From: Pavel Machek <pavel@ucw.cz>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Woodhouse <dwmw@amazon.co.uk>,
tglx@linutronix.de, x86@kernel.org, kvm@vger.kernel.org,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
arjan.van.de.ven@intel.com, dave.hansen@intel.com
Subject: Re: [PATCH 2/2] x86/speculation: Support "Enhanced IBRS" on future CPUs
Date: Thu, 15 Feb 2018 16:21:39 +0100 [thread overview]
Message-ID: <20180215152139.GA23145@amd> (raw)
In-Reply-To: <7e2e5ad1-49b6-1fdb-4a62-8ad6aefc30a0@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3231 bytes --]
On Tue 2018-02-13 09:02:25, Paolo Bonzini wrote:
> On 12/02/2018 16:27, David Woodhouse wrote:
> > The original IBRS hack in microcode is horribly slow. For the next
> > generation of CPUs, as a stopgap until we get a proper fix, Intel
> > promise an "Enhanced IBRS" which will be fast.
> >
> > The assumption is that predictions in the BTB/RSB will be tagged with
> > the VMX mode and ring that they were learned in, and thus the CPU will
> > avoid consuming unsafe predictions without a performance penalty.
> >
> > Intel's documentation says that it is still required to set the IBRS bit
> > in the SPEC_CTRL MSR and ensure that it remains set.
> >
> > Cope with this by trapping and emulating *all* access to SPEC_CTRL from
> > KVM guests when the IBRS_ALL feature is present, so it can never be
> > turned off. Guests who see IBRS_ALL should never do anything except
> > turn it on at boot anyway. And if they didn't know about IBRS_ALL and
> > they keep frobbing IBRS on every kernel entry/exit... well the vmexit
> > for a no-op is probably going to be faster than they were expecting
> > anyway, so they'll live.
> >
> > Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> > Acked-by: Arjan van de Ven <arjan.van.de.ven@intel.com>
> > ---
> > arch/x86/include/asm/nospec-branch.h | 9 ++++++++-
> > arch/x86/kernel/cpu/bugs.c | 16 ++++++++++++++--
> > arch/x86/kvm/vmx.c | 17 ++++++++++-------
> > 3 files changed, 32 insertions(+), 10 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
> > index 788c4da..524bb86 100644
> > --- a/arch/x86/include/asm/nospec-branch.h
> > +++ b/arch/x86/include/asm/nospec-branch.h
> > @@ -140,9 +140,16 @@ enum spectre_v2_mitigation {
> > SPECTRE_V2_RETPOLINE_MINIMAL_AMD,
> > SPECTRE_V2_RETPOLINE_GENERIC,
> > SPECTRE_V2_RETPOLINE_AMD,
> > - SPECTRE_V2_IBRS,
> > + SPECTRE_V2_IBRS_ALL,
> > };
> >
> > +extern enum spectre_v2_mitigation spectre_v2_enabled;
> > +
> > +static inline bool spectre_v2_ibrs_all(void)
> > +{
> > + return spectre_v2_enabled == SPECTRE_V2_IBRS_ALL;
> > +}
> > +
> > extern char __indirect_thunk_start[];
> > extern char __indirect_thunk_end[];
> >
> > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> > index debcdda..047538a 100644
> > --- a/arch/x86/kernel/cpu/bugs.c
> > +++ b/arch/x86/kernel/cpu/bugs.c
> > @@ -88,12 +88,13 @@ static const char *spectre_v2_strings[] = {
> > [SPECTRE_V2_RETPOLINE_MINIMAL_AMD] = "Vulnerable: Minimal AMD ASM retpoline",
> > [SPECTRE_V2_RETPOLINE_GENERIC] = "Mitigation: Full generic retpoline",
> > [SPECTRE_V2_RETPOLINE_AMD] = "Mitigation: Full AMD retpoline",
> > + [SPECTRE_V2_IBRS_ALL] = "Mitigation: Enhanced IBRS",
> > };
Hmm. Probably not just your problem but these should really get
documentation somewhere -- and adding another one should be treated
like changing the ABI.
How is poor userland expected to do anything inteligent with that
file?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
prev parent reply other threads:[~2018-02-15 15:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-12 15:27 [PATCH 1/2] x86/speculation: Correct Speculation Control microcode blacklist again David Woodhouse
2018-02-12 15:27 ` [PATCH 2/2] x86/speculation: Support "Enhanced IBRS" on future CPUs David Woodhouse
2018-02-13 7:47 ` Ingo Molnar
2018-02-13 8:12 ` David Woodhouse
2018-02-13 8:02 ` Paolo Bonzini
2018-02-13 8:15 ` David Woodhouse
2018-02-13 9:58 ` Paolo Bonzini
2018-02-13 10:21 ` David Woodhouse
2018-02-13 10:36 ` David Woodhouse
2018-02-13 10:41 ` Paolo Bonzini
2018-02-13 10:53 ` David Woodhouse
2018-02-13 10:55 ` Paolo Bonzini
2018-02-16 9:58 ` David Woodhouse
2018-02-16 10:08 ` Paolo Bonzini
2018-02-16 10:21 ` David Woodhouse
2018-02-16 11:04 ` Paolo Bonzini
2018-02-16 12:10 ` David Woodhouse
2018-02-15 15:21 ` Pavel Machek [this message]
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=20180215152139.GA23145@amd \
--to=pavel@ucw.cz \
--cc=arjan.van.de.ven@intel.com \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).