Skip to content

Commit 8cba75a

Browse files
committed
add Cortex-A72 Spectre v4 (CVE-2018-3639) mitigation
1 parent 0c39cb5 commit 8cba75a

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

armstubs/Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BINS=armstub.bin armstub7.bin armstub8-32.bin armstub8-32-gic.bin armstub8.bin armstub8-gic.bin armstub8-gic-highperi.bin
1+
BINS=armstub.bin armstub7.bin armstub8-32.bin armstub8-32-gic.bin armstub8.bin armstub8-gic.bin armstub8-gic-highperi.bin armstub8-gic-spectrev4.bin
22

33
CC8?=aarch64-linux-gnu-gcc
44
LD8?=aarch64-linux-gnu-ld
@@ -26,6 +26,9 @@ clean :
2626
%8-gic-highperi.o: %8.S
2727
$(CC8) -DGIC=1 -DHIGH_PERI=1 -DBCM2711=1 -c $< -o $@
2828

29+
%8-gic-spectrev4.o: %8.S
30+
$(CC8) -DGIC=1 -DSPECTRE_V4=1 -DBCM2711=1 -c $< -o $@
31+
2932
%8-32.o: %7.S
3033
$(CC7) -DBCM2710=1 -c $< -o $@
3134

@@ -41,6 +44,9 @@ clean :
4144
%8-gic-highperi.elf: %8-gic-highperi.o
4245
$(LD8) --section-start=.text=0 $< -o $@
4346

47+
%8-gic-spectrev4.elf: %8-gic-spectrev4.o
48+
$(LD8) --section-start=.text=0 $< -o $@
49+
4450
%8.elf: %8.o
4551
$(LD8) --section-start=.text=0 $< -o $@
4652

@@ -53,6 +59,9 @@ clean :
5359
%8-gic-highperi.tmp: %8-gic-highperi.elf
5460
$(OBJCOPY8) $< -O binary $@
5561

62+
%8-gic-spectrev4.tmp: %8-gic-spectrev4.elf
63+
$(OBJCOPY8) $< -O binary $@
64+
5665
%8.tmp: %8.elf
5766
$(OBJCOPY8) $< -O binary $@
5867

@@ -75,7 +84,7 @@ clean :
7584
$(BIN2C): bin2c.c
7685
gcc $< -o $@
7786

78-
armstubs.h: armstub.C armstub7.C armstub8-32.C armstub8-32-gic.C armstub8.C armstub8-gic.C armstub8-gic-highperi.C
87+
armstubs.h: armstub.C armstub7.C armstub8-32.C armstub8-32-gic.C armstub8.C armstub8-gic.C armstub8-gic-highperi.C armstub8-gic-spectrev4.C
7988
echo 'static const unsigned armstub[] = {' > $@
8089
cat armstub.C >> $@
8190
echo '};' >> $@
@@ -97,4 +106,7 @@ armstubs.h: armstub.C armstub7.C armstub8-32.C armstub8-32-gic.C armstub8.C arms
97106
echo 'static const unsigned armstub8_gic_highperi[] = {' >> $@
98107
cat armstub8-gic-highperi.C >> $@
99108
echo '};' >> $@
109+
echo 'static const unsigned armstub8_gic_spectrev4[] = {' >> $@
110+
cat armstub8-gic-spectrev4.C >> $@
111+
echo '};' >> $@
100112

armstubs/armstub8.S

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
#define SCR_VAL \
6666
(SCR_RW | SCR_HCE | SCR_SMD | SCR_RES1_5 | SCR_RES1_4 | SCR_NS)
6767

68+
#define CPUACTLR_EL1 S3_1_C15_C2_0
69+
#define CPUACTLR_EL1_DLPS BIT(55)
70+
6871
#define CPUECTLR_EL1 S3_1_C15_C2_1
6972
#define CPUECTLR_EL1_SMPEN BIT(6)
7073

@@ -124,6 +127,12 @@ _start:
124127
mov x0, #CPUECTLR_EL1_SMPEN
125128
msr CPUECTLR_EL1, x0
126129

130+
#ifdef SPECTRE_V4
131+
/* mitigate Spectre v4 */
132+
mov x0, #CPUACTLR_EL1_DLPS
133+
msr CPUACTLR_EL1, x0
134+
#endif
135+
127136
#ifdef GIC
128137
bl setup_gic
129138
#endif

0 commit comments

Comments
 (0)