From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: x86@kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>,
"KarimAllah Ahmed" <karahmed@amazon.de>,
"David Woodhouse" <dwmw@amazon.co.uk>,
"Jim Mattson" <jmattson@google.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH 2/3] KVM: nVMX: fix wrong condition for SPEC_CTRL and PRED_CMD MSRs
Date: Wed, 21 Feb 2018 22:41:36 +0100 [thread overview]
Message-ID: <1519249297-73718-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1519249297-73718-1-git-send-email-pbonzini@redhat.com>
We need to change the default all-1s bitmap if the MSRs are _not_
intercepted. However, the code was disabling the intercept when it was
_enabled_ in the VMCS01. This is not causing bigger trouble,
because vmx_vcpu_run checks the VMCS02's MSR bitmap and would do the
right thing even if fed garbage... but it's obviously a bug and it can
cause extra MSR reads and writes when running nested guests.
Fixes: d28b387fb74da95d69d2615732f50cceb38e9a4d
Fixes: 15d45071523d89b3fb7372e2135fbd72f6af9506
Cc: x86@kernel.org
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: KarimAllah Ahmed <karahmed@amazon.de>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Jim Mattson <jmattson@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/vmx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 5caeb8dc5bda..af89d377681d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -10235,7 +10235,7 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
return false;
if (!nested_cpu_has_virt_x2apic_mode(vmcs12) &&
- !pred_cmd && !spec_ctrl)
+ pred_cmd && spec_ctrl)
return false;
page = kvm_vcpu_gpa_to_page(vcpu, vmcs12->msr_bitmap);
@@ -10278,13 +10278,13 @@ static inline bool nested_vmx_prepare_msr_bitmap(struct kvm_vcpu *vcpu,
MSR_TYPE_W);
}
- if (spec_ctrl)
+ if (!spec_ctrl)
nested_vmx_disable_intercept_for_msr(
msr_bitmap_l1, msr_bitmap_l0,
MSR_IA32_SPEC_CTRL,
MSR_TYPE_R | MSR_TYPE_W);
- if (pred_cmd)
+ if (!pred_cmd)
nested_vmx_disable_intercept_for_msr(
msr_bitmap_l1, msr_bitmap_l0,
MSR_IA32_PRED_CMD,
--
1.8.3.1
next prev parent reply other threads:[~2018-02-21 21:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 21:41 [PATCH 0/3] x86/pti: KVM: fixes and optimizations for IBRS Paolo Bonzini
2018-02-21 21:41 ` [PATCH 1/3] KVM: x86: use native MSR ops for SPEC_CTRL Paolo Bonzini
2018-02-21 23:49 ` Jim Mattson
2018-02-22 17:07 ` Konrad Rzeszutek Wilk
2018-02-23 9:37 ` Paolo Bonzini
2018-02-23 17:22 ` Konrad Rzeszutek Wilk
2018-02-23 17:35 ` Paolo Bonzini
2018-02-23 17:55 ` Konrad Rzeszutek Wilk
2018-02-21 21:41 ` Paolo Bonzini [this message]
2018-02-22 0:07 ` [PATCH 2/3] KVM: nVMX: fix wrong condition for SPEC_CTRL and PRED_CMD MSRs Jim Mattson
2018-02-22 9:39 ` Paolo Bonzini
2018-02-21 21:41 ` [PATCH 3/3] KVM: VMX: mark RDMSR path as unlikely Paolo Bonzini
2018-02-22 0:25 ` Jim Mattson
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=1519249297-73718-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=dwmw@amazon.co.uk \
--cc=jmattson@google.com \
--cc=karahmed@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rkrcmar@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--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®