hv/mod_irq: move NMI and exception handler out of x86/irq.c

Each of them now resides in a separate .c file.

Tracked-On: #5825

Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Liang Yi 2021-03-02 10:24:14 +08:00 committed by wenlingz
parent 6098648373
commit 798015876c
4 changed files with 67 additions and 45 deletions

View File

@ -215,6 +215,8 @@ HW_C_SRCS += arch/x86/page.c
HW_C_SRCS += arch/x86/notify.c
HW_C_SRCS += arch/x86/vtd.c
HW_C_SRCS += arch/x86/gdt.c
HW_C_SRCS += arch/x86/nmi.c
HW_C_SRCS += arch/x86/exception.c
HW_C_SRCS += arch/x86/irq.c
HW_C_SRCS += arch/x86/timer.c
HW_C_SRCS += arch/x86/vmx.c

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch/x86/cpu.h>
#include <arch/x86/irq.h>
#include <debug/dump.h>
void dispatch_exception(struct intr_excp_ctx *ctx)
{
uint16_t pcpu_id = get_pcpu_id();
/* Dump exception context */
dump_exception(ctx, pcpu_id);
/* Halt the CPU */
cpu_dead();
}

View File

@ -212,51 +212,9 @@ void dispatch_interrupt(const struct intr_excp_ctx *ctx)
}
}
void dispatch_exception(struct intr_excp_ctx *ctx)
{
uint16_t pcpu_id = get_pcpu_id();
/* Dump exception context */
dump_exception(ctx, pcpu_id);
/* Halt the CPU */
cpu_dead();
}
void handle_nmi(__unused struct intr_excp_ctx *ctx)
{
uint32_t value32;
/*
* There is a window where we may miss the current request in this
* notification period when the work flow is as the following:
*
* CPUx + + CPUr
* | |
* | +--+
* | | | Handle pending req
* | <--+
* +--+ |
* | | Set req flag |
* <--+ |
* +------------------>---+
* | Send NMI | | Handle NMI
* | <--+
* | |
* | |
* | +--> vCPU enter
* | |
* + +
*
* So, here we enable the NMI-window exiting to trigger the next vmexit
* once there is no "virtual-NMI blocking" after vCPU enter into VMX non-root
* mode. Then we can process the pending request on time.
*/
value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
value32 |= VMX_PROCBASED_CTLS_NMI_WINEXIT;
exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
}
/*
* descs[] must have NR_IRQS entries
*/
void init_irq_descs_arch(struct irq_desc descs[])
{
uint32_t i;

42
hypervisor/arch/x86/nmi.c Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch/x86/irq.h>
#include <arch/x86/vmx.h>
void handle_nmi(__unused struct intr_excp_ctx *ctx)
{
uint32_t value32;
/*
* There is a window where we may miss the current request in this
* notification period when the work flow is as the following:
*
* CPUx + + CPUr
* | |
* | +--+
* | | | Handle pending req
* | <--+
* +--+ |
* | | Set req flag |
* <--+ |
* +------------------>---+
* | Send NMI | | Handle NMI
* | <--+
* | |
* | |
* | +--> vCPU enter
* | |
* + +
*
* So, here we enable the NMI-window exiting to trigger the next vmexit
* once there is no "virtual-NMI blocking" after vCPU enter into VMX non-root
* mode. Then we can process the pending request on time.
*/
value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS);
value32 |= VMX_PROCBASED_CTLS_NMI_WINEXIT;
exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS, value32);
}