mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	x86@kernel.org, "Wanpeng Li" <kernellwp@gmail.com>,
	"KarimAllah Ahmed" <karahmed@amazon.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] x86/kvm/nVMX: set exit_qualification correctly when nested_vmx_load_msr() fails
Date: Thu, 12 Jul 2018 13:35:05 +0200	[thread overview]
Message-ID: <20180712113505.23354-1-vkuznets@redhat.com> (raw)

Commit e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent
the running guest") introduced a regression in enter_vmx_non_root_mode():
when nested_vmx_load_msr() fails exit_qualification needs to point to the
entry number we failed to validate. Intel's SDM states:

"VM-entry failure due to MSR loading. The exit qualification is loaded to
indicate which entry in the VM-entry MSR-load area caused the problem (1
for the first entry, 2 for the second, etc.)."

Fixes: e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest")
Reported-by: Wanpeng Li <kernellwp@gmail.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/kvm/vmx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 65968649b365..be468c822892 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11720,8 +11720,10 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu)
 	msr_entry_idx = nested_vmx_load_msr(vcpu,
 					    vmcs12->vm_entry_msr_load_addr,
 					    vmcs12->vm_entry_msr_load_count);
-	if (msr_entry_idx)
+	if (msr_entry_idx) {
+		exit_qual = msr_entry_idx;
 		goto fail;
+	}
 
 	/*
 	 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point
-- 
2.14.4


             reply	other threads:[~2018-07-12 11:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 11:35 Vitaly Kuznetsov [this message]
2018-07-12 16:25 ` Jim Mattson
2018-07-12 16:57   ` Vitaly Kuznetsov
2018-07-15 14:30     ` 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=20180712113505.23354-1-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=karahmed@amazon.de \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®