Skip to content

Commit c47e4d0

Browse files
author
James Morse
committed
arm64: entry: Make the kpti trampoline's kpti sequence optional
Spectre-BHB needs to add sequences to the vectors. Having one global set of vectors is a problem for big/little systems where the sequence is costly on cpus that are not vulnerable. Making the vectors per-cpu in the style of KVM's bh_harden_hyp_vecs requires the vectors to be generated by macros. Make the kpti re-mapping of the kernel optional, so the macros can be used without kpti. Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: James Morse <[email protected]>
1 parent 13d7a08 commit c47e4d0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

arch/arm64/kernel/entry.S

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,10 @@ alternative_else_nop_endif
646646
sub \dst, \dst, PAGE_SIZE
647647
.endm
648648

649-
.macro tramp_ventry, vector_start, regsize
649+
.macro tramp_ventry, vector_start, regsize, kpti
650650
.align 7
651651
1:
652+
.if \kpti == 1
652653
.if \regsize == 64
653654
msr tpidrro_el0, x30 // Restored in kernel_ventry
654655
.endif
@@ -671,9 +672,14 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003
671672
alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM
672673
prfm plil1strm, [x30, #(1b - \vector_start)]
673674
alternative_else_nop_endif
675+
674676
msr vbar_el1, x30
675-
add x30, x30, #(1b - \vector_start + 4)
676677
isb
678+
.else
679+
ldr x30, =vectors
680+
.endif // \kpti == 1
681+
682+
add x30, x30, #(1b - \vector_start + 4)
677683
ret
678684
.org 1b + 128 // Did we overflow the ventry slot?
679685
.endm
@@ -691,15 +697,15 @@ alternative_else_nop_endif
691697
sb
692698
.endm
693699

694-
.macro generate_tramp_vector
700+
.macro generate_tramp_vector, kpti
695701
.Lvector_start\@:
696702
.space 0x400
697703

698704
.rept 4
699-
tramp_ventry .Lvector_start\@, 64
705+
tramp_ventry .Lvector_start\@, 64, \kpti
700706
.endr
701707
.rept 4
702-
tramp_ventry .Lvector_start\@, 32
708+
tramp_ventry .Lvector_start\@, 32, \kpti
703709
.endr
704710
.endm
705711

@@ -710,7 +716,7 @@ alternative_else_nop_endif
710716
.pushsection ".entry.tramp.text", "ax"
711717
.align 11
712718
SYM_CODE_START_NOALIGN(tramp_vectors)
713-
generate_tramp_vector
719+
generate_tramp_vector kpti=1
714720
SYM_CODE_END(tramp_vectors)
715721

716722
SYM_CODE_START(tramp_exit_native)

0 commit comments

Comments
 (0)