From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Paul Mackerras <paulus@samba.org>,
"H . Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>,
Andrea Arcangeli <aarcange@redhat.com>,
linux-s390@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>,
x86@kernel.org, Will Deacon <will.deacon@arm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Waiman Long <longman@redhat.com>,
linux-arch@vger.kernel.org, Jon Masters <jcm@redhat.com>,
Jiri Kosina <jikos@kernel.org>, Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-arm-kernel@lists.infradead.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, Tyler Hicks <tyhicks@canonical.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH RFC 2/5] x86/speculation: Add support for 'cpu_spec_mitigations=' cmdline options
Date: Fri, 5 Apr 2019 09:31:01 -0500 [thread overview]
Message-ID: <20190405143101.ksj7ayjis4p52dgt@treble> (raw)
In-Reply-To: <20190405135712.GF23348@zn.tnic>
On Fri, Apr 05, 2019 at 03:57:12PM +0200, Borislav Petkov wrote:
> > diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> > index 2bb3a648fc12..7e95b310f869 100644
> > --- a/arch/x86/include/asm/processor.h
> > +++ b/arch/x86/include/asm/processor.h
> > @@ -982,6 +982,7 @@ void microcode_check(void);
> >
> > enum l1tf_mitigations {
> > L1TF_MITIGATION_OFF,
> > + L1TF_MITIGATION_DEFAULT,
> > L1TF_MITIGATION_FLUSH_NOWARN,
> > L1TF_MITIGATION_FLUSH,
> > L1TF_MITIGATION_FLUSH_NOSMT,
> > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> > index 2da82eff0eb4..65b95fb95ba5 100644
> > --- a/arch/x86/kernel/cpu/bugs.c
> > +++ b/arch/x86/kernel/cpu/bugs.c
> > @@ -308,8 +308,11 @@ spectre_v2_parse_user_cmdline(enum spectre_v2_mitigation_cmd v2_cmd)
> >
> > ret = cmdline_find_option(boot_command_line, "spectre_v2_user",
> > arg, sizeof(arg));
> > - if (ret < 0)
> > + if (ret < 0) {
> > + if (cpu_spec_mitigations == CPU_SPEC_MITIGATIONS_OFF)
> > + return SPECTRE_V2_USER_CMD_NONE;
>
> Instead of sprinkling that test in those three functions, just do it
> once above in check_bugs(), before those *_select_mitigation() functions
> get to run and depending on the value, you either run them or use the
> default settings, for the OFF case, for example.
My thinking was that the individual options could be used to override
the global option. But maybe that's overkill? I dunno.
> > return SPECTRE_V2_USER_CMD_AUTO;
> > + }
> >
> > for (i = 0; i < ARRAY_SIZE(v2_user_options); i++) {
> > if (match_option(arg, ret, v2_user_options[i].option)) {
> > @@ -444,8 +447,11 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
> > return SPECTRE_V2_CMD_NONE;
> >
> > ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
> > - if (ret < 0)
> > + if (ret < 0) {
> > + if (cpu_spec_mitigations == CPU_SPEC_MITIGATIONS_OFF)
> > + return SPECTRE_V2_CMD_NONE;
> > return SPECTRE_V2_CMD_AUTO;
> > + }
> >
> > for (i = 0; i < ARRAY_SIZE(mitigation_options); i++) {
> > if (!match_option(arg, ret, mitigation_options[i].option))
> > @@ -677,8 +683,11 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void)
> > } else {
> > ret = cmdline_find_option(boot_command_line, "spec_store_bypass_disable",
> > arg, sizeof(arg));
> > - if (ret < 0)
> > + if (ret < 0) {
> > + if (cpu_spec_mitigations == CPU_SPEC_MITIGATIONS_OFF)
> > + return SPEC_STORE_BYPASS_CMD_NONE;
> > return SPEC_STORE_BYPASS_CMD_AUTO;
> > + }
> >
> > for (i = 0; i < ARRAY_SIZE(ssb_mitigation_options); i++) {
> > if (!match_option(arg, ret, ssb_mitigation_options[i].option))
> > @@ -955,7 +964,7 @@ void x86_spec_ctrl_setup_ap(void)
> > #define pr_fmt(fmt) "L1TF: " fmt
> >
> > /* Default mitigation for L1TF-affected CPUs */
> > -enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH;
> > +enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_DEFAULT;
> > #if IS_ENABLED(CONFIG_KVM_INTEL)
> > EXPORT_SYMBOL_GPL(l1tf_mitigation);
> > #endif
> > @@ -1010,8 +1019,23 @@ static void __init l1tf_select_mitigation(void)
> >
> > override_cache_bits(&boot_cpu_data);
> >
> > + if (l1tf_mitigation == L1TF_MITIGATION_DEFAULT) {
> > + switch (cpu_spec_mitigations) {
> > + case CPU_SPEC_MITIGATIONS_OFF:
> > + l1tf_mitigation = L1TF_MITIGATION_OFF;
> > + break;
> > + case CPU_SPEC_MITIGATIONS_AUTO:
> > + l1tf_mitigation = L1TF_MITIGATION_FLUSH;
> > + break;
> > + case CPU_SPEC_MITIGATIONS_AUTO_NOSMT:
> > + l1tf_mitigation = L1TF_MITIGATION_FLUSH_NOSMT;
> > + break;
> > + }
> > + }
> > +
> > switch (l1tf_mitigation) {
> > case L1TF_MITIGATION_OFF:
> > + case L1TF_MITIGATION_DEFAULT:
> > case L1TF_MITIGATION_FLUSH_NOWARN:
> > case L1TF_MITIGATION_FLUSH:
> > break;
> > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> > index ab432a930ae8..83b5bdc3c777 100644
> > --- a/arch/x86/kvm/vmx/vmx.c
> > +++ b/arch/x86/kvm/vmx/vmx.c
> > @@ -233,6 +233,7 @@ static int vmx_setup_l1d_flush(enum vmx_l1d_flush_state l1tf)
> > case L1TF_MITIGATION_FLUSH_NOWARN:
> > case L1TF_MITIGATION_FLUSH:
> > case L1TF_MITIGATION_FLUSH_NOSMT:
> > + case L1TF_MITIGATION_DEFAULT:
> > l1tf = VMENTER_L1D_FLUSH_COND;
> > break;
> > case L1TF_MITIGATION_FULL:
> > @@ -6686,6 +6687,7 @@ static int vmx_vm_init(struct kvm *kvm)
> > case L1TF_MITIGATION_FLUSH:
> > case L1TF_MITIGATION_FLUSH_NOSMT:
> > case L1TF_MITIGATION_FULL:
> > + case L1TF_MITIGATION_DEFAULT:
> > /*
> > * Warn upon starting the first VM in a potentially
> > * insecure environment.
>
> The L1TF bits need to be a separate patch.
I assume you mean just the part where L1TF_MITIGATION_DEFAULT is added?
--
Josh
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-04-05 14:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 16:44 [PATCH RFC 0/5] cpu/speculation: Add 'cpu_spec_mitigations=' cmdline options Josh Poimboeuf
2019-04-04 16:44 ` [PATCH RFC 1/5] " Josh Poimboeuf
2019-04-04 16:49 ` Josh Poimboeuf
2019-04-05 13:12 ` Borislav Petkov
2019-04-05 14:20 ` Josh Poimboeuf
2019-04-05 15:20 ` Borislav Petkov
2019-04-05 16:01 ` Borislav Petkov
2019-04-05 16:18 ` Josh Poimboeuf
2019-04-10 5:48 ` Michael Ellerman
2019-04-10 8:30 ` Borislav Petkov
2019-04-10 12:10 ` Thomas Gleixner
2019-04-11 13:15 ` Josh Poimboeuf
2019-04-12 2:41 ` Michael Ellerman
2019-04-12 2:29 ` Michael Ellerman
2019-04-04 16:44 ` [PATCH RFC 2/5] x86/speculation: Add support for " Josh Poimboeuf
2019-04-05 13:57 ` Borislav Petkov
2019-04-05 14:31 ` Josh Poimboeuf [this message]
2019-04-05 15:26 ` Borislav Petkov
2019-04-05 16:05 ` Josh Poimboeuf
2019-04-05 15:18 ` Randy Dunlap
2019-04-05 15:30 ` Josh Poimboeuf
2019-04-04 16:44 ` [PATCH RFC 3/5] powerpc/speculation: " Josh Poimboeuf
2019-04-04 19:49 ` Jiri Kosina
2019-04-04 20:01 ` Timothy Pearson
2019-04-10 6:06 ` Michael Ellerman
2019-04-11 4:02 ` Josh Poimboeuf
2019-04-04 16:44 ` [PATCH RFC 4/5] s390/speculation: " Josh Poimboeuf
2019-04-04 16:44 ` [PATCH RFC 5/5] arm64/speculation: " Josh Poimboeuf
2019-04-05 14:39 ` Steven Price
2019-04-05 14:43 ` Josh Poimboeuf
2019-04-05 14:44 ` Will Deacon
2019-04-05 16:03 ` Josh Poimboeuf
2019-04-04 16:50 ` [PATCH RFC 0/5] cpu/speculation: Add " Waiman Long
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=20190405143101.ksj7ayjis4p52dgt@treble \
--to=jpoimboe@redhat.com \
--cc=aarcange@redhat.com \
--cc=benh@kernel.crashing.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=heiko.carstens@de.ibm.com \
--cc=hpa@zytor.com \
--cc=jcm@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=longman@redhat.com \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=tyhicks@canonical.com \
--cc=will.deacon@arm.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