* [PATCH 0/2] arm64/boot: Some relocation tweaks
@ 2026-11-23 14:46 Ard Biesheuvel
2026-11-23 14:46 ` [PATCH 1/2] arm64/boot: Handle RELR relocations more efficiently Ard Biesheuvel
0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2026-11-23 14:46 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: will, catalin.marinas, mark.rutland, Ard Biesheuvel
From: Ard Biesheuvel <ardb@kernel.org>
Fix two issues I spotted while playing with the startup relocation code.
Ard Biesheuvel (2):
arm64/boot: Handle RELR relocations more efficiently
arm64/boot: Discard NULL relocation entries
arch/arm64/kernel/pi/relocate.c | 5 ++---
arch/arm64/kernel/vmlinux.lds.S | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/2] arm64/boot: Handle RELR relocations more efficiently
2026-11-23 14:46 [PATCH 0/2] arm64/boot: Some relocation tweaks Ard Biesheuvel
@ 2026-11-23 14:46 ` Ard Biesheuvel
0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2026-11-23 14:46 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: will, catalin.marinas, mark.rutland, Ard Biesheuvel
From: Ard Biesheuvel <ardb@kernel.org>
The RELR format consists of anchor entries with bit #0 cleared, that
describe an address in the image's address space to which the runtime
load displacement must be applied, followed by any number of entries
with bit #0 set, whose remaining bits each describe 63 subsequent
positions in the image that need the displacement applied as well.
Iterating over those 63 bits one by one is inefficient, given that we
can use the number of trailing zeroes as an array index directly, and
iteratively clear the least significant 1 bit in x by AND'ing with x-1.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/kernel/pi/relocate.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/pi/relocate.c b/arch/arm64/kernel/pi/relocate.c
index 82592f3a5c1c..aa83946193ab 100644
--- a/arch/arm64/kernel/pi/relocate.c
+++ b/arch/arm64/kernel/pi/relocate.c
@@ -55,9 +55,8 @@ void __init relocate_kernel(u64 offset)
place = (u64 *)(*relr + offset);
*place++ += offset;
} else {
- for (u64 *p = place, r = *relr >> 1; r; p++, r >>= 1)
- if (r & 1)
- *p += offset;
+ for (u64 r = *relr >> 1; r; r &= r - 1)
+ place[__ffs(r)] += offset;
place += 63;
}
}
--
2.56.1.750.gf70dc682cf-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 14:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:46 [PATCH 0/2] arm64/boot: Some relocation tweaks Ard Biesheuvel
2026-11-23 14:46 ` [PATCH 1/2] arm64/boot: Handle RELR relocations more efficiently Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox