KVM: Add VT-x machine check support v2
PATCH 1/1 KVM: Add VT-x machine check support v2
sorry took a bit longer to do this, had some trouble with my test rig. This addresses the preemptible kernel problem discussed earlier. I tried to not add more vmcb reads, so I'm caching the exit_reason in memory over callbacks.
Note I'm on offline for some time, if there further issues please contact Ying Huang (cc'ed)
-Andi
---
KVM: Add VT-x machine check support v2
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 Huang Ying and Jiang Yunhong for help and testing.
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
--- arch/x86/include/asm/kvm_host.h | 2 + arch/x86/include/asm/vmx.h | 1 arch/x86/kvm/vmx.c | 41 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-)
arch/x86/include/asm/vmx.h +1 -0
@@ -247,6 +247,7 @@#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 +38 -3
89 lines not on this page · raw message
arch/x86/include/asm/kvm_host.h +2 -0
@@ -371,6 +371,8 @@unsigned long dr6;unsigned long dr7;unsigned long eff_db[KVM_NR_DB_REGS ]; + +u32 exit_reason; };struct kvm_mem_alias {
Quoted 11 lines · Andi Kleen
KVM: Add VT-x machine check support v2
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 Huang Ying and Jiang Yunhong for help and testing.
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
Signed-off-by Andi Kleen <[email protected]>
Only applies with -C0. What tree was this generated against?
Please diff and test against latest kvm.git.
arch/x86/include/asm/kvm_host.h line 377
Quoted 11 lines
===================================================================
arch/x86/include/asm/kvm_host.h +2
-0@@ -371,6 +371,8 @@unsigned long dr6;unsigned long dr7;unsigned long eff_db[KVM_NR_DB_REGS ]; + +u32 exit_reason; };
This should be in 'struct vcpu_vmx' (vmx.c), as it's vmx specific.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 8 lines · Avi Kivity
Quoted 6 lines
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
Signed-off-by Andi Kleen <[email protected]>Only applies with -C0. What tree was this generated against?
2.6.30-rc7
Quoted 1 line
Please diff and test against latest kvm.git.
Sorry can't do neither for the next two weeks.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 5 lines · Andi Kleen
Quoted 3 lines · Avi Kivity
Quoted 3 lines
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Signed-off-by Andi Kleen <[email protected]>Only applies with -C0. What tree was this generated against?
2.6.30-rc7
Please use kvm.git, which is maybe 150 patches ahead.
Quoted 5 lines
Quoted 2 lines
Please diff and test against latest kvm.git.
Sorry can't do neither for the next two weeks.
Ying?
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 8 lines · Andi Kleen
Quoted 7 lines · Avi Kivity
Quoted 6 lines
v2: Handle machine checks still in interrupt off context to avoid problems on preemptible kernels.
Signed-off-by Andi Kleen <[email protected]>
Quoted 7 lines
Quoted 1 line
Only applies with -C0. What tree was this generated against?
2.6.30-rc7
Quoted 1 line
Please diff and test against latest kvm.git.
Sorry can't do neither for the next two weeks.
I will do this.
Best Regards,
Huang Ying