KVM: Add VT-x machine check support
PATCH 1/1 KVM: Add VT-x machine check support
From: Andi Kleen <[email protected]>
VT-x needs an explicit MC vector intercept to handle machine checks in the hyper visor.
It also has a special option to catch machine checks that happen during VT entry.
Do these interceptions and forward them to the Linux machine check handler. Make it always look like user space is interrupted because the machine check handler treats kernel/user space differently.
Thanks to Jiang Yunhong for help and testing.
v4: move exit_reason to struct vcpu_vmx, add is_machine_check()
v3: Rebased on kvm.git
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
--- arch/x86/include/asm/vmx.h | 1 arch/x86/kernel/cpu/mcheck/mce_64.c | 1 arch/x86/kvm/vmx.c | 47 ++++++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-)
arch/x86/include/asm/vmx.h +1 -0
@@ -247,6 +247,7 @@ enum vmcs_field {#define EXIT_REASON_MSR_READ 31#define EXIT_REASON_MSR_WRITE 32#define EXIT_REASON_MWAIT_INSTRUCTION 36 +#define EXIT_REASON_MCE_DURING_VMENTRY 41#define EXIT_REASON_TPR_BELOW_THRESHOLD 43#define EXIT_REASON_APIC_ACCESS 44#define EXIT_REASON_EPT_VIOLATION 48
arch/x86/kvm/vmx.c +45 -2
102 lines not on this page · raw message
arch/x86/kernel/cpu/mcheck/mce_64.c +1 -0
@@ -420,6 +420,7 @@ void do_machine_check(struct pt_regs * r out2:atomic_dec (&mce_entry); } +EXPORT_SYMBOL_GPL (do_machine_check);#ifdef CONFIG_X86_MCE_INTEL /***
Avi Kivity
AppliedQuoted 11 lines · Huang Ying
From: Andi Kleen <[email protected]>
VT-x needs an explicit MC vector intercept to handle machine checks in the hyper visor.
It also has a special option to catch machine checks that happen during VT entry.
Do these interceptions and forward them to the Linux machine check handler. Make it always look like user space is interrupted because the machine check handler treats kernel/user space differently.
Quoted 10 lines
Thanks to Jiang Yunhong for help and testing.
v4: move
exit_reasonto structvcpu_vmx, addis_machine_check()v3: Rebased on kvm.git
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
Applied, thanks.
arch/x86/kvm/vmx.c static void vmx_complete_interrupts(stru · line 3329
Quoted 9 lines
arch/x86/kvm/vmx.c +7
-0+ vmx->exit_reason =vmcs_read32 (VM_EXIT_REASON ); + +/* Handle machine checks before interrupts are enabled */ +if ((vmx->exit_reason ==EXIT_REASON_MCE_DURING_VMENTRY ) || +is_machine_check (exit_intr_info)) +kvm_machine_check (); +
I added a check here for exit_reason == EXCEPTION_NMI. I don't think exit_intr_info can be trusted otherwise.
Signature · 1 line
error compiling committee.c: too many arguments to function