x86/cpu/amd: Report zenbleed in sysfs
Subsystems (3)
PATCH 1/1 x86/cpu/amd: Report zenbleed in sysfs
Initial submission of Zenbleed fix omitted reporting the bug in sysfs. There's no reason why it shouldn't be reported so let's add it among the other vulnerabilities.
--- .../ABI/testing/sysfs-devices-system-cpu | 1 + arch/x86/kernel/cpu/amd.c | 15 +++++++++++++++ drivers/base/cpu.c | 8 ++++++++ include/linux/cpu.h | 2 ++ 4 files changed, 26 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +1 -0
@@ -524,6 +524,7 @@ What: /sys/devices/system/cpu/vulnerabilities /sys/devices/system/cpu/vulnerabilities/itlb_multihit /sys/devices/system/cpu/vulnerabilities/mmio_stale_data /sys/devices/system/cpu/vulnerabilities/retbleed + /sys/devices/system/cpu/vulnerabilities/zenbleed Date: January 2018 Contact: Linux kernel mailing list <[email protected]> Description: Information about CPU vulnerabilities
arch/x86/kernel/cpu/amd.c +15 -0
@@ -1279,6 +1279,21 @@ u32 amd_get_highest_perf(void) }EXPORT_SYMBOL_GPL (amd_get_highest_perf); +ssize_t cpu_show_zenbleed (struct device *dev,struct device_attribute *attr,char *buf) +{ + +if (!cpu_has_amd_erratum (&boot_cpu_data, amd_zenbleed) || + !boot_cpu_has (X86_FEATURE_AVX ) || +boot_cpu_has (X86_FEATURE_HYPERVISOR )) +return sysfs_emit (buf,"Not affected\n" ); + +if (!cpu_has_zenbleed_microcode ()) { +return sysfs_emit (buf,"Mitigation: Chickenbit\n" ); + }else { +return sysfs_emit (buf,"Mitigation: Microcode\n" ); + } +} +static void zenbleed_check_cpu (void *unused) {struct cpuinfo_x86 *c = &cpu_data (smp_processor_id ());
drivers/base/cpu.c +8 -0
@@ -577,6 +577,12 @@ ssize_t __weak cpu_show_retbleed(struct device *dev,return sysfs_emit (buf,"Not affected\n" ); } +ssize_t __weak cpu_show_zenbleed (struct device *dev, +struct device_attribute *attr,char *buf) +{ +return sysfs_emit (buf,"Not affected\n" ); +} + static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL); static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL); static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
@@ -588,6 +594,7 @@ static DEVICE_ATTR(itlb_multihit, 0444, cpu_show_itlb_multihit, NULL); static DEVICE_ATTR(srbds, 0444, cpu_show_srbds, NULL); static DEVICE_ATTR(mmio_stale_data, 0444, cpu_show_mmio_stale_data, NULL); static DEVICE_ATTR(retbleed, 0444, cpu_show_retbleed, NULL); +static DEVICE_ATTR(zenbleed, 0444, cpu_show_zenbleed, NULL);static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_meltdown.attr,
@@ -601,6 +608,7 @@ static struct attribute *cpu_root_vulnerabilities_attrs[] = { &dev_attr_srbds.attr, &dev_attr_mmio_stale_data.attr, &dev_attr_retbleed.attr, + &dev_attr_zenbleed.attr, NULL };
include/linux/cpu.h +2 -0
@@ -70,6 +70,8 @@ extern ssize_t cpu_show_mmio_stale_data(struct device *dev, char *buf);extern ssize_t cpu_show_retbleed (struct device *dev,struct device_attribute *attr,char *buf); +extern ssize_t cpu_show_zenbleed (struct device *dev, +struct device_attribute *attr,char *buf); extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata,
Signature · 1 line
2.34.1
Borislav Petkov
maintainerQuoted 2 lines · Nikolay Borisov
Initial submission of Zenbleed fix omitted reporting the bug in sysfs. There's no reason
Yeah, there is a reason - it is not a speculation vuln and people want to disable the speculation mitigations if they deem their userspace trustworthy. This one you don't want to disable ever.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 29 lines · Nikolay Borisov
Initial submission of Zenbleed fix omitted reporting the bug in sysfs. There's no reason why it shouldn't be reported so let's add it among the other vulnerabilities.
Signed-off-by Nikolay Borisov <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 1 + arch/x86/kernel/cpu/amd.c | 15 +++++++++++++++ drivers/base/cpu.c | 8 ++++++++ include/linux/cpu.h | 2 ++ 4 files changed, 26 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +1
-0@@ -524,6 +524,7 @@ What: /sys/devices/system/cpu/vulnerabilities /sys/devices/system/cpu/vulnerabilities/itlb_multihit /sys/devices/system/cpu/vulnerabilities/mmio_stale_data /sys/devices/system/cpu/vulnerabilities/retbleed + /sys/devices/system/cpu/vulnerabilities/zenbleed Date: January 2018 Contact: Linux kernel mailing list <[email protected]> Description: Information about CPU vulnerabilitiesarch/x86/kernel/cpu/amd.c +0
-0
arch/x86/kernel/cpu/amd.c u32 amd_get_highest_perf(void) · line 1284
Quoted 6 lines
arch/x86/kernel/cpu/amd.c +3
-0@@ -1279,6 +1279,21 @@ u32 amd_get_highest_perf(void) }EXPORT_SYMBOL_GPL (amd_get_highest_perf); +ssize_t cpu_show_zenbleed (struct device *dev,struct device_attribute *attr,char *buf) +{ +
Extra newline.
arch/x86/kernel/cpu/amd.c u32 amd_get_highest_perf(void) · line 1290
Quoted 6 lines
arch/x86/kernel/cpu/amd.c +6
-0+if (!cpu_has_amd_erratum (&boot_cpu_data, amd_zenbleed) || + !boot_cpu_has (X86_FEATURE_AVX ) || +boot_cpu_has (X86_FEATURE_HYPERVISOR )) +return sysfs_emit (buf,"Not affected\n" ); + +if (!cpu_has_zenbleed_microcode ()) {
For readability this can check of microcode present case, and drop the NOT operator.
arch/x86/kernel/cpu/amd.c u32 amd_get_highest_perf(void) · line 1291
Quoted 1 line
arch/x86/kernel/cpu/amd.c +1
-0+return sysfs_emit (buf,"Mitigation: Chickenbit\n" );
Shouldn't this be checking if the chicken bit is set? And if its not set then report "Vulnerable".
But, looking at zenbleed_check() it appear that the chicken bit for zenbleed will always be present, and it will always be set if microcode is not present.
Quoted 4 lines
arch/x86/kernel/cpu/amd.c +4
-0+ }else { +return sysfs_emit (buf,"Mitigation: Microcode\n" ); + } +}
Quoted 49 lines · Pawan Gupta
Quoted 29 lines · Nikolay Borisov
Initial submission of Zenbleed fix omitted reporting the bug in sysfs. There's no reason why it shouldn't be reported so let's add it among the other vulnerabilities.
Signed-off-by Nikolay Borisov <[email protected]>--- .../ABI/testing/sysfs-devices-system-cpu | 1 + arch/x86/kernel/cpu/amd.c | 15 +++++++++++++++ drivers/base/cpu.c | 8 ++++++++ include/linux/cpu.h | 2 ++ 4 files changed, 26 insertions(+)Documentation/ABI/testing/sysfs-devices-system-cpu +1
-0@@ -524,6 +524,7 @@ What: /sys/devices/system/cpu/vulnerabilities /sys/devices/system/cpu/vulnerabilities/itlb_multihit /sys/devices/system/cpu/vulnerabilities/mmio_stale_data /sys/devices/system/cpu/vulnerabilities/retbleed + /sys/devices/system/cpu/vulnerabilities/zenbleed Date: January 2018 Contact: Linux kernel mailing list <[email protected]> Description: Information about CPU vulnerabilitiesarch/x86/kernel/cpu/amd.c +0
-0arch/x86/kernel/cpu/amd.c u32 amd_get_highest_perf(void) · line 1284
Quoted 6 lines
arch/x86/kernel/cpu/amd.c +3
-0@@ -1279,6 +1279,21 @@ u32 amd_get_highest_perf(void) }EXPORT_SYMBOL_GPL (amd_get_highest_perf); +ssize_t cpu_show_zenbleed (struct device *dev,struct device_attribute *attr,char *buf) +{ +Extra newline.
arch/x86/kernel/cpu/amd.c u32 amd_get_highest_perf(void) · line 1290
Quoted 6 lines
arch/x86/kernel/cpu/amd.c +6
-0+if (!cpu_has_amd_erratum (&boot_cpu_data, amd_zenbleed) || + !boot_cpu_has (X86_FEATURE_AVX ) || +boot_cpu_has (X86_FEATURE_HYPERVISOR )) +return sysfs_emit (buf,"Not affected\n" ); + +if (!cpu_has_zenbleed_microcode ()) {For readability this can check of microcode present case, and drop the NOT operator.
Quoted 8 lines
arch/x86/kernel/cpu/amd.c u32 amd_get_highest_perf(void) · line 1291
Quoted 1 line
arch/x86/kernel/cpu/amd.c +1
-0+return sysfs_emit (buf,"Mitigation: Chickenbit\n" );Shouldn't this be checking if the chicken bit is set? And if its not set then report "Vulnerable".
But, looking at
zenbleed_check()it appear that the chicken bit for zenbleed will always be present, and it will always be set if microcode is not present.
Yeah, but based on feedback I got from Boris it seems this is not going to be merged so it doesn't matter.
Quoted 5 lines
Quoted 5 lines
arch/x86/kernel/cpu/amd.c +4
-0+ }else { +return sysfs_emit (buf,"Mitigation: Microcode\n" ); + } +}