2024-04-09 17:51:29

by Sean Christopherson

[permalink] [raw]
Subject: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Initialize cpu_mitigations to CPU_MITIGATIONS_OFF if the kernel is built
with CONFIG_SPECULATION_MITIGATIONS=n, as the help text quite clearly
states that disabling SPECULATION_MITIGATIONS is supposed to turn off all
mitigations by default.

│ If you say N, all mitigations will be disabled. You really
│ should know what you are doing to say so.

As is, the kernel still defaults to CPU_MITIGATIONS_AUTO, which results in
some mitigations being enabled in spite of SPECULATION_MITIGATIONS=n.

Fixes: f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs")
Cc: [email protected]
Signed-off-by: Sean Christopherson <[email protected]>
---
kernel/cpu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 8f6affd051f7..07ad53b7f119 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3207,7 +3207,8 @@ enum cpu_mitigations {
};

static enum cpu_mitigations cpu_mitigations __ro_after_init =
- CPU_MITIGATIONS_AUTO;
+ IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
+ CPU_MITIGATIONS_OFF;

static int __init mitigations_parse_cmdline(char *arg)
{
--
2.44.0.478.gd926399ef9-goog



Subject: [tip: x86/urgent] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID: f337a6a21e2fd67eadea471e93d05dd37baaa9be
Gitweb: https://git.kernel.org/tip/f337a6a21e2fd67eadea471e93d05dd37baaa9be
Author: Sean Christopherson <[email protected]>
AuthorDate: Tue, 09 Apr 2024 10:51:05 -07:00
Committer: Ingo Molnar <[email protected]>
CommitterDate: Wed, 10 Apr 2024 16:22:47 +02:00

x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Initialize cpu_mitigations to CPU_MITIGATIONS_OFF if the kernel is built
with CONFIG_SPECULATION_MITIGATIONS=n, as the help text quite clearly
states that disabling SPECULATION_MITIGATIONS is supposed to turn off all
mitigations by default.

│ If you say N, all mitigations will be disabled. You really
│ should know what you are doing to say so.

As is, the kernel still defaults to CPU_MITIGATIONS_AUTO, which results in
some mitigations being enabled in spite of SPECULATION_MITIGATIONS=n.

Fixes: f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs")
Signed-off-by: Sean Christopherson <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Reviewed-by: Daniel Sneddon <[email protected]>
Cc: [email protected]
Cc: Linus Torvalds <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
kernel/cpu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 8f6affd..07ad53b 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3207,7 +3207,8 @@ enum cpu_mitigations {
};

static enum cpu_mitigations cpu_mitigations __ro_after_init =
- CPU_MITIGATIONS_AUTO;
+ IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
+ CPU_MITIGATIONS_OFF;

static int __init mitigations_parse_cmdline(char *arg)
{

2024-04-13 01:54:10

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Hi Sean,

I noticed this commit in linux-next.

On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
>
> Initialize cpu_mitigations to CPU_MITIGATIONS_OFF if the kernel is built
> with CONFIG_SPECULATION_MITIGATIONS=n, as the help text quite clearly
> states that disabling SPECULATION_MITIGATIONS is supposed to turn off all
> mitigations by default.
>
> │ If you say N, all mitigations will be disabled. You really
> │ should know what you are doing to say so.
>
> As is, the kernel still defaults to CPU_MITIGATIONS_AUTO, which results in
> some mitigations being enabled in spite of SPECULATION_MITIGATIONS=n.
>
> Fixes: f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs")
> Cc: [email protected]
> Signed-off-by: Sean Christopherson <[email protected]>
> ---
> kernel/cpu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 8f6affd051f7..07ad53b7f119 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
> };
>
> static enum cpu_mitigations cpu_mitigations __ro_after_init =
> - CPU_MITIGATIONS_AUTO;
> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
> + CPU_MITIGATIONS_OFF;
>
> static int __init mitigations_parse_cmdline(char *arg)
> {
> --
> 2.44.0.478.gd926399ef9-goog
>

I noticed because it turned off all mitigations for my PowerPC qemu
boot tests - probably because CONFIG_SPECULATION_MITIGATIONS only
exists in arch/x86/Kconfig ... thus for other architectures that have
cpu mitigations, this will always default them to off, right?

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2024-04-13 09:28:10

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Stephen Rothwell <[email protected]> writes:
> Hi Sean,
>
> I noticed this commit in linux-next.
>
> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
>>
>> Initialize cpu_mitigations to CPU_MITIGATIONS_OFF if the kernel is built
>> with CONFIG_SPECULATION_MITIGATIONS=n, as the help text quite clearly
>> states that disabling SPECULATION_MITIGATIONS is supposed to turn off all
>> mitigations by default.
>>
>> │ If you say N, all mitigations will be disabled. You really
>> │ should know what you are doing to say so.
>>
>> As is, the kernel still defaults to CPU_MITIGATIONS_AUTO, which results in
>> some mitigations being enabled in spite of SPECULATION_MITIGATIONS=n.
>>
>> Fixes: f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs")
>> Cc: [email protected]
>> Signed-off-by: Sean Christopherson <[email protected]>
>> ---
>> kernel/cpu.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/cpu.c b/kernel/cpu.c
>> index 8f6affd051f7..07ad53b7f119 100644
>> --- a/kernel/cpu.c
>> +++ b/kernel/cpu.c
>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
>> };
>>
>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
>> - CPU_MITIGATIONS_AUTO;
>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
>> + CPU_MITIGATIONS_OFF;
>>
>> static int __init mitigations_parse_cmdline(char *arg)
>> {
>> --
>> 2.44.0.478.gd926399ef9-goog
>>
>
> I noticed because it turned off all mitigations for my PowerPC qemu
> boot tests - probably because CONFIG_SPECULATION_MITIGATIONS only
> exists in arch/x86/Kconfig ... thus for other architectures that have
> cpu mitigations, this will always default them to off, right?

Yep.

The patch has the effect of changing the default for non-x86 arches from
auto to off.

I see at least powerpc, arm64 and s390 use cpu_mitigations_off() and
will be affected.

cheers

2024-04-13 09:39:01

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Michael Ellerman <[email protected]> writes:
> Stephen Rothwell <[email protected]> writes:
..
>> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
..
>>> diff --git a/kernel/cpu.c b/kernel/cpu.c
>>> index 8f6affd051f7..07ad53b7f119 100644
>>> --- a/kernel/cpu.c
>>> +++ b/kernel/cpu.c
>>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
>>> };
>>>
>>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
>>> - CPU_MITIGATIONS_AUTO;
>>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
>>> + CPU_MITIGATIONS_OFF;
>>>
>>> static int __init mitigations_parse_cmdline(char *arg)
>>> {

I think a minimal workaround/fix would be:

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 2b8fd6bb7da0..290be2f9e909 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -191,6 +191,10 @@ config GENERIC_CPU_AUTOPROBE
config GENERIC_CPU_VULNERABILITIES
bool

+config SPECULATION_MITIGATIONS
+ def_bool y
+ depends on !X86
+
config SOC_BUS
bool
select GLOB

cheers

2024-04-14 22:43:19

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Hi all,

On Sat, 13 Apr 2024 19:38:47 +1000 Michael Ellerman <[email protected]> wrote:
>
> Michael Ellerman <[email protected]> writes:
> > Stephen Rothwell <[email protected]> writes:
> ...
> >> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
> ...
> >>> diff --git a/kernel/cpu.c b/kernel/cpu.c
> >>> index 8f6affd051f7..07ad53b7f119 100644
> >>> --- a/kernel/cpu.c
> >>> +++ b/kernel/cpu.c
> >>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
> >>> };
> >>>
> >>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
> >>> - CPU_MITIGATIONS_AUTO;
> >>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
> >>> + CPU_MITIGATIONS_OFF;
> >>>
> >>> static int __init mitigations_parse_cmdline(char *arg)
> >>> {
>
> I think a minimal workaround/fix would be:
>
> diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> index 2b8fd6bb7da0..290be2f9e909 100644
> --- a/drivers/base/Kconfig
> +++ b/drivers/base/Kconfig
> @@ -191,6 +191,10 @@ config GENERIC_CPU_AUTOPROBE
> config GENERIC_CPU_VULNERABILITIES
> bool
>
> +config SPECULATION_MITIGATIONS
> + def_bool y
> + depends on !X86
> +
> config SOC_BUS
> bool
> select GLOB

The original commit is now in Linus' tree.

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2024-04-15 11:14:04

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Hi Sean,

On Tue, Apr 9, 2024 at 7:51 PM Sean Christopherson <[email protected]> wrote:
> Initialize cpu_mitigations to CPU_MITIGATIONS_OFF if the kernel is built
> with CONFIG_SPECULATION_MITIGATIONS=n, as the help text quite clearly
> states that disabling SPECULATION_MITIGATIONS is supposed to turn off all
> mitigations by default.
>
> │ If you say N, all mitigations will be disabled. You really
> │ should know what you are doing to say so.
>
> As is, the kernel still defaults to CPU_MITIGATIONS_AUTO, which results in
> some mitigations being enabled in spite of SPECULATION_MITIGATIONS=n.
>
> Fixes: f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs")
> Cc: [email protected]
> Signed-off-by: Sean Christopherson <[email protected]>

Thanks for your patch, which is now commit f337a6a21e2fd67e
("x86/cpu: Actually turn off mitigations by default
for SPECULATION_MITIGATIONS=n") in v6.9-rc4.

This causes the following suspicious messages on R-Car H3:

CPU features: kernel page table isolation forced OFF by mitigations=off
spectre-v4 mitigation disabled by command-line option
spectre-v2 mitigation disabled by command line option
spectre-v2 mitigation disabled by command line option

and R-Car V4H:

CPU features: kernel page table isolation forced OFF by mitigations=off
spectre-v4 mitigation disabled by command-line option
spectre-bhb mitigation disabled by command line option
spectre-bhb mitigation disabled by command line option

Interestingly, no mitigations are disabled on the command-line.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68korg

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2024-04-15 11:17:33

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Hi Michael,

On Sat, Apr 13, 2024 at 11:38 AM Michael Ellerman <[email protected]> wrote:
> Michael Ellerman <[email protected]> writes:
> > Stephen Rothwell <[email protected]> writes:
> ...
> >> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
> ...
> >>> diff --git a/kernel/cpu.c b/kernel/cpu.c
> >>> index 8f6affd051f7..07ad53b7f119 100644
> >>> --- a/kernel/cpu.c
> >>> +++ b/kernel/cpu.c
> >>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
> >>> };
> >>>
> >>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
> >>> - CPU_MITIGATIONS_AUTO;
> >>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
> >>> + CPU_MITIGATIONS_OFF;
> >>>
> >>> static int __init mitigations_parse_cmdline(char *arg)
> >>> {
>
> I think a minimal workaround/fix would be:
>
> diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> index 2b8fd6bb7da0..290be2f9e909 100644
> --- a/drivers/base/Kconfig
> +++ b/drivers/base/Kconfig
> @@ -191,6 +191,10 @@ config GENERIC_CPU_AUTOPROBE
> config GENERIC_CPU_VULNERABILITIES
> bool
>
> +config SPECULATION_MITIGATIONS
> + def_bool y
> + depends on !X86
> +
> config SOC_BUS
> bool
> select GLOB

Thanks, that works for me (on arm64), so
Tested-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68korg

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2024-04-15 14:37:18

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

On Mon, Apr 15, 2024, Geert Uytterhoeven wrote:
> Hi Michael,
>
> On Sat, Apr 13, 2024 at 11:38 AM Michael Ellerman <[email protected]> wrote:
> > Michael Ellerman <[email protected]> writes:
> > > Stephen Rothwell <[email protected]> writes:
> > ...
> > >> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
> > ...
> > >>> diff --git a/kernel/cpu.c b/kernel/cpu.c
> > >>> index 8f6affd051f7..07ad53b7f119 100644
> > >>> --- a/kernel/cpu.c
> > >>> +++ b/kernel/cpu.c
> > >>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
> > >>> };
> > >>>
> > >>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
> > >>> - CPU_MITIGATIONS_AUTO;
> > >>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
> > >>> + CPU_MITIGATIONS_OFF;
> > >>>
> > >>> static int __init mitigations_parse_cmdline(char *arg)
> > >>> {
> >
> > I think a minimal workaround/fix would be:
> >
> > diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> > index 2b8fd6bb7da0..290be2f9e909 100644
> > --- a/drivers/base/Kconfig
> > +++ b/drivers/base/Kconfig
> > @@ -191,6 +191,10 @@ config GENERIC_CPU_AUTOPROBE
> > config GENERIC_CPU_VULNERABILITIES
> > bool
> >
> > +config SPECULATION_MITIGATIONS
> > + def_bool y
> > + depends on !X86
> > +
> > config SOC_BUS
> > bool
> > select GLOB
>
> Thanks, that works for me (on arm64), so
> Tested-by: Geert Uytterhoeven <[email protected]>

Oof. I completely missed that "cpu_mitigations" wasn't x86-only. I can't think
of better solution than an on-by-default generic Kconfig, though can't that it
more simply be:

diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 2b8fd6bb7da0..5930cb56ee29 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -191,6 +191,9 @@ config GENERIC_CPU_AUTOPROBE
config GENERIC_CPU_VULNERABILITIES
bool

+config SPECULATION_MITIGATIONS
+ def_bool !X86
+
config SOC_BUS
bool
select GLOB

2024-04-16 11:06:56

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

Sean Christopherson <[email protected]> writes:
> On Mon, Apr 15, 2024, Geert Uytterhoeven wrote:
>> On Sat, Apr 13, 2024 at 11:38 AM Michael Ellerman <[email protected]> wrote:
>> > Michael Ellerman <[email protected]> writes:
>> > > Stephen Rothwell <[email protected]> writes:
>> > ...
>> > >> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
>> > ...
>> > >>> diff --git a/kernel/cpu.c b/kernel/cpu.c
>> > >>> index 8f6affd051f7..07ad53b7f119 100644
>> > >>> --- a/kernel/cpu.c
>> > >>> +++ b/kernel/cpu.c
>> > >>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
>> > >>> };
>> > >>>
>> > >>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
>> > >>> - CPU_MITIGATIONS_AUTO;
>> > >>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
>> > >>> + CPU_MITIGATIONS_OFF;
>> > >>>
>> > >>> static int __init mitigations_parse_cmdline(char *arg)
>> > >>> {
>> >
>> > I think a minimal workaround/fix would be:
>> >
>> > diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
>> > index 2b8fd6bb7da0..290be2f9e909 100644
>> > --- a/drivers/base/Kconfig
>> > +++ b/drivers/base/Kconfig
>> > @@ -191,6 +191,10 @@ config GENERIC_CPU_AUTOPROBE
>> > config GENERIC_CPU_VULNERABILITIES
>> > bool
>> >
>> > +config SPECULATION_MITIGATIONS
>> > + def_bool y
>> > + depends on !X86
>> > +
>> > config SOC_BUS
>> > bool
>> > select GLOB
>>
>> Thanks, that works for me (on arm64), so
>> Tested-by: Geert Uytterhoeven <[email protected]>
>
> Oof. I completely missed that "cpu_mitigations" wasn't x86-only. I can't think
> of better solution than an on-by-default generic Kconfig, though can't that it
> more simply be:
>
> diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> index 2b8fd6bb7da0..5930cb56ee29 100644
> --- a/drivers/base/Kconfig
> +++ b/drivers/base/Kconfig
> @@ -191,6 +191,9 @@ config GENERIC_CPU_AUTOPROBE
> config GENERIC_CPU_VULNERABILITIES
> bool
>
> +config SPECULATION_MITIGATIONS
> + def_bool !X86
> +

Yeah that works too.

cheers

2024-04-19 14:10:34

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

On Fri, Apr 19, 2024, Will Deacon wrote:
> On Mon, Apr 15, 2024 at 07:31:23AM -0700, Sean Christopherson wrote:
> > On Mon, Apr 15, 2024, Geert Uytterhoeven wrote:
> > Oof. I completely missed that "cpu_mitigations" wasn't x86-only. I can't think
> > of better solution than an on-by-default generic Kconfig, though can't that it
> > more simply be:
> >
> > diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> > index 2b8fd6bb7da0..5930cb56ee29 100644
> > --- a/drivers/base/Kconfig
> > +++ b/drivers/base/Kconfig
> > @@ -191,6 +191,9 @@ config GENERIC_CPU_AUTOPROBE
> > config GENERIC_CPU_VULNERABILITIES
> > bool
> >
> > +config SPECULATION_MITIGATIONS
> > + def_bool !X86
> > +
> > config SOC_BUS
> > bool
> > select GLOB
>
> I can't see this in -next yet. Do you plan to post it as a proper patch
> to collect acks etc?

Sorry, I neglected to Cc everyone.

https://lore.kernel.org/all/[email protected]

2024-04-19 14:16:12

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

On Mon, Apr 15, 2024 at 07:31:23AM -0700, Sean Christopherson wrote:
> On Mon, Apr 15, 2024, Geert Uytterhoeven wrote:
> > On Sat, Apr 13, 2024 at 11:38 AM Michael Ellerman <[email protected]> wrote:
> > > Michael Ellerman <[email protected]> writes:
> > > > Stephen Rothwell <[email protected]> writes:
> > > ...
> > > >> On Tue, 9 Apr 2024 10:51:05 -0700 Sean Christopherson <[email protected]> wrote:
> > > ...
> > > >>> diff --git a/kernel/cpu.c b/kernel/cpu.c
> > > >>> index 8f6affd051f7..07ad53b7f119 100644
> > > >>> --- a/kernel/cpu.c
> > > >>> +++ b/kernel/cpu.c
> > > >>> @@ -3207,7 +3207,8 @@ enum cpu_mitigations {
> > > >>> };
> > > >>>
> > > >>> static enum cpu_mitigations cpu_mitigations __ro_after_init =
> > > >>> - CPU_MITIGATIONS_AUTO;
> > > >>> + IS_ENABLED(CONFIG_SPECULATION_MITIGATIONS) ? CPU_MITIGATIONS_AUTO :
> > > >>> + CPU_MITIGATIONS_OFF;
> > > >>>
> > > >>> static int __init mitigations_parse_cmdline(char *arg)
> > > >>> {
> > >
> > > I think a minimal workaround/fix would be:
> > >
> > > diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> > > index 2b8fd6bb7da0..290be2f9e909 100644
> > > --- a/drivers/base/Kconfig
> > > +++ b/drivers/base/Kconfig
> > > @@ -191,6 +191,10 @@ config GENERIC_CPU_AUTOPROBE
> > > config GENERIC_CPU_VULNERABILITIES
> > > bool
> > >
> > > +config SPECULATION_MITIGATIONS
> > > + def_bool y
> > > + depends on !X86
> > > +
> > > config SOC_BUS
> > > bool
> > > select GLOB
> >
> > Thanks, that works for me (on arm64), so
> > Tested-by: Geert Uytterhoeven <[email protected]>
>
> Oof. I completely missed that "cpu_mitigations" wasn't x86-only. I can't think
> of better solution than an on-by-default generic Kconfig, though can't that it
> more simply be:
>
> diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> index 2b8fd6bb7da0..5930cb56ee29 100644
> --- a/drivers/base/Kconfig
> +++ b/drivers/base/Kconfig
> @@ -191,6 +191,9 @@ config GENERIC_CPU_AUTOPROBE
> config GENERIC_CPU_VULNERABILITIES
> bool
>
> +config SPECULATION_MITIGATIONS
> + def_bool !X86
> +
> config SOC_BUS
> bool
> select GLOB

I can't see this in -next yet. Do you plan to post it as a proper patch
to collect acks etc?

Cheers,

Will

2024-04-19 14:39:03

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH 1/3] x86/cpu: Actually turn off mitigations by default for SPECULATION_MITIGATIONS=n

On Fri, Apr 19, 2024 at 07:06:00AM -0700, Sean Christopherson wrote:
> On Fri, Apr 19, 2024, Will Deacon wrote:
> > On Mon, Apr 15, 2024 at 07:31:23AM -0700, Sean Christopherson wrote:
> > > On Mon, Apr 15, 2024, Geert Uytterhoeven wrote:
> > > Oof. I completely missed that "cpu_mitigations" wasn't x86-only. I can't think
> > > of better solution than an on-by-default generic Kconfig, though can't that it
> > > more simply be:
> > >
> > > diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> > > index 2b8fd6bb7da0..5930cb56ee29 100644
> > > --- a/drivers/base/Kconfig
> > > +++ b/drivers/base/Kconfig
> > > @@ -191,6 +191,9 @@ config GENERIC_CPU_AUTOPROBE
> > > config GENERIC_CPU_VULNERABILITIES
> > > bool
> > >
> > > +config SPECULATION_MITIGATIONS
> > > + def_bool !X86
> > > +
> > > config SOC_BUS
> > > bool
> > > select GLOB
> >
> > I can't see this in -next yet. Do you plan to post it as a proper patch
> > to collect acks etc?
>
> Sorry, I neglected to Cc everyone.
>
> https://lore.kernel.org/all/[email protected]

Ah, thanks. I'll go Ack that...

Will