Skip to content

Commit 6c5bf79

Browse files
author
James Morse
committed
arm64: entry: Allow tramp_alias to access symbols after the 4K boundary
Systems using kpti enter and exit the kernel through a trampoline mapping that is always mapped, even when the kernel is not. tramp_valias is a macro to find the address of a symbol in the trampoline mapping. Adding extra sets of vectors will expand the size of the entry.tramp.text section to beyond 4K. tramp_valias will be unable to generate addresses for symbols beyond 4K as it uses the 12 bit immediate of the add instruction. As there are now two registers available when tramp_alias is called, use the extra register to avoid the 4K limit of the 12 bit immediate. Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent c091fb6 commit 6c5bf79

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

arch/arm64/kernel/entry.S

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@
103103
.org .Lventry_start\@ + 128 // Did we overflow the ventry slot?
104104
.endm
105105

106-
.macro tramp_alias, dst, sym
106+
.macro tramp_alias, dst, sym, tmp
107107
mov_q \dst, TRAMP_VALIAS
108-
add \dst, \dst, #(\sym - .entry.tramp.text)
108+
adr_l \tmp, \sym
109+
add \dst, \dst, \tmp
110+
adr_l \tmp, .entry.tramp.text
111+
sub \dst, \dst, \tmp
109112
.endm
110113

111114
/*
@@ -429,10 +432,10 @@ alternative_else_nop_endif
429432
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
430433
bne 4f
431434
msr far_el1, x29
432-
tramp_alias x30, tramp_exit_native
435+
tramp_alias x30, tramp_exit_native, x29
433436
br x30
434437
4:
435-
tramp_alias x30, tramp_exit_compat
438+
tramp_alias x30, tramp_exit_compat, x29
436439
br x30
437440
#endif
438441
.else
@@ -1000,7 +1003,7 @@ alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0
10001003
alternative_else_nop_endif
10011004

10021005
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
1003-
tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline
1006+
tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline, tmp=x3
10041007
br x5
10051008
#endif
10061009
SYM_CODE_END(__sdei_asm_handler)

0 commit comments

Comments
 (0)