Commit 654f06fc authored by Avi Kivity's avatar Avi Kivity

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: default avatarAvi Kivity <avi@redhat.com>
parent 89a9fb78
...@@ -3532,11 +3532,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu) ...@@ -3532,11 +3532,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
switch (type) { switch (type) {
case INTR_TYPE_NMI_INTR: case INTR_TYPE_NMI_INTR:
vcpu->arch.nmi_injected = false; vcpu->arch.nmi_injected = false;
if (cpu_has_virtual_nmis()) { vmx_set_nmi_mask(vcpu, true);
vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO,
GUEST_INTR_STATE_NMI);
vmx->nmi_known_unmasked = false;
}
break; break;
case INTR_TYPE_EXT_INTR: case INTR_TYPE_EXT_INTR:
case INTR_TYPE_SOFT_INTR: case INTR_TYPE_SOFT_INTR:
...@@ -3991,9 +3987,7 @@ static void __vmx_complete_interrupts(struct vcpu_vmx *vmx, ...@@ -3991,9 +3987,7 @@ static void __vmx_complete_interrupts(struct vcpu_vmx *vmx,
* Clear bit "block by NMI" before VM entry if a NMI * Clear bit "block by NMI" before VM entry if a NMI
* delivery faulted. * delivery faulted.
*/ */
vmcs_clear_bits(GUEST_INTERRUPTIBILITY_INFO, vmx_set_nmi_mask(&vmx->vcpu, false);
GUEST_INTR_STATE_NMI);
vmx->nmi_known_unmasked = true;
break; break;
case INTR_TYPE_SOFT_EXCEPTION: case INTR_TYPE_SOFT_EXCEPTION:
vmx->vcpu.arch.event_exit_inst_len = vmx->vcpu.arch.event_exit_inst_len =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment