mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-11 04:52:58 +00:00
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:
parent
6098648373
commit
798015876c
@ -215,6 +215,8 @@ HW_C_SRCS += arch/x86/page.c
|
|||||||
HW_C_SRCS += arch/x86/notify.c
|
HW_C_SRCS += arch/x86/notify.c
|
||||||
HW_C_SRCS += arch/x86/vtd.c
|
HW_C_SRCS += arch/x86/vtd.c
|
||||||
HW_C_SRCS += arch/x86/gdt.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/irq.c
|
||||||
HW_C_SRCS += arch/x86/timer.c
|
HW_C_SRCS += arch/x86/timer.c
|
||||||
HW_C_SRCS += arch/x86/vmx.c
|
HW_C_SRCS += arch/x86/vmx.c
|
||||||
|
20
hypervisor/arch/x86/exception.c
Normal file
20
hypervisor/arch/x86/exception.c
Normal 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();
|
||||||
|
}
|
@ -212,51 +212,9 @@ void dispatch_interrupt(const struct intr_excp_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatch_exception(struct intr_excp_ctx *ctx)
|
/*
|
||||||
{
|
* descs[] must have NR_IRQS entries
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_irq_descs_arch(struct irq_desc descs[])
|
void init_irq_descs_arch(struct irq_desc descs[])
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
42
hypervisor/arch/x86/nmi.c
Normal file
42
hypervisor/arch/x86/nmi.c
Normal 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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user