public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Lendacky, Thomas" <Thomas.Lendacky@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: "x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Jiri Kosina <jkosina@suse.cz>, Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	David Woodhouse <dwmw@amazon.co.uk>
Subject: Re: [PATCH] x86/speculation: Add support for STIBP always-on preferred mode
Date: Tue, 11 Dec 2018 22:45:41 +0000	[thread overview]
Message-ID: <eebb189a-1e39-92a3-d2be-7ee67ac1845c@amd.com> (raw)
In-Reply-To: <20181211222259.GU27375@zn.tnic>

On 12/11/2018 04:22 PM, Borislav Petkov wrote:
> On Tue, Dec 11, 2018 at 10:17:30PM +0000, Lendacky, Thomas wrote:
>> If using just SPECTRE_V2_USER_STRICT then the code in stibp_state() would
>> have to be able differentiate between the case where the mode was switched
>> because of X86_FEATURE_AMD_STIBP_ALWAYS_ON vs a kernel command line with
>> "spectre_v2_user=on". I could always set and use a static variable in the
>> file just for the stibp_state() case.
> 
> Does it matter on X86_FEATURE_AMD_STIBP_ALWAYS_ON CPUs?
> 
> I mean, we want STIBP to be always on there so you can do:
> 
> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 25e914f77bb8..d14860d1cf9c 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -1089,7 +1089,10 @@ static char *stibp_state(void)
>  	case SPECTRE_V2_USER_NONE:
>  		return ", STIBP: disabled";
>  	case SPECTRE_V2_USER_STRICT:
> -		return ", STIBP: forced";
> +		if (boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
> +			return ", STIBP: always on";
> +		else
> +			return ", STIBP: forced";
>  	case SPECTRE_V2_USER_PRCTL:
>  	case SPECTRE_V2_USER_SECCOMP:
>  		if (static_key_enabled(&switch_to_cond_stibp))
> 
> so if user has booted with spectre_v2_user=on, we say, "oh well, it is always
> enabled anyway"... or?

I'm ok with that. Having said that, we can probably just leave it as is
and return "forced" even for the ALWAYS_ON case, then.

But if we want to differentiate, though, a simple static bool that is set
when the mode is switched works just as well.

> 
>> I'll give it a bit of time and see if there's any other discussion and
>> re-submit without the new SPECTRE_V2_USER_STRICT_PREFERRED value.
> 
> Sure.

Eh, I'll just submit v2 with the changes now and we can decide between the
above or the bool.

Thanks,
Tom

> 

      reply	other threads:[~2018-12-11 22:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 19:10 [PATCH] x86/speculation: Add support for STIBP always-on preferred mode Lendacky, Thomas
2018-12-11 19:19 ` Lendacky, Thomas
2018-12-11 21:19   ` Borislav Petkov
2018-12-11 22:17     ` Lendacky, Thomas
2018-12-11 22:22       ` Borislav Petkov
2018-12-11 22:45         ` Lendacky, Thomas [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=eebb189a-1e39-92a3-d2be-7ee67ac1845c@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=aarcange@redhat.com \
    --cc=bp@alien8.de \
    --cc=dwmw@amazon.co.uk \
    --cc=jkosina@suse.cz \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --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