diff options
author | Avi Kivity <avi@redhat.com> | 2011-03-23 09:02:47 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-11 07:56:57 -0400 |
commit | 654f06fc651b01782015185e5b049197255463a3 (patch) | |
tree | b6651c050398054e92a4e8ba7e0d0ad3475d4419 | |
parent | 89a9fb78b5bd8bece353449079726556ecab41df (diff) |
KVM: VMX: simplify NMI mask management
Use vmx_set_nmi_mask() instead of open-coding management of
the hardware bit and the software hint (nmi_known_unmasked).
There's a slight change of behaviour when running without
hardware virtual NMI support - we now clear the NMI mask if
NMI delivery faulted in that case as well. This improves
emulation accuracy.
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/kvm/vmx.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1bdb49de6a22..2b99ae72481f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -3532,11 +3532,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu) | |||
3532 | switch (type) { | 3532 | switch (type) { |
3533 | case INTR_TYPE_NMI_INTR: | 3533 | case INTR_TYPE_NMI_INTR: |
3534 | vcpu->arch.nmi_injected = false; | 3534 | vcpu->arch.nmi_injected = false; |
3535 | if (cpu_has_virtual_nmis()) { | 3535 | vmx_set_nmi_mask(vcpu, true); |
3536 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, | ||
3537 | GUEST_INTR_STATE_NMI); | ||
3538 | vmx->nmi_known_unmasked = false; | ||
3539 | } | ||
3540 | break; | 3536 | break; |
3541 | case INTR_TYPE_EXT_INTR: | 3537 | case INTR_TYPE_EXT_INTR: |
3542 | case INTR_TYPE_SOFT_INTR: | 3538 | case INTR_TYPE_SOFT_INTR: |
@@ -3991,9 +3987,7 @@ static void __vmx_complete_interrupts(struct vcpu_vmx *vmx, | |||
3991 | * Clear bit "block by NMI" before VM entry if a NMI | 3987 | * Clear bit "block by NMI" before VM entry if a NMI |
3992 | * delivery faulted. | 3988 | * delivery faulted. |
3993 | */ | 3989 | */ |
3994 | vmcs_clear_bits(GUEST_INTERRUPTIBILITY_INFO, | 3990 | vmx_set_nmi_mask(&vmx->vcpu, false); |
3995 | GUEST_INTR_STATE_NMI); | ||
3996 | vmx->nmi_known_unmasked = true; | ||
3997 | break; | 3991 | break; |
3998 | case INTR_TYPE_SOFT_EXCEPTION: | 3992 | case INTR_TYPE_SOFT_EXCEPTION: |
3999 | vmx->vcpu.arch.event_exit_inst_len = | 3993 | vmx->vcpu.arch.event_exit_inst_len = |