| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
#include <linux/device.h> |
| 3 |
#include <linux/cpu.h> |
| 4 |
#include <asm/facility.h> |
| 5 |
#include <asm/nospec-branch.h> |
| 6 |
|
| 7 |
ssize_t cpu_show_spectre_v1(struct device *dev, |
| 8 |
struct device_attribute *attr, char *buf) |
| 9 |
{ |
| 10 |
return sysfs_emit(buf, "Mitigation: __user pointer sanitization\n"); |
| 11 |
} |
| 12 |
|
| 13 |
ssize_t cpu_show_spectre_v2(struct device *dev, |
| 14 |
struct device_attribute *attr, char *buf) |
| 15 |
{ |
| 16 |
if (test_facility(156)) |
| 17 |
return sysfs_emit(buf, "Mitigation: etokens\n"); |
| 18 |
if (nospec_uses_trampoline()) |
| 19 |
return sysfs_emit(buf, "Mitigation: execute trampolines\n"); |
| 20 |
if (nobp_enabled()) |
| 21 |
return sysfs_emit(buf, "Mitigation: limited branch prediction\n"); |
| 22 |
return sysfs_emit(buf, "Vulnerable\n"); |
| 23 |
} |