diff --git a/armstubs/Makefile b/armstubs/Makefile index e6035719..20183d5e 100644 --- a/armstubs/Makefile +++ b/armstubs/Makefile @@ -1,4 +1,4 @@ -BINS=armstub.bin armstub7.bin armstub8-32.bin armstub8-32-gic.bin armstub8.bin armstub8-gic.bin armstub8-gic-highperi.bin +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 CC8?=aarch64-linux-gnu-gcc LD8?=aarch64-linux-gnu-ld @@ -26,6 +26,9 @@ clean : %8-gic-highperi.o: %8.S $(CC8) -DGIC=1 -DHIGH_PERI=1 -DBCM2711=1 -c $< -o $@ +%8-gic-spectrev4.o: %8.S + $(CC8) -DGIC=1 -DSPECTRE_V4=1 -DBCM2711=1 -c $< -o $@ + %8-32.o: %7.S $(CC7) -DBCM2710=1 -c $< -o $@ @@ -41,6 +44,9 @@ clean : %8-gic-highperi.elf: %8-gic-highperi.o $(LD8) --section-start=.text=0 $< -o $@ +%8-gic-spectrev4.elf: %8-gic-spectrev4.o + $(LD8) --section-start=.text=0 $< -o $@ + %8.elf: %8.o $(LD8) --section-start=.text=0 $< -o $@ @@ -53,6 +59,9 @@ clean : %8-gic-highperi.tmp: %8-gic-highperi.elf $(OBJCOPY8) $< -O binary $@ +%8-gic-spectrev4.tmp: %8-gic-spectrev4.elf + $(OBJCOPY8) $< -O binary $@ + %8.tmp: %8.elf $(OBJCOPY8) $< -O binary $@ diff --git a/armstubs/armstub8.S b/armstubs/armstub8.S index 30eb238e..9e6a41ce 100644 --- a/armstubs/armstub8.S +++ b/armstubs/armstub8.S @@ -68,6 +68,9 @@ #define ACTLR_VAL \ (BIT(0) | BIT(1) | BIT(4) | BIT(5) | BIT(6)) +#define CPUACTLR_EL1 S3_1_C15_C2_0 +#define CPUACTLR_EL1_DLPS BIT(55) + #define CPUECTLR_EL1 S3_1_C15_C2_1 #define CPUECTLR_EL1_SMPEN BIT(6) @@ -130,6 +133,12 @@ _start: mov x0, #CPUECTLR_EL1_SMPEN msr CPUECTLR_EL1, x0 +#ifdef SPECTRE_V4 + /* mitigate Spectre v4 */ + mov x0, #CPUACTLR_EL1_DLPS + msr CPUACTLR_EL1, x0 +#endif + #ifdef GIC bl setup_gic #endif