* Question about dmesg/sysfs output when retpoline config is disabled @ 2018-01-30 4:52 Misono, Tomohiro 2018-01-30 6:13 ` Dou Liyang 0 siblings, 1 reply; 3+ messages in thread From: Misono, Tomohiro @ 2018-01-30 4:52 UTC (permalink / raw) To: linux-kernel; +Cc: Misono, Tomohiro Hello, I think dmesg/sysfs output messages are not suitable if retpoline config is off: I intentionally compiled the kernel 4.15.0 with CONFIG_RETPOLINE=n for test and boot it with the following kernel command line option to check dmesg/sysfs: (a) no command line option or "spectre_v2=on" or "spectre_v2=auto" $ dmesg | grep -i spectre [ 0.017714] Spectre V2 mitigation: Vulnerable: Minimal generic ASM retpoline $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 Minimal generic ASM retpoline (b) "spectre_v2=off" $ dmesg | grep -i spectre [ 0.017002] Spectre V2 mitigation: disabled on command line. $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 Vulnerable (c) "spectre_v2=retpoline" $ dmesg | grep -i spectre [ 0.018002] Spectre V2 mitigation: kernel not compiled with retpoline; no mitigation available! $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 Vulnerable I think the output of (c) is correct for this case, or are these outputs actually right? Also, the output of (a) is the same with following condition: (1) CONFIG_RETPOLINE=n, and (2) CONFIG_RETPOLINE=y but the compiler did not support retpoline These cannot be distinguished unless option of (c) is explicitly used. Regards, Tomohiro Misono ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about dmesg/sysfs output when retpoline config is disabled 2018-01-30 4:52 Question about dmesg/sysfs output when retpoline config is disabled Misono, Tomohiro @ 2018-01-30 6:13 ` Dou Liyang 2018-01-30 14:49 ` [tip:x86/pti] x86/spectre: Check CONFIG_RETPOLINE in command line parser tip-bot for Dou Liyang 0 siblings, 1 reply; 3+ messages in thread From: Dou Liyang @ 2018-01-30 6:13 UTC (permalink / raw) To: Misono, Tomohiro, linux-kernel Cc: dwmw, tglx, arjan, mingo, ak, peterz, bp, x86, dave.hansen Hi Misono-san, At 01/30/2018 12:52 PM, Misono, Tomohiro wrote: > Hello, > > I think dmesg/sysfs output messages are not suitable if retpoline config is off: > > I intentionally compiled the kernel 4.15.0 with CONFIG_RETPOLINE=n for test and > boot it with the following kernel command line option to check dmesg/sysfs: > > (a) no command line option or "spectre_v2=on" or "spectre_v2=auto" > $ dmesg | grep -i spectre > [ 0.017714] Spectre V2 mitigation: Vulnerable: Minimal generic ASM retpoline > $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 > Minimal generic ASM retpoline > > (b) "spectre_v2=off" > $ dmesg | grep -i spectre > [ 0.017002] Spectre V2 mitigation: disabled on command line. > $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 > Vulnerable > > (c) "spectre_v2=retpoline" > $ dmesg | grep -i spectre > [ 0.018002] Spectre V2 mitigation: kernel not compiled with retpoline; no mitigation available! > $ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2 > Vulnerable > > I think the output of (c) is correct for this case, or are these outputs actually right? > > Also, the output of (a) is the same with following condition: > (1) CONFIG_RETPOLINE=n, and > (2) CONFIG_RETPOLINE=y but the compiler did not support retpoline > These cannot be distinguished unless option of (c) is explicitly used. > +Cc maintainers and x86 mail list... first. IMO, Selecting 'on' or 'auto' to "spectre_v2=" should also consider the setting of the CONFIG_RETPOLINE configuration option. So, check if CONFIG_RETPOLINE is y before setup CPU capability. Thanks, dou. --------------8<----------------------------- diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 390b3dc3d438..10188f856099 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -193,8 +193,9 @@ static void __init spectre_v2_select_mitigation(void) case SPECTRE_V2_CMD_FORCE: /* FALLTRHU */ case SPECTRE_V2_CMD_AUTO: - goto retpoline_auto; - + if (IS_ENABLED(CONFIG_RETPOLINE)) + goto retpoline_auto; + break; case SPECTRE_V2_CMD_RETPOLINE_AMD: if (IS_ENABLED(CONFIG_RETPOLINE)) goto retpoline_amd; > Regards, > Tomohiro Misono > > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:x86/pti] x86/spectre: Check CONFIG_RETPOLINE in command line parser 2018-01-30 6:13 ` Dou Liyang @ 2018-01-30 14:49 ` tip-bot for Dou Liyang 0 siblings, 0 replies; 3+ messages in thread From: tip-bot for Dou Liyang @ 2018-01-30 14:49 UTC (permalink / raw) To: linux-tip-commits Cc: mingo, linux-kernel, hpa, misono.tomohiro, douly.fnst, tglx Commit-ID: 9471eee9186a46893726e22ebb54cade3f9bc043 Gitweb: https://git.kernel.org/tip/9471eee9186a46893726e22ebb54cade3f9bc043 Author: Dou Liyang <douly.fnst@cn.fujitsu.com> AuthorDate: Tue, 30 Jan 2018 14:13:50 +0800 Committer: Thomas Gleixner <tglx@linutronix.de> CommitDate: Tue, 30 Jan 2018 15:30:35 +0100 x86/spectre: Check CONFIG_RETPOLINE in command line parser The spectre_v2 option 'auto' does not check whether CONFIG_RETPOLINE is enabled. As a consequence it fails to emit the appropriate warning and sets feature flags which have no effect at all. Add the missing IS_ENABLED() check. Fixes: da285121560e ("x86/spectre: Add boot time option to select Spectre v2 mitigation") Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: ak@linux.intel.com Cc: peterz@infradead.org Cc: Tomohiro" <misono.tomohiro@jp.fujitsu.com> Cc: dave.hansen@intel.com Cc: bp@alien8.de Cc: arjan@linux.intel.com Cc: dwmw@amazon.co.uk Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/f5892721-7528-3647-08fb-f8d10e65ad87@cn.fujitsu.com --- arch/x86/kernel/cpu/bugs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 3bfb2b2..400c34e 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -213,10 +213,10 @@ static void __init spectre_v2_select_mitigation(void) return; case SPECTRE_V2_CMD_FORCE: - /* FALLTRHU */ case SPECTRE_V2_CMD_AUTO: - goto retpoline_auto; - + if (IS_ENABLED(CONFIG_RETPOLINE)) + goto retpoline_auto; + break; case SPECTRE_V2_CMD_RETPOLINE_AMD: if (IS_ENABLED(CONFIG_RETPOLINE)) goto retpoline_amd; ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-30 14:50 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-01-30 4:52 Question about dmesg/sysfs output when retpoline config is disabled Misono, Tomohiro 2018-01-30 6:13 ` Dou Liyang 2018-01-30 14:49 ` [tip:x86/pti] x86/spectre: Check CONFIG_RETPOLINE in command line parser tip-bot for Dou Liyang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome