arm64/sdei: fix trampoline vector alignment
PATCH 1/1 arm64/sdei: fix trampoline vector alignment
From: Remi Denis-Courmont <[email protected]>
The exception vector is aligned on 2KiB. To compute the correct address to the SDEI handler, use ADRP for the page number. The existing code using ADR would only compute the correct address if the vector is aligned on 4KiB, i.e., works by luck.
This also combines the following ADD and LDR into a single LDR with a relocated offset.
--- arch/arm64/kernel/entry.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arm64/kernel/entry.S +2 -3
@@ -953,9 +953,8 @@ ENTRY(__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 · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerHi Remi,
In future could you please Cc maintainers? You can use scripts/get_maintainer.pl to get a list of relevant people for a patch or file.
I've added the relevant arm64 folk here.
Quoted 6 lines · Rémi Denis-Courmont
From: Remi Denis-Courmont <[email protected]>
The exception vector is aligned on 2KiB. To compute the correct address to the SDEI handler, use ADRP for the page number. The existing code using ADR would only compute the correct address if the vector is aligned on 4KiB, i.e., works by luck.
This works because .entry.tramp.test is aligned to PAGE_SIZE, and tramp_vectors is the first element in .entry.tramp.test, so it's aligned to PAGE_SIZE.
Other code relies on tramp_vectors being page aligned,
so I think it would make sense to remove the ".align 11" and replace it with ".align PAGE_SHIFT" and a comment regarding .entry.tramp.text being page-aligned.
I think the commit message needs to be corrected, since this works by more than luck.
Quoted 2 lines
This also combines the following ADD and LDR into a single LDR with a relocated offset.
This looks sane to me.
Thanks,
Mark.
Quoted 30 lines
Signed-off-by Remi Denis-Courmont <[email protected]>--- arch/arm64/kernel/entry.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)arch/arm64/kernel/entry.S +2
-3@@ -953,9 +953,8 @@ ENTRY(__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 #endifSignature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel