Skip to content

Commit 455697a

Browse files
committed
arm64: Introduce separate file for spectre mitigations and reporting
The spectre mitigation code is spread over a few different files, which makes it both hard to follow, but also hard to remove it should we want to do that in future. Introduce a new file for housing the spectre mitigations, and populate it with the spectre-v1 reporting code to start with. Signed-off-by: Will Deacon <[email protected]>
1 parent 688f1e4 commit 455697a

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

arch/arm64/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \
1919
return_address.o cpuinfo.o cpu_errata.o \
2020
cpufeature.o alternative.o cacheinfo.o \
2121
smp.o smp_spin_table.o topology.o smccc-call.o \
22-
ssbd.o syscall.o
22+
ssbd.o syscall.o proton-pack.o
2323

2424
targets += efi-entry.o
2525

arch/arm64/kernel/cpu_errata.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -949,12 +949,6 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
949949
}
950950
};
951951

952-
ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr,
953-
char *buf)
954-
{
955-
return sprintf(buf, "Mitigation: __user pointer sanitization\n");
956-
}
957-
958952
ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr,
959953
char *buf)
960954
{

arch/arm64/kernel/proton-pack.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Handle detection, reporting and mitigation of Spectre v1, v2 and v4, as
4+
* detailed at:
5+
*
6+
* https://developer.arm.com/support/arm-security-updates/speculative-processor-vulnerability
7+
*
8+
* This code was originally written hastily under an awful lot of stress and so
9+
* aspects of it are somewhat hacky. Unfortunately, changing anything in here
10+
* instantly makes me feel ill. Thanks, Jann. Thann.
11+
*
12+
* Copyright (C) 2018 ARM Ltd, All Rights Reserved.
13+
* Copyright (C) 2020 Google LLC
14+
*
15+
* "If there's something strange in your neighbourhood, who you gonna call?"
16+
*
17+
* Authors: Will Deacon <[email protected]> and Marc Zyngier <[email protected]>
18+
*/
19+
20+
#include <linux/device.h>
21+
22+
/*
23+
* Spectre v1.
24+
*
25+
* The kernel can't protect userspace for this one: it's each person for
26+
* themselves. Advertise what we're doing and be done with it.
27+
*/
28+
ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr,
29+
char *buf)
30+
{
31+
return sprintf(buf, "Mitigation: __user pointer sanitization\n");
32+
}

0 commit comments

Comments
 (0)