Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390: detect etoken facility

Detect and report the etoken facility. With spectre_v2=auto or
CONFIG_EXPOLINE_AUTO=y automatically disable expolines and use
the full branch prediction mode for the kernel.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

+13 -1
+11 -1
arch/s390/kernel/nospec-branch.c
··· 35 35 36 36 static int __init nospec_report(void) 37 37 { 38 + if (test_facility(156)) 39 + pr_info("Spectre V2 mitigation: etokens\n"); 38 40 if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) 39 41 pr_info("Spectre V2 mitigation: execute trampolines\n"); 40 42 if (__test_facility(82, S390_lowcore.alt_stfle_fac_list)) ··· 58 56 59 57 void __init nospec_auto_detect(void) 60 58 { 61 - if (IS_ENABLED(CC_USING_EXPOLINE)) { 59 + if (test_facility(156)) { 60 + /* 61 + * The machine supports etokens. 62 + * Disable expolines and disable nobp. 63 + */ 64 + if (IS_ENABLED(CC_USING_EXPOLINE)) 65 + nospec_disable = 1; 66 + __clear_facility(82, S390_lowcore.alt_stfle_fac_list); 67 + } else if (IS_ENABLED(CC_USING_EXPOLINE)) { 62 68 /* 63 69 * The kernel has been compiled with expolines. 64 70 * Keep expolines enabled and disable nobp.
+2
arch/s390/kernel/nospec-sysfs.c
··· 13 13 ssize_t cpu_show_spectre_v2(struct device *dev, 14 14 struct device_attribute *attr, char *buf) 15 15 { 16 + if (test_facility(156)) 17 + return sprintf(buf, "Mitigation: etokens\n"); 16 18 if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) 17 19 return sprintf(buf, "Mitigation: execute trampolines\n"); 18 20 if (__test_facility(82, S390_lowcore.alt_stfle_fac_list))