aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2013-04-14 15:04:26 -0400
committerGleb Natapov <gleb@redhat.com>2013-04-22 04:10:49 -0400
commitea8ceb8354e1c84a13cf2a8e915dc74f96759393 (patch)
treec200b09a828deaac744f403f76c235ede613ad7e /arch/x86
parent2505dc9fad44491ac4ce06290f358c030abe6be3 (diff)
KVM: nVMX: Fix conditions for NMI injection
The logic for checking if interrupts can be injected has to be applied also on NMIs. The difference is that if NMI interception is on these events are consumed and blocked by the VM exit. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/vmx.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 451ab2a57ca0..11ea3cbbb78c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4392,6 +4392,12 @@ static bool nested_exit_on_intr(struct kvm_vcpu *vcpu)
4392 PIN_BASED_EXT_INTR_MASK; 4392 PIN_BASED_EXT_INTR_MASK;
4393} 4393}
4394 4394
4395static bool nested_exit_on_nmi(struct kvm_vcpu *vcpu)
4396{
4397 return get_vmcs12(vcpu)->pin_based_vm_exec_control &
4398 PIN_BASED_NMI_EXITING;
4399}
4400
4395static void enable_irq_window(struct kvm_vcpu *vcpu) 4401static void enable_irq_window(struct kvm_vcpu *vcpu)
4396{ 4402{
4397 u32 cpu_based_vm_exec_control; 4403 u32 cpu_based_vm_exec_control;
@@ -4517,6 +4523,26 @@ static void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked)
4517 4523
4518static int vmx_nmi_allowed(struct kvm_vcpu *vcpu) 4524static int vmx_nmi_allowed(struct kvm_vcpu *vcpu)
4519{ 4525{
4526 if (is_guest_mode(vcpu)) {
4527 struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
4528
4529 if (to_vmx(vcpu)->nested.nested_run_pending)
4530 return 0;
4531 if (nested_exit_on_nmi(vcpu)) {
4532 nested_vmx_vmexit(vcpu);
4533 vmcs12->vm_exit_reason = EXIT_REASON_EXCEPTION_NMI;
4534 vmcs12->vm_exit_intr_info = NMI_VECTOR |
4535 INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK;
4536 /*
4537 * The NMI-triggered VM exit counts as injection:
4538 * clear this one and block further NMIs.
4539 */
4540 vcpu->arch.nmi_pending = 0;
4541 vmx_set_nmi_mask(vcpu, true);
4542 return 0;
4543 }
4544 }
4545
4520 if (!cpu_has_virtual_nmis() && to_vmx(vcpu)->soft_vnmi_blocked) 4546 if (!cpu_has_virtual_nmis() && to_vmx(vcpu)->soft_vnmi_blocked)
4521 return 0; 4547 return 0;
4522 4548