diff options
author | Gleb Natapov <gleb@redhat.com> | 2009-03-30 09:03:08 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-06-10 04:48:36 -0400 |
commit | 7b4a25cb296e2a73d2e87a4af65361d45d450a27 (patch) | |
tree | 676e601fd5e518174b5179cfe99d8668ff4abff4 /arch/x86/kvm/vmx.c | |
parent | 20c466b56168ddccf034c136510d73e4a0e18605 (diff) |
KVM: VMX: Fix handling of a fault during NMI unblocked due to IRET
Bit 12 is undefined in any of the following cases:
If the VM exit sets the valid bit in the IDT-vectoring information field.
If the VM exit is due to a double fault.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r-- | arch/x86/kvm/vmx.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7d7b0d6e3f58..631f9b720971 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -3272,36 +3272,41 @@ static void update_tpr_threshold(struct kvm_vcpu *vcpu) | |||
3272 | static void vmx_complete_interrupts(struct vcpu_vmx *vmx) | 3272 | static void vmx_complete_interrupts(struct vcpu_vmx *vmx) |
3273 | { | 3273 | { |
3274 | u32 exit_intr_info; | 3274 | u32 exit_intr_info; |
3275 | u32 idt_vectoring_info; | 3275 | u32 idt_vectoring_info = vmx->idt_vectoring_info; |
3276 | bool unblock_nmi; | 3276 | bool unblock_nmi; |
3277 | u8 vector; | 3277 | u8 vector; |
3278 | int type; | 3278 | int type; |
3279 | bool idtv_info_valid; | 3279 | bool idtv_info_valid; |
3280 | u32 error; | 3280 | u32 error; |
3281 | 3281 | ||
3282 | idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK; | ||
3282 | exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO); | 3283 | exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO); |
3283 | if (cpu_has_virtual_nmis()) { | 3284 | if (cpu_has_virtual_nmis()) { |
3284 | unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0; | 3285 | unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0; |
3285 | vector = exit_intr_info & INTR_INFO_VECTOR_MASK; | 3286 | vector = exit_intr_info & INTR_INFO_VECTOR_MASK; |
3286 | /* | 3287 | /* |
3287 | * SDM 3: 25.7.1.2 | 3288 | * SDM 3: 27.7.1.2 (September 2008) |
3288 | * Re-set bit "block by NMI" before VM entry if vmexit caused by | 3289 | * Re-set bit "block by NMI" before VM entry if vmexit caused by |
3289 | * a guest IRET fault. | 3290 | * a guest IRET fault. |
3291 | * SDM 3: 23.2.2 (September 2008) | ||
3292 | * Bit 12 is undefined in any of the following cases: | ||
3293 | * If the VM exit sets the valid bit in the IDT-vectoring | ||
3294 | * information field. | ||
3295 | * If the VM exit is due to a double fault. | ||
3290 | */ | 3296 | */ |
3291 | if (unblock_nmi && vector != DF_VECTOR) | 3297 | if ((exit_intr_info & INTR_INFO_VALID_MASK) && unblock_nmi && |
3298 | vector != DF_VECTOR && !idtv_info_valid) | ||
3292 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, | 3299 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, |
3293 | GUEST_INTR_STATE_NMI); | 3300 | GUEST_INTR_STATE_NMI); |
3294 | } else if (unlikely(vmx->soft_vnmi_blocked)) | 3301 | } else if (unlikely(vmx->soft_vnmi_blocked)) |
3295 | vmx->vnmi_blocked_time += | 3302 | vmx->vnmi_blocked_time += |
3296 | ktime_to_ns(ktime_sub(ktime_get(), vmx->entry_time)); | 3303 | ktime_to_ns(ktime_sub(ktime_get(), vmx->entry_time)); |
3297 | 3304 | ||
3298 | idt_vectoring_info = vmx->idt_vectoring_info; | ||
3299 | idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK; | ||
3300 | vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK; | 3305 | vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK; |
3301 | type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK; | 3306 | type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK; |
3302 | if (vmx->vcpu.arch.nmi_injected) { | 3307 | if (vmx->vcpu.arch.nmi_injected) { |
3303 | /* | 3308 | /* |
3304 | * SDM 3: 25.7.1.2 | 3309 | * SDM 3: 27.7.1.2 (September 2008) |
3305 | * Clear bit "block by NMI" before VM entry if a NMI delivery | 3310 | * Clear bit "block by NMI" before VM entry if a NMI delivery |
3306 | * faulted. | 3311 | * faulted. |
3307 | */ | 3312 | */ |