From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
"David Woodhouse" <dwmw2@infradead.org>,
"Dave Hansen" <dave.hansen@intel.com>,
"Liran Alon" <liran.alon@oracle.com>,
"Laura Abbott" <labbott@redhat.com>,
"Andrew Lutomirski" <luto@kernel.org>,
"Janakarajan Natarajan" <Janakarajan.Natarajan@amd.com>,
"Borislav Petkov" <bp@suse.de>,
"Mallick, Asit K" <asit.k.mallick@intel.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"KarimAllah Ahmed" <karahmed@amazon.de>,
"Peter Anvin" <hpa@zytor.com>,
"Jun Nakajima" <jun.nakajima@intel.com>,
"Ingo Molnar" <mingo@redhat.com>,
"the arch/x86 maintainers" <x86@kernel.org>,
"Ashok Raj" <ashok.raj@intel.com>,
"Van De Ven, Arjan" <arjan.van.de.ven@intel.com>,
"Tim Chen" <tim.c.chen@linux.intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Arjan van de Ven" <arjan@linux.intel.com>,
"Tom Lendacky" <thomas.lendacky@amd.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Andrea Arcangeli" <aarcange@redhat.com>,
"KVM list" <kvm@vger.kernel.org>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>
Subject: Re: [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation
Date: Fri, 26 Jan 2018 14:02:57 -0500 [thread overview]
Message-ID: <20180126190257.GS14668@char.us.oracle.com> (raw)
In-Reply-To: <20180126175901.GL26209@tassilo.jf.intel.com>
On Fri, Jan 26, 2018 at 09:59:01AM -0800, Andi Kleen wrote:
> On Fri, Jan 26, 2018 at 09:19:09AM -0800, Linus Torvalds wrote:
> > On Fri, Jan 26, 2018 at 1:11 AM, David Woodhouse <dwmw2@infradead.org> wrote:
> > >
> > > Do we need to look again at the fact that we've disabled the RSB-
> > > stuffing for SMEP?
> >
> > Absolutely. SMEP helps make people a lot less worried about things,
> > but it doesn't fix the "BTB only contains partial addresses" case.
> >
> > But did we do that "disable stuffing with SMEP"? I'm not seeing it. In
> > my tree, it's only conditional on X86_FEATURE_RETPOLINE.
>
> For Skylake we need RSB stuffing even with SMEP to avoid falling back to the
> BTB on underflow.
>
> It's also always needed with virtualization.
-ECONFUSED, see ==>
Is this incorrect then?
I see:
241 * Skylake era CPUs have a separate issue with *underflow* of the
242 * RSB, when they will predict 'ret' targets from the generic BTB.
243 * The proper mitigation for this is IBRS. If IBRS is not supported
244 * or deactivated in favour of retpolines the RSB fill on context
245 * switch is required.
246 */
which came from this:
commit c995efd5a740d9cbafbf58bde4973e8b50b4d761
Author: David Woodhouse <dwmw@amazon.co.uk>
Date: Fri Jan 12 17:49:25 2018 +0000
x86/retpoline: Fill RSB on context switch for affected CPUs
On context switch from a shallow call stack to a deeper one, as the CPU
does 'ret' up the deeper side it may encounter RSB entries (predictions for
where the 'ret' goes to) which were populated in userspace.
This is problematic if neither SMEP nor KPTI (the latter of which marks
userspace pages as NX for the kernel) are active, as malicious code in
userspace may then be executed speculatively.
Overwrite the CPU's return prediction stack with calls which are predicted
to return to an infinite loop, to "capture" speculation if this
happens. This is required both for retpoline, and also in conjunction with
IBRS for !SMEP && !KPTI.
On Skylake+ the problem is slightly different, and an *underflow* of the
RSB may cause errant branch predictions to occur. So there it's not so much
overwrite, as *filling* the RSB to attempt to prevent it getting
empty. This is only a partial solution for Skylake+ since there are many
==>other conditions which may result in the RSB becoming empty. The full <==
==>solution on Skylake+ is to use IBRS, which will prevent the problem even <==
when the RSB becomes empty. With IBRS, the RSB-stuffing will not be
required on context switch.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
The "full solution" is what is making me confused.
>
> -Andi
next prev parent reply other threads:[~2018-01-26 19:02 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-26 2:11 [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation Liran Alon
2018-01-26 2:23 ` Dave Hansen
2018-01-26 9:11 ` David Woodhouse
2018-01-26 17:19 ` Linus Torvalds
2018-01-26 17:27 ` Borislav Petkov
2018-01-26 17:29 ` David Woodhouse
2018-01-26 17:31 ` David Woodhouse
2018-01-26 17:59 ` Andi Kleen
2018-01-26 18:11 ` David Woodhouse
2018-01-26 18:12 ` Arjan van de Ven
2018-01-26 18:26 ` David Woodhouse
2018-01-26 18:28 ` Van De Ven, Arjan
2018-01-26 18:43 ` David Woodhouse
2018-01-26 18:44 ` Van De Ven, Arjan
2018-01-26 18:53 ` David Woodhouse
2018-01-26 19:02 ` Konrad Rzeszutek Wilk [this message]
2018-01-26 19:11 ` Hansen, Dave
2018-01-27 13:42 ` Konrad Rzeszutek Wilk
2018-01-27 15:55 ` Dave Hansen
2018-01-26 19:11 ` David Woodhouse
2018-01-26 8:46 ` David Woodhouse
-- strict thread matches above, loose matches on Subject: below --
2018-01-26 2:50 Liran Alon
2018-01-26 2:55 ` Van De Ven, Arjan
2018-01-23 11:13 Liran Alon
2018-01-25 22:20 ` Dave Hansen
2018-01-22 22:15 Luke Kenneth Casson Leighton
2018-01-20 19:22 [RFC 00/10] Speculation Control feature support KarimAllah Ahmed
2018-01-20 19:23 ` [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation KarimAllah Ahmed
2018-01-21 19:14 ` Andy Lutomirski
2018-01-23 16:12 ` Tom Lendacky
2018-01-23 16:20 ` Woodhouse, David
2018-01-23 22:37 ` Tom Lendacky
2018-01-23 22:49 ` Andi Kleen
2018-01-23 23:14 ` Woodhouse, David
2018-01-23 23:22 ` Andi Kleen
2018-01-24 0:47 ` Tim Chen
2018-01-24 1:00 ` Andy Lutomirski
2018-01-24 1:22 ` David Woodhouse
2018-01-24 1:59 ` Van De Ven, Arjan
2018-01-24 3:25 ` Andy Lutomirski
2018-01-21 19:34 ` Linus Torvalds
2018-01-21 20:28 ` David Woodhouse
2018-01-21 21:35 ` Linus Torvalds
2018-01-21 22:00 ` David Woodhouse
2018-01-21 22:27 ` Linus Torvalds
2018-01-22 16:27 ` David Woodhouse
2018-01-23 7:29 ` Ingo Molnar
2018-01-23 7:53 ` Ingo Molnar
2018-01-23 9:27 ` Ingo Molnar
2018-01-23 9:37 ` David Woodhouse
2018-01-23 15:01 ` Dave Hansen
2018-01-23 9:30 ` David Woodhouse
2018-01-23 10:15 ` Ingo Molnar
2018-01-23 10:27 ` David Woodhouse
2018-01-23 10:44 ` Ingo Molnar
2018-01-23 10:57 ` David Woodhouse
2018-01-23 10:23 ` Ingo Molnar
2018-01-23 10:35 ` David Woodhouse
2018-02-04 18:43 ` Thomas Gleixner
2018-02-04 20:22 ` David Woodhouse
2018-02-06 9:14 ` David Woodhouse
2018-01-25 16:19 ` Mason
2018-01-25 17:16 ` Greg Kroah-Hartman
2018-01-29 11:59 ` Mason
2018-01-24 0:05 ` Andi Kleen
2018-01-23 20:16 ` Pavel Machek
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=20180126190257.GS14668@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=Janakarajan.Natarajan@amd.com \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=arjan.van.de.ven@intel.com \
--cc=arjan@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=asit.k.mallick@intel.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@suse.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=joro@8bytes.org \
--cc=jun.nakajima@intel.com \
--cc=karahmed@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liran.alon@oracle.com \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).