From: David Woodhouse <dwmw2@infradead.org>
To: Tom Lendacky <thomas.lendacky@amd.com>,
KarimAllah Ahmed <karahmed@amazon.de>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org
Cc: Ashok Raj <ashok.raj@intel.com>,
Asit Mallick <asit.k.mallick@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Arjan Van De Ven <arjan.van.de.ven@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Andi Kleen <ak@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Dan Williams <dan.j.williams@intel.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Andy Lutomirski <luto@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v3 2/4] KVM: x86: Add IBPB support
Date: Tue, 30 Jan 2018 14:36:18 +0000 [thread overview]
Message-ID: <1517322978.18619.122.camel@infradead.org> (raw)
In-Reply-To: <eea20236-35ff-4900-5749-42915df389e9@amd.com>
[-- Attachment #1: Type: text/plain, Size: 2393 bytes --]
On Tue, 2018-01-30 at 08:22 -0600, Tom Lendacky wrote:
> > @@ -918,6 +919,9 @@ static void svm_vcpu_init_msrpm(u32 *msrpm)
> >
> > set_msr_interception(msrpm, direct_access_msrs[i].index, 1, 1);
> > }
> > +
> > + if (boot_cpu_has(X86_FEATURE_IBPB))
> > + set_msr_interception(msrpm, MSR_IA32_PRED_CMD, 1, 1);
>
> Not sure you really need the check here. If the feature isn't available
> in the hardware, then it won't be advertised in the CPUID bits to the
> guest, so the guest shouldn't try to write to the msr. If it does, it
> will #GP. So I would think it could be set all the time to not be
> intercepted, no?
The check for boot_cpu_has() is wrong and is fairly redundant as you
say. What we actually want is guest_cpu_has(). We *don't* want to pass
the MSR through for a recalcitrant guest to bash on, if we have elected
not to expose this feature to the guest.
On Intel right now it's *really* important that we don't allow it to be
touched, even if a write would succeed. So even boot_cpu_has() would
not be entirely meaningless there. :)
> > @@ -3330,6 +3331,14 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> > case MSR_IA32_TSC:
> > kvm_write_tsc(vcpu, msr_info);
> > break;
> > + case MSR_IA32_PRED_CMD:
> > + if (!msr_info->host_initiated &&
> > + !guest_cpuid_has(vcpu, X86_FEATURE_IBPB))
> > + return 1;
> > +
> > + if (data & PRED_CMD_IBPB)
> > + wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_IBPB);
> > + break;
>
> Should this also be in svm.c or as common code in x86.c?
See my response to [0/4]. I suggested that, but noted that it wasn't
entirely clear where we'd put the storage for SPEC_CTRL. We probably
*could* manage it for IBPB though.
> >
> > case MSR_IA32_CR_PAT:
> > if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
> > if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
> > @@ -9548,6 +9557,9 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
> > goto free_msrs;
> >
> > msr_bitmap = vmx->vmcs01.msr_bitmap;
> > +
> > + if (boot_cpu_has(X86_FEATURE_IBPB))
> > + vmx_disable_intercept_for_msr(msr_bitmap, MSR_IA32_PRED_CMD, MSR_TYPE_W);
>
> Same comment here as in svm.c, is the feature check necessary?
Again, yes but it should be guest_cpu_has() and we couldn't see how :)
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5213 bytes --]
next prev parent reply other threads:[~2018-01-30 14:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-30 0:10 [PATCH v3 0/4] KVM: Expose speculation control feature to guests KarimAllah Ahmed
2018-01-30 0:10 ` [PATCH v3 1/4] KVM: x86: Update the reverse_cpuid list to include CPUID_7_EDX KarimAllah Ahmed
2018-01-30 23:17 ` Paolo Bonzini
2018-01-30 0:10 ` [PATCH v3 2/4] KVM: x86: Add IBPB support KarimAllah Ahmed
2018-01-30 14:22 ` Tom Lendacky
2018-01-30 14:36 ` David Woodhouse [this message]
2018-01-30 17:19 ` Jim Mattson
2018-01-30 17:43 ` David Woodhouse
2018-01-30 0:10 ` [PATCH v3 3/4] KVM: VMX: Emulate MSR_IA32_ARCH_CAPABILITIES KarimAllah Ahmed
2018-01-30 0:22 ` Raj, Ashok
2018-01-30 0:25 ` KarimAllah Ahmed
2018-01-30 23:21 ` Paolo Bonzini
2018-01-30 0:10 ` [PATCH v3 4/4] KVM: VMX: Allow direct access to MSR_IA32_SPEC_CTRL KarimAllah Ahmed
2018-01-30 17:49 ` Jim Mattson
2018-01-30 21:00 ` KarimAllah Ahmed
2018-01-30 22:49 ` Jim Mattson
2018-01-30 23:32 ` Paolo Bonzini
2018-01-30 23:50 ` KarimAllah Ahmed
2018-01-31 0:16 ` Jim Mattson
2018-01-31 0:19 ` Paolo Bonzini
2018-01-31 0:27 ` Jim Mattson
2018-01-31 0:52 ` KarimAllah Ahmed
2018-01-31 0:56 ` Paolo Bonzini
2018-01-30 9:00 ` [PATCH v3 0/4] KVM: Expose speculation control feature to guests David Woodhouse
2018-01-30 9:32 ` KarimAllah Ahmed
2018-01-30 23:36 ` Paolo Bonzini
2018-01-30 23:48 ` Raj, Ashok
2018-01-31 0:16 ` Paolo Bonzini
2018-01-31 0:26 ` David Woodhouse
2018-01-31 6:54 ` Dave Hansen
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=1517322978.18619.122.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=arjan.van.de.ven@intel.com \
--cc=ashok.raj@intel.com \
--cc=asit.k.mallick@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jun.nakajima@intel.com \
--cc=karahmed@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--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