From: Oliver Upton <oupton@google.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Oliver Upton <oupton@google.com>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <sean.j.christopherson@intel.com>,
Jim Mattson <jmattson@google.com>,
Peter Shier <pshier@google.com>
Subject: [PATCH] kvm: x86: get vmcs12 pages before checking pending interrupts
Date: Tue, 5 May 2020 23:22:01 +0000 [thread overview]
Message-ID: <20200505232201.923-1-oupton@google.com> (raw)
vmx_guest_apic_has_interrupt implicitly depends on the virtual APIC
page being present + mapped into the kernel address space. Normally,
upon VMLAUNCH/VMRESUME, we get the vmcs12 pages directly. However, if a
live migration were to occur before reaching vcpu_block, the virtual
APIC will not be restored on the target host.
Fix this by getting vmcs12 pages before inspecting the virtual APIC
page.
Cc: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Oliver Upton <oupton@google.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
---
Parent commit: 7c67f54661fc ("KVM: SVM: do not allow VMRUN inside SMM")
arch/x86/kvm/x86.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8c0b77ac8dc6..edd3b75ad578 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8494,6 +8494,16 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu)
{
+ /*
+ * We must first get the vmcs12 pages before checking for interrupts
+ * (done in kvm_arch_vcpu_runnable) in case L1 is using
+ * virtual-interrupt delivery.
+ */
+ if (kvm_check_request(KVM_REQ_GET_VMCS12_PAGES, vcpu)) {
+ if (unlikely(!kvm_x86_ops.nested_ops->get_vmcs12_pages(vcpu)))
+ return 0;
+ }
+
if (!kvm_arch_vcpu_runnable(vcpu) &&
(!kvm_x86_ops.pre_block || kvm_x86_ops.pre_block(vcpu) == 0)) {
srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
--
2.26.2.526.g744177e7f7-goog
next reply other threads:[~2020-05-05 23:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 23:22 Oliver Upton [this message]
2020-05-06 12:07 ` [PATCH] kvm: x86: get vmcs12 pages before checking pending interrupts Paolo Bonzini
2020-05-06 15:25 ` Sean Christopherson
2020-05-06 16:00 ` Paolo Bonzini
2020-05-06 16:48 ` Sean Christopherson
2020-05-06 17:19 ` Oliver Upton
2020-05-06 17:43 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200505232201.923-1-oupton@google.com \
--to=oupton@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=pshier@google.com \
--cc=sean.j.christopherson@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox