arm64: clean up trampoline vector loads
PATCH 1/3 arm64: clean up trampoline vector loads
From: Rémi Denis-Courmont <[email protected]>
This switches from custom instruction patterns to the regular large memory model sequence with ADRP and LDR. In doing so, the ADD instruction can be eliminated in the SDEI handler, and the code no longer assumes that the trampoline vectors and the vectors address both start on a page boundary.
--- arch/arm64/kernel/entry.S | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/arm64/kernel/entry.S +4 -5
@@ -805,9 +805,9 @@ alternative_else_nop_endif 2: tramp_map_kernel x30 #ifdef CONFIG_RANDOMIZE_BASE - adr x30, tramp_vectors + PAGE_SIZE + adrp x30, tramp_vectors + PAGE_SIZE alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 - ldr x30, [x30] + ldr x30, [x30, #:lo12:__entry_tramp_data_start] #else ldr x30, =vectors #endif
@@ -953,9 +953,8 @@ SYM_CODE_START(__sdei_asm_entry_trampoline) 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] #ifdef CONFIG_RANDOMIZE_BASE - adr x4, tramp_vectors + PAGE_SIZE - add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler - ldr x4, [x4] + adrp x4, tramp_vectors + PAGE_SIZE + ldr x4, [x4, #:lo12:__sdei_asm_trampoline_next_handler] #else ldr x4, =__sdei_asm_handler #endif
Signature · 1 line
2.25.1
Quoted 31 lines · Rémi Denis-Courmont
From: Rémi Denis-Courmont <[email protected]>
This switches from custom instruction patterns to the regular large memory model sequence with ADRP and LDR. In doing so, the ADD instruction can be eliminated in the SDEI handler, and the code no longer assumes that the trampoline vectors and the vectors address both start on a page boundary.
Signed-off-by Rémi Denis-Courmont <[email protected]>--- arch/arm64/kernel/entry.S | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)arch/arm64/kernel/entry.S +2
-2@@ -805,9 +805,9 @@ alternative_else_nop_endif 2: tramp_map_kernel x30 #ifdef CONFIG_RANDOMIZE_BASE - adr x30, tramp_vectors + PAGE_SIZE + adrp x30, tramp_vectors + PAGE_SIZE alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 - ldr x30, [x30] + ldr x30, [x30, #:lo12:__entry_tramp_data_start] #else ldr x30, =vectors #endif@@ -953,9 +953,8 @@ SYM_CODE_START(__sdei_asm_entry_trampoline) 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)]
arch/arm64/kernel/entry.S SYM_CODE_START(__sdei_asm_entry_trampoline) · line 960
Quoted 10 lines
arch/arm64/kernel/entry.S +2
-3#ifdef CONFIG_RANDOMIZE_BASE - adr x4, tramp_vectors + PAGE_SIZE - add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler - ldr x4, [x4] + adrp x4, tramp_vectors + PAGE_SIZE + ldr x4, [x4, #:lo12:__sdei_asm_trampoline_next_handler] #else ldr x4, =__sdei_asm_handler #endif
Will
Quoted 9 lines · Rémi Denis-Courmont
From: Rémi Denis-Courmont <[email protected]>
This switches from custom instruction patterns to the regular large memory model sequence with ADRP and LDR. In doing so, the ADD instruction can be eliminated in the SDEI handler, and the code no longer assumes that the trampoline vectors and the vectors address both start on a page boundary.
Signed-off-by Rémi Denis-Courmont <[email protected]>
I queued the 3 trampoline patches for 5.7. Thanks.
Signature · 1 line
Catalin
Catalin Marinas
maintainerQuoted 9 lines · Catalin Marinas
Quoted 8 lines · Rémi Denis-Courmont
From: Rémi Denis-Courmont <[email protected]>
This switches from custom instruction patterns to the regular large memory model sequence with ADRP and LDR. In doing so, the ADD instruction can be eliminated in the SDEI handler, and the code no longer assumes that the trampoline vectors and the vectors address both start on a page boundary.
Quoted 3 lines
Quoted 1 line
Signed-off-by Rémi Denis-Courmont <[email protected]>I queued the 3 trampoline patches for 5.7. Thanks.
... and removed. I applied them on top of arm64 for-next/asm-annotations and with defconfig I get:
LD .tmp_vmlinux1arch/arm64/kernel/entry.o: in function `tramp_vectors':
arch/arm64/kernel/entry.S:838:(.entry.tramp.text+0x43c): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:838: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:839:(.entry.tramp.text+0x4bc): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:839: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:840:(.entry.tramp.text+0x53c): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:840: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:841:(.entry.tramp.text+0x5bc): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:841: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:843:(.entry.tramp.text+0x638): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:843: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:844:(.entry.tramp.text+0x6b8): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:844: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:845:(.entry.tramp.text+0x738): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:845: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined arch/arm64/kernel/entry.S:846:(.entry.tramp.text+0x7b8): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__entry_tramp_data_start' defined in .rodata section in arch/arm64/kernel/entry.o
ld: arch/arm64/kernel/entry.S:846: warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined make[1]: *** [Makefile:1077: vmlinux] Error 1
I haven't bisected to see which patch caused this issue.
$ gcc --version gcc (Debian 9.2.1-30) 9.2.1 20200224
$ ld --version GNU ld (GNU Binutils for Debian) 2.34
Signature · 1 line
Catalin
Quoted 17 lines · Le keskiviikkona 18. maaliskuuta 2020, 20.06.30 EET Catalin Marinas a écrit :
Quoted 9 lines · Catalin Marinas
Quoted 8 lines · Rémi Denis-Courmont
From: Rémi Denis-Courmont <[email protected]>
This switches from custom instruction patterns to the regular large memory model sequence with ADRP and LDR. In doing so, the ADD instruction can be eliminated in the SDEI handler, and the code no longer assumes that the trampoline vectors and the vectors address both start on a page boundary.
Quoted 3 lines
Quoted 1 line
Signed-off-by Rémi Denis-Courmont <[email protected]>I queued the 3 trampoline patches for 5.7. Thanks.
... and removed. I applied them on top of arm64 for-next/asm-annotations and with defconfig I get:
Quoted 7 lines
LD .tmp_vmlinux1
arch/arm64/kernel/entry.o: in function `tramp_vectors':
arch/arm64/kernel/entry.S:838:(.entry.tramp.text+0x43c): relocation truncated to fit:R_AARCH64_LDST64_ABS_LO12_NCagainst symbol `__entry_tramp_data_start' defined in .rodata section inI haven't bisected to see which patch caused this issue.
Uho, right :-( It only builds with SDEI enabled :-$
I'll check further.
Signature · 2 lines
Rémi Denis-Courmont http://www.remlab.net/
Le 2020-03-18 20:29, Rémi Denis-Courmont a écrit :
Quoted 18 lines · Le keskiviikkona 18. maaliskuuta 2020, 20.06.30 EET Catalin Marinas a écrit :
Quoted 17 lines · Catalin Marinas
Quoted 9 lines · Rémi Denis-Courmont
Quoted 8 lines
From: Rémi Denis-Courmont <[email protected]>
This switches from custom instruction patterns to the regular large memory model sequence with ADRP and LDR. In doing so, the ADD instruction can be eliminated in the SDEI handler, and the code no longer assumes that the trampoline vectors and the vectors address both start on a page boundary.
Quoted 3 lines
Quoted 1 line
Signed-off-by Rémi Denis-Courmont <[email protected]>I queued the 3 trampoline patches for 5.7. Thanks.
... and removed. I applied them on top of arm64 for-next/asm-annotations and with defconfig I get:
Quoted 7 lines
Quoted 7 lines
LD .tmp_vmlinux1
arch/arm64/kernel/entry.o: in function `tramp_vectors':
arch/arm64/kernel/entry.S:838:(.entry.tramp.text+0x43c): relocation truncated to fit:R_AARCH64_LDST64_ABS_LO12_NCagainst symbol `__entry_tramp_data_start' defined in .rodata section inI haven't bisected to see which patch caused this issue.
It's the third patch.
Quoted 3 lines
Uho, right :-( It only builds with SDEI enabled :-$
I'll check further.
It seems that the SYM_DATA_START macro does not align the data on its natural boundary. I guess that is all fine on x86 where data needs not be aligned, but it leads to this kind of mischief on arm64. Though even then, the address is of course actually aligned correctly on an 8-bytes boundary, so I suppose binutils is just being pointlessly pedantic here?
Signature · 1 line
Rémi Denis-Courmont