The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Daniel Sneddon <daniel.sneddon@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Alexandre Chartre <alexandre.chartre@oracle.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sean Christopherson <seanjc@google.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Nikolay Borisov <nik.borisov@suse.com>,
	KP Singh <kpsingh@kernel.org>, Waiman Long <longman@redhat.com>,
	Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v3] x86/bugs: Only harden syscalls when needed
Date: Thu, 18 Apr 2024 17:48:45 -0700	[thread overview]
Message-ID: <20240419004845.ker26cp3hslttslk@treble> (raw)
In-Reply-To: <2a490bb4-fd00-46e7-b7c3-bb8ef962d8b9@citrix.com>

On Wed, Apr 17, 2024 at 07:01:54PM +0100, Andrew Cooper wrote:
> On 17/04/2024 6:57 pm, Josh Poimboeuf wrote:
> > On Wed, Apr 17, 2024 at 09:45:14AM -0700, Pawan Gupta wrote:
> >> On Wed, Apr 17, 2024 at 04:14:26PM +0100, Andrew Cooper wrote:
> >>> On 17/04/2024 12:02 am, Josh Poimboeuf wrote:
> >>>> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> >>>> index ca295b0c1eee..dcb97cc2758f 100644
> >>>> --- a/arch/x86/kernel/cpu/bugs.c
> >>>> +++ b/arch/x86/kernel/cpu/bugs.c
> >>>> @@ -1678,6 +1687,21 @@ static void __init spectre_v2_select_mitigation(void)
> >>>>  	enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline();
> >>>>  	enum spectre_v2_mitigation mode = SPECTRE_V2_NONE;
> >>>>  
> >>>> +	/*
> >>>> +	 * X86_FEATURE_INDIRECT_SAFE indicates whether indirect calls can be
> >>>> +	 * considered safe.  That means either:
> >>>> +	 *
> >>>> +	 *   - the CPU isn't vulnerable to Spectre v2 or its variants;
> >>>> +	 *
> >>>> +	 *   - a hardware mitigation is in place (e.g., IBRS, BHI_DIS_S); or
> >>>> +	 *
> >>>> +	 *   - the user turned off mitigations altogether.
> >>>> +	 *
> >>>> +	 * Assume innocence until proven guilty: set the cap bit now, then
> >>>> +	 * clear it later if/when needed.
> >>>> +	 */
> >>>> +	setup_force_cpu_cap(X86_FEATURE_INDIRECT_SAFE);
> >>> Following on from the (re)discovery that X86_FEATURE_RETPOLINE is a poor
> >>> name given what it *actually* does, can I recommend s/SAFE/OK/ here?
> >> Or simply X86_FEATURE_USE_INDIRECT_BRANCH.
> >>
> >>> This flag really is "do I want indirect branches or not", which - as
> >>> noted here - is more than just a judgement of whether indirect branches
> >>> are "safe".
> > X86_FEATURE_USE_INDIRECT_BRANCH sounds good.  It's a bit long but does
> > describe it better.
> 
> Works for me.  Definitely an improvement over SAFE.

USE_INDIRECT_BRANCH is now irking me: "use indirect branch for what?
when? why?"

At the moment I'm leaning towards Andrew's suggestion of
X86_FEATURE_INDIRECT_OK as it at least says it's "ok" (safe or don't
care) to use indirect branches when desired (typically performance
raisins).  I'll probably go with that (or maybe
X86_FEATURE_INDIRECT_BRANCH_OK) unless anybody yells.

-- 
Josh

  reply	other threads:[~2024-04-19  0:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 23:02 [PATCH v3] x86/bugs: Only harden syscalls when needed Josh Poimboeuf
2024-04-17 14:57 ` Borislav Petkov
2024-04-17 15:14 ` Andrew Cooper
2024-04-17 16:45   ` Pawan Gupta
2024-04-17 17:57     ` Josh Poimboeuf
2024-04-17 18:01       ` Andrew Cooper
2024-04-19  0:48         ` Josh Poimboeuf [this message]
2024-04-19  1:14           ` Pawan Gupta
2024-04-18  6:50 ` Christoph Hellwig
2024-04-19  0:31   ` Josh Poimboeuf

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=20240419004845.ker26cp3hslttslk@treble \
    --to=jpoimboe@kernel.org \
    --cc=alexandre.chartre@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=daniel.sneddon@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.wilk@oracle.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=nik.borisov@suse.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=seanjc@google.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