From: Borislav Petkov <bp@alien8.de>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "KP Singh" <kpsingh@kernel.org>,
"Dave Hansen" <dave.hansen@intel.com>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
linux-kernel@vger.kernel.org, pjt@google.com, evn@google.com,
tglx@linutronix.de, mingo@redhat.com,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
peterz@infradead.org, pawan.kumar.gupta@linux.intel.com,
kim.phillips@amd.com, alexandre.chartre@oracle.com,
daniel.sneddon@linux.intel.com,
"José Oliveira" <joseloliveira11@gmail.com>,
"Rodrigo Branco" <rodrigo@kernelhacking.com>,
"Alexandra Sandulescu" <aesa@google.com>,
"Jim Mattson" <jmattson@google.com>
Subject: Re: [PATCH RESEND] x86/speculation: Fix user-mode spectre-v2 protection with KERNEL_IBRS
Date: Mon, 20 Feb 2023 22:10:28 +0100 [thread overview]
Message-ID: <Y/PhxDIVsa4WU5gu@zn.tnic> (raw)
In-Reply-To: <3a65d18f-b218-60e7-4748-f1609eb76fd5@citrix.com>
On Mon, Feb 20, 2023 at 07:57:25PM +0000, Andrew Cooper wrote:
> "When IBRS or enhanced IBRS is enabled, STIBP is not needed."
>
> This is misleading, if not strictly wrong. The IBRS bit being set
> implies STIBP, which reads differently to "not needed".
>
>
> Now - eIBRS is "set once at start of day" which ends up becoming a
> global implicit STIBP.
Right.
> I think we're discussing the legacy IBRS case here. i.e. what was
> retrofitted in microcode for existing parts?
Any IBRS actually. The one which is *not* the automatic, fire'n'forget
thing.
> The reason why it is "write 1 on each privilege increase, 0 on privilege
> decrease" is because on some CPUs its an inhibit control, and on some
> CPUs is a flush (i.e. its actually IBPB).
>
> But these same CPUs don't actually have an ability to thread-tag the
> indirect predictor nicely so STIBP is also horribly expensive under the
> hood - so much so that we were firmly recommended to clear STIBP/IBRS
> when going idle so as to reduce the impact on the sibling.
Yap, we do that. And we do the write to 0 for IBRS on exit to
luserspace, probably for very similar reasons.
> IMO the proper way to do this is to set STIBP uniformly depending on
> whether you want it in userspace or not, and treat it logically
> separately to IBRS. It doesn't hurt (any more) to have both bits set.
So we have this thing:
/*
* If no STIBP, IBRS or enhanced IBRS is enabled, or SMT impossible,
* STIBP is not required.
*/
if (!boot_cpu_has(X86_FEATURE_STIBP) ||
!smt_possible ||
spectre_v2_in_ibrs_mode(spectre_v2_enabled))
return;
What you propose sounds cleaner but would definitely need more massaging
of this madness code. So I guess we could do only the
enable-STIBP-when-IBRS-enabled thing first and do more cleanups later.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2023-02-20 21:10 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 12:01 [PATCH RESEND] x86/speculation: Fix user-mode spectre-v2 protection with KERNEL_IBRS KP Singh
2023-02-20 12:13 ` Josh Poimboeuf
2023-02-20 12:20 ` KP Singh
2023-02-20 12:34 ` KP Singh
2023-02-20 14:31 ` Borislav Petkov
2023-02-20 15:38 ` Dave Hansen
2023-02-20 19:57 ` Andrew Cooper
2023-02-20 21:10 ` Borislav Petkov [this message]
2023-02-20 23:01 ` KP Singh
2023-02-20 23:30 ` Andrew Cooper
2023-02-20 23:45 ` KP Singh
2023-02-21 18:52 ` KP Singh
2023-02-21 10:59 ` Borislav Petkov
2023-02-20 16:34 ` Josh Poimboeuf
2023-02-20 17:46 ` Borislav Petkov
2023-02-20 17:59 ` Josh Poimboeuf
2023-02-20 18:01 ` KP Singh
2023-02-20 18:22 ` Borislav Petkov
2023-02-20 18:44 ` KP Singh
2023-02-20 18:51 ` Borislav Petkov
2023-02-20 18:56 ` KP Singh
2023-02-20 19:02 ` Borislav Petkov
2023-02-20 19:10 ` KP Singh
2023-02-20 18:27 ` [PATCH] x86/bugs: Allow STIBP with IBRS Josh Poimboeuf
2023-02-20 18:33 ` KP Singh
2023-02-20 18:59 ` Josh Poimboeuf
2023-02-20 19:04 ` KP Singh
2023-02-20 19:19 ` Josh Poimboeuf
2023-02-20 18:34 ` Borislav Petkov
2023-02-20 19:09 ` Josh Poimboeuf
2023-02-20 19:16 ` KP Singh
2023-02-20 19:35 ` Josh Poimboeuf
2023-02-20 19:38 ` KP Singh
2023-02-20 19:20 ` Borislav Petkov
2023-02-22 1:20 ` Pawan Gupta
2023-02-22 1:26 ` KP Singh
2023-02-22 1:38 ` Pawan Gupta
2023-02-27 19:59 ` [tip: x86/urgent] x86/speculation: Allow enabling STIBP with legacy IBRS tip-bot2 for KP Singh
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=Y/PhxDIVsa4WU5gu@zn.tnic \
--to=bp@alien8.de \
--cc=aesa@google.com \
--cc=alexandre.chartre@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=daniel.sneddon@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=evn@google.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joseloliveira11@gmail.com \
--cc=jpoimboe@kernel.org \
--cc=kim.phillips@amd.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=rodrigo@kernelhacking.com \
--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