2018-04-24 06:23:54 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <asm/facility.h>
|
|
|
|
#include <asm/nospec-branch.h>
|
|
|
|
|
|
|
|
ssize_t cpu_show_spectre_v1(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2024-10-23 12:10:58 +00:00
|
|
|
return sysfs_emit(buf, "Mitigation: __user pointer sanitization\n");
|
2018-04-24 06:23:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t cpu_show_spectre_v2(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2018-05-08 13:14:48 +00:00
|
|
|
if (test_facility(156))
|
2024-10-23 12:10:58 +00:00
|
|
|
return sysfs_emit(buf, "Mitigation: etokens\n");
|
2021-10-04 06:51:06 +00:00
|
|
|
if (nospec_uses_trampoline())
|
2024-10-23 12:10:58 +00:00
|
|
|
return sysfs_emit(buf, "Mitigation: execute trampolines\n");
|
2024-07-16 11:50:55 +00:00
|
|
|
if (nobp_enabled())
|
2024-10-23 12:10:58 +00:00
|
|
|
return sysfs_emit(buf, "Mitigation: limited branch prediction\n");
|
|
|
|
return sysfs_emit(buf, "Vulnerable\n");
|
2018-04-24 06:23:54 +00:00
|
|
|
}
|