Skip to content

Commit aff6539

Browse files
author
James Morse
committed
arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations
kpti is an optional feature, for systems not using kpti a set of vectors for the spectre-bhb mitigations is needed. Add another set of vectors, __bp_harden_el1_vectors, that will be used if a mitigation is needed and kpti is not in use. The EL1 ventries are repeated verbatim as there is no additional work needed for entry from EL1. Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: James Morse <[email protected]>
1 parent a9c406e commit aff6539

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

arch/arm64/kernel/entry.S

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,11 @@ alternative_else_nop_endif
649649
.macro tramp_ventry, vector_start, regsize, kpti
650650
.align 7
651651
1:
652-
.if \kpti == 1
653652
.if \regsize == 64
654653
msr tpidrro_el0, x30 // Restored in kernel_ventry
655654
.endif
655+
656+
.if \kpti == 1
656657
/*
657658
* Defend against branch aliasing attacks by pushing a dummy
658659
* entry onto the return stack and using a RET instruction to
@@ -739,6 +740,38 @@ SYM_DATA_END(__entry_tramp_data_start)
739740
#endif /* CONFIG_RANDOMIZE_BASE */
740741
#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
741742

743+
/*
744+
* Exception vectors for spectre mitigations on entry from EL1 when
745+
* kpti is not in use.
746+
*/
747+
.macro generate_el1_vector
748+
.Lvector_start\@:
749+
kernel_ventry 1, t, 64, sync // Synchronous EL1t
750+
kernel_ventry 1, t, 64, irq // IRQ EL1t
751+
kernel_ventry 1, t, 64, fiq // FIQ EL1h
752+
kernel_ventry 1, t, 64, error // Error EL1t
753+
754+
kernel_ventry 1, h, 64, sync // Synchronous EL1h
755+
kernel_ventry 1, h, 64, irq // IRQ EL1h
756+
kernel_ventry 1, h, 64, fiq // FIQ EL1h
757+
kernel_ventry 1, h, 64, error // Error EL1h
758+
759+
.rept 4
760+
tramp_ventry .Lvector_start\@, 64, kpti=0
761+
.endr
762+
.rept 4
763+
tramp_ventry .Lvector_start\@, 32, kpti=0
764+
.endr
765+
.endm
766+
767+
.pushsection ".entry.text", "ax"
768+
.align 11
769+
SYM_CODE_START(__bp_harden_el1_vectors)
770+
generate_el1_vector
771+
SYM_CODE_END(__bp_harden_el1_vectors)
772+
.popsection
773+
774+
742775
/*
743776
* Register switch for AArch64. The callee-saved registers need to be saved
744777
* and restored. On entry:

0 commit comments

Comments
 (0)