summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2019-01-07 19:44:51 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-05 17:58:02 +0100
commit7ce9d889aa00d88dacf9a88a293cea555a148a7f (patch)
tree9dbcd81ac8a4f3a63e88e4bf606d33d4570ddcf1 /arch/x86/kvm/svm.c
parentf20cf376cc63d887a989cd4521bcccd669ebd3eb (diff)
downloadlinux-stable-7ce9d889aa00d88dacf9a88a293cea555a148a7f.tar.gz
linux-stable-7ce9d889aa00d88dacf9a88a293cea555a148a7f.tar.bz2
linux-stable-7ce9d889aa00d88dacf9a88a293cea555a148a7f.zip
KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1
[ Upstream commit 619ad846fc3452adaf71ca246c5aa711e2055398 ] kvm-unit-tests' eventinj "NMI failing on IDT" test results in NMI being delivered to the host (L1) when it's running nested. The problem seems to be: svm_complete_interrupts() raises 'nmi_injected' flag but later we decide to reflect EXIT_NPF to L1. The flag remains pending and we do NMI injection upon entry so it got delivered to L1 instead of L2. It seems that VMX code solves the same issue in prepare_vmcs12(), this was introduced with code refactoring in commit 5f3d5799974b ("KVM: nVMX: Rework event injection and recovery"). Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a94beaecd3e0..c387047e926a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2929,6 +2929,14 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
kvm_mmu_reset_context(&svm->vcpu);
kvm_mmu_load(&svm->vcpu);
+ /*
+ * Drop what we picked up for L2 via svm_complete_interrupts() so it
+ * doesn't end up in L1.
+ */
+ svm->vcpu.arch.nmi_injected = false;
+ kvm_clear_exception_queue(&svm->vcpu);
+ kvm_clear_interrupt_queue(&svm->vcpu);
+
return 0;
}