Skip to content

Commit c456442

Browse files
konradwilkKAGA-KOKO
authored andcommitted
x86/bugs: Expose /sys/../spec_store_bypass
Add the sysfs file for the new vulerability. It does not do much except show the words 'Vulnerable' for recent x86 cores. Intel cores prior to family 6 are known not to be vulnerable, and so are some Atoms and some Xeon Phi. It assumes that older Cyrix, Centaur, etc. cores are immune. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Borislav Petkov <bp@suse.de> Reviewed-by: Ingo Molnar <mingo@kernel.org>
1 parent 5cf6875 commit c456442

6 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎Documentation/ABI/testing/sysfs-devices-system-cpu‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ What: /sys/devices/system/cpu/vulnerabilities
478478
/sys/devices/system/cpu/vulnerabilities/meltdown
479479
/sys/devices/system/cpu/vulnerabilities/spectre_v1
480480
/sys/devices/system/cpu/vulnerabilities/spectre_v2
481+
/sys/devices/system/cpu/vulnerabilities/spec_store_bypass
481482
Date: January 2018
482483
Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
483484
Description: Information about CPU vulnerabilities

‎arch/x86/include/asm/cpufeatures.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,6 @@
363363
#define X86_BUG_CPU_MELTDOWN X86_BUG(14) /* CPU is affected by meltdown attack and needs kernel page table isolation */
364364
#define X86_BUG_SPECTRE_V1 X86_BUG(15) /* CPU is affected by Spectre variant 1 attack with conditional branches */
365365
#define X86_BUG_SPECTRE_V2 X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
366+
#define X86_BUG_SPEC_STORE_BYPASS X86_BUG(17) /* CPU is affected by speculative store bypass attack */
366367

367368
#endif /* _ASM_X86_CPUFEATURES_H */

‎arch/x86/kernel/cpu/bugs.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,9 @@ ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, c
404404
{
405405
return cpu_show_common(dev, attr, buf, X86_BUG_SPECTRE_V2);
406406
}
407+
408+
ssize_t cpu_show_spec_store_bypass(struct device *dev, struct device_attribute *attr, char *buf)
409+
{
410+
return cpu_show_common(dev, attr, buf, X86_BUG_SPEC_STORE_BYPASS);
411+
}
407412
#endif

‎arch/x86/kernel/cpu/common.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,33 @@ static const __initconst struct x86_cpu_id cpu_no_meltdown[] = {
927927
{}
928928
};
929929

930+
static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
931+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PINEVIEW },
932+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_LINCROFT },
933+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PENWELL },
934+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CLOVERVIEW },
935+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CEDARVIEW },
936+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
937+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
938+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT2 },
939+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_MERRIFIELD },
940+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_CORE_YONAH },
941+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
942+
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
943+
{ X86_VENDOR_CENTAUR, 5, },
944+
{ X86_VENDOR_INTEL, 5, },
945+
{ X86_VENDOR_NSC, 5, },
946+
{ X86_VENDOR_ANY, 4, },
947+
{}
948+
};
949+
930950
static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
931951
{
932952
u64 ia32_cap = 0;
933953

954+
if (!x86_match_cpu(cpu_no_spec_store_bypass))
955+
setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
956+
934957
if (x86_match_cpu(cpu_no_speculation))
935958
return;
936959

‎drivers/base/cpu.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,22 @@ ssize_t __weak cpu_show_spectre_v2(struct device *dev,
534534
return sprintf(buf, "Not affected\n");
535535
}
536536

537+
ssize_t __weak cpu_show_spec_store_bypass(struct device *dev,
538+
struct device_attribute *attr, char *buf)
539+
{
540+
return sprintf(buf, "Not affected\n");
541+
}
542+
537543
static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
538544
static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
539545
static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
546+
static DEVICE_ATTR(spec_store_bypass, 0444, cpu_show_spec_store_bypass, NULL);
540547

541548
static struct attribute *cpu_root_vulnerabilities_attrs[] = {
542549
&dev_attr_meltdown.attr,
543550
&dev_attr_spectre_v1.attr,
544551
&dev_attr_spectre_v2.attr,
552+
&dev_attr_spec_store_bypass.attr,
545553
NULL
546554
};
547555

‎include/linux/cpu.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ extern ssize_t cpu_show_spectre_v1(struct device *dev,
5353
struct device_attribute *attr, char *buf);
5454
extern ssize_t cpu_show_spectre_v2(struct device *dev,
5555
struct device_attribute *attr, char *buf);
56+
extern ssize_t cpu_show_spec_store_bypass(struct device *dev,
57+
struct device_attribute *attr, char *buf);
5658

5759
extern __printf(4, 5)
5860
struct device *cpu_device_create(struct device *parent, void *drvdata,

0 commit comments

Comments
 (0)