Skip to contentSkip to conversation

arm64: head: remove unnecessary instructions from __relocate_kernel

PATCH In review Puranjay Mohan 2 participants 2 messages Mar 2, 2024 – Mar 4, 2024 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: head: remove unnecessary instructions from __relocate_kernel

Formerly, we had to access the RELA and RELR tables via the kernel mapping that was being relocated, and so deriving the start and end addresses was done by loading __rela_offset in x9 and then adding the actual virtual offset of the kernel to it.

d7bea550279d ("arm64: head: use relative references to the RELA and RELR tables") changed this to load the entries via the ID map as we map the entire kernel image via the ID map.

The two instructions for finding the actual virtual offset were left by that commit, so remove them now as they are unnecessary and add runtime overhead.

Fixes d7bea550279d ("arm64: head: use relative references to the RELA and RELR tables")
---
 arch/arm64/kernel/head.S | 2 --
 1 file changed, 2 deletions(-)
arch/arm64/kernel/head.S +0 -2
index cab7f91949d8..90db196f7c19 100644
@@ -787,8 +787,6 @@ SYM_FUNC_START_LOCAL(__relocate_kernel)
 	 */
 	adr_l	x9, __rela_start
 	adr_l	x10, __rela_end
-	mov_q	x11, KIMAGE_VADDR		// default virtual offset
-	add	x11, x11, x23			// actual virtual offset
 
 0:	cmp	x9, x10
 	b.hs	1f

base-commit: 5ad3cb0ed525b80c7f66c32b49a68c1f3510bec9

Signature · 1 line
2.42.0
reviewer
#1 lore raw
Quoted 5 lines · Puranjay Mohan

Formerly, we had to access the RELA and RELR tables via the kernel mapping that was being relocated, and so deriving the start and end addresses was done by loading __rela_offset in x9 and then adding the actual virtual offset of the kernel to it.

Quoted 7 lines

d7bea550279d ("arm64: head: use relative references to the RELA and RELR tables") changed this to load the entries via the ID map as we map the entire kernel image via the ID map.

The two instructions for finding the actual virtual offset were left by that commit, so remove them now as they are unnecessary and add runtime overhead.

These instructions are already gone in linux-next; they're removed by commit:

734958ef0b5497b1 ("arm64: head: move relocation handling to C code")

... so this patch isn't necessary.

Quoted 1 line
Fixes d7bea550279d ("arm64: head: use relative references to the RELA and RELR tables")

As a heads-up for future patches, while this would be a cleanup it is not a fix, and wouldn't need a fixes tag.

Mark.

Quoted 23 lines
---
 arch/arm64/kernel/head.S | 2 --
 1 file changed, 2 deletions(-)
arch/arm64/kernel/head.S +0 -2
index cab7f91949d8..90db196f7c19 100644
@@ -787,8 +787,6 @@ SYM_FUNC_START_LOCAL(__relocate_kernel)
 	 */
 	adr_l	x9, __rela_start
 	adr_l	x10, __rela_end
-	mov_q	x11, KIMAGE_VADDR		// default virtual offset
-	add	x11, x11, x23			// actual virtual offset
 
 0:	cmp	x9, x10
 	b.hs	1f

base-commit: 5ad3cb0ed525b80c7f66c32b49a68c1f3510bec9

Signature · 1 line
2.42.0