1 |
From foo@baz Tue Mar 8 08:47:19 PM CET 2022 |
2 |
From: James Morse <james.morse@arm.com> |
3 |
Date: Wed, 24 Nov 2021 11:40:18 +0000 |
4 |
Subject: arm64: entry: Allow tramp_alias to access symbols after the 4K boundary |
5 |
|
6 |
From: James Morse <james.morse@arm.com> |
7 |
|
8 |
commit 6c5bf79b69f911560fbf82214c0971af6e58e682 upstream. |
9 |
|
10 |
Systems using kpti enter and exit the kernel through a trampoline mapping |
11 |
that is always mapped, even when the kernel is not. tramp_valias is a macro |
12 |
to find the address of a symbol in the trampoline mapping. |
13 |
|
14 |
Adding extra sets of vectors will expand the size of the entry.tramp.text |
15 |
section to beyond 4K. tramp_valias will be unable to generate addresses |
16 |
for symbols beyond 4K as it uses the 12 bit immediate of the add |
17 |
instruction. |
18 |
|
19 |
As there are now two registers available when tramp_alias is called, |
20 |
use the extra register to avoid the 4K limit of the 12 bit immediate. |
21 |
|
22 |
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> |
23 |
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> |
24 |
Signed-off-by: James Morse <james.morse@arm.com> |
25 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
26 |
--- |
27 |
arch/arm64/kernel/entry.S | 13 ++++++++----- |
28 |
1 file changed, 8 insertions(+), 5 deletions(-) |
29 |
|
30 |
--- a/arch/arm64/kernel/entry.S |
31 |
+++ b/arch/arm64/kernel/entry.S |
32 |
@@ -103,9 +103,12 @@ |
33 |
.org .Lventry_start\@ + 128 // Did we overflow the ventry slot? |
34 |
.endm |
35 |
|
36 |
- .macro tramp_alias, dst, sym |
37 |
+ .macro tramp_alias, dst, sym, tmp |
38 |
mov_q \dst, TRAMP_VALIAS |
39 |
- add \dst, \dst, #(\sym - .entry.tramp.text) |
40 |
+ adr_l \tmp, \sym |
41 |
+ add \dst, \dst, \tmp |
42 |
+ adr_l \tmp, .entry.tramp.text |
43 |
+ sub \dst, \dst, \tmp |
44 |
.endm |
45 |
|
46 |
/* |
47 |
@@ -429,10 +432,10 @@ alternative_else_nop_endif |
48 |
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
49 |
bne 4f |
50 |
msr far_el1, x29 |
51 |
- tramp_alias x30, tramp_exit_native |
52 |
+ tramp_alias x30, tramp_exit_native, x29 |
53 |
br x30 |
54 |
4: |
55 |
- tramp_alias x30, tramp_exit_compat |
56 |
+ tramp_alias x30, tramp_exit_compat, x29 |
57 |
br x30 |
58 |
#endif |
59 |
.else |
60 |
@@ -998,7 +1001,7 @@ alternative_if_not ARM64_UNMAP_KERNEL_AT |
61 |
alternative_else_nop_endif |
62 |
|
63 |
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 |
64 |
- tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline |
65 |
+ tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline, tmp=x3 |
66 |
br x5 |
67 |
#endif |
68 |
SYM_CODE_END(__sdei_asm_handler) |