Skip to contentSkip to conversation

arm64: move kimage_vaddr to .rodata

PATCH Applied Rémi Denis-Courmont 4 participants 6 messages Mar 12, 2020 – Mar 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: move kimage_vaddr to .rodata

From: Remi Denis-Courmont <[email protected]>

This datum is not referenced from .idmap.text: it does not need to be mapped in idmap. Lets move it to .rodata as it is never written to after early boot of the primary CPU.
(Maybe .data.ro_after_init would be cleaner though?)

---
 arch/arm64/kernel/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/arm64/kernel/head.S +7 -5
index 6e08ee2b4d55..8e5c0e0040e4 100644
@@ -457,17 +457,19 @@ SYM_FUNC_START_LOCAL(__primary_switched)
 	b	start_kernel
 SYM_FUNC_END(__primary_switched)
 
+	.pushsection ".rodata", "a"
+SYM_DATA_START(kimage_vaddr)
+	.quad		_text - TEXT_OFFSET
+SYM_DATA_END(kimage_vaddr)
+EXPORT_SYMBOL(kimage_vaddr)
+	.popsection
+
 /*
  * end early head section, begin head code that is also used for
  * hotplug and needs to have the same protections as the text region
  */
 	.section ".idmap.text","awx"
 
-SYM_DATA_START(kimage_vaddr)
-	.quad		_text - TEXT_OFFSET
-SYM_DATA_END(kimage_vaddr)
-EXPORT_SYMBOL(kimage_vaddr)
-
 /*
  * If we're fortunate enough to boot at EL2, ensure that the world is
  * sane before dropping to EL1.
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
reviewer
#1 lore raw
Quoted 6 lines · Rémi Denis-Courmont

From: Remi Denis-Courmont <[email protected]>

This datum is not referenced from .idmap.text: it does not need to be mapped in idmap. Lets move it to .rodata as it is never written to after early boot of the primary CPU.
(Maybe .data.ro_after_init would be cleaner though?)

Can we move this into arch/arm64/mm/mmu.c, where we already have kimage_voffset:

| u64 kimage_voffset __ro_after_init;
| EXPORT_SYMBOL(kimage_voffset);

... or is it not possible to initialize kimage_vaddr correctly in C?

Thanks,
Mark.

Quoted 43 lines
---
 arch/arm64/kernel/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/arm64/kernel/head.S +7 -5
index 6e08ee2b4d55..8e5c0e0040e4 100644
@@ -457,17 +457,19 @@ SYM_FUNC_START_LOCAL(__primary_switched)
 	b	start_kernel
 SYM_FUNC_END(__primary_switched)
 
+	.pushsection ".rodata", "a"
+SYM_DATA_START(kimage_vaddr)
+	.quad		_text - TEXT_OFFSET
+SYM_DATA_END(kimage_vaddr)
+EXPORT_SYMBOL(kimage_vaddr)
+	.popsection
+
 /*
  * end early head section, begin head code that is also used for
  * hotplug and needs to have the same protections as the text region
  */
 	.section ".idmap.text","awx"
 
-SYM_DATA_START(kimage_vaddr)
-	.quad		_text - TEXT_OFFSET
-SYM_DATA_END(kimage_vaddr)
-EXPORT_SYMBOL(kimage_vaddr)
-
 /*
  * If we're fortunate enough to boot at EL2, ensure that the world is
  * sane before dropping to EL1.
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

#2 lore raw

Le 2020-03-12 18:40, Mark Rutland a écrit :

Quoted 8 lines · Rémi Denis-Courmont
Quoted 6 lines

From: Remi Denis-Courmont <[email protected]>

This datum is not referenced from .idmap.text: it does not need to be mapped in idmap. Lets move it to .rodata as it is never written to after early boot of the primary CPU.
(Maybe .data.ro_after_init would be cleaner though?)

Quoted 7 lines

Can we move this into arch/arm64/mm/mmu.c, where we already have kimage_voffset:

| u64 kimage_voffset __ro_after_init;
| EXPORT_SYMBOL(kimage_voffset);

... or is it not possible to initialize kimage_vaddr correctly in C?

Good question... I'll check tomorrow.

Signature · 1 line
Rémi Denis-Courmont
#3 lore raw
In reply to Mark Rutland
Quoted 8 lines · Le torstaina 12. maaliskuuta 2020, 18.40.36 EET Mark Rutland a écrit :
Quoted 6 lines · Rémi Denis-Courmont

From: Remi Denis-Courmont <[email protected]>

This datum is not referenced from .idmap.text: it does not need to be mapped in idmap. Lets move it to .rodata as it is never written to after early boot of the primary CPU.
(Maybe .data.ro_after_init would be cleaner though?)

Quoted 7 lines

Can we move this into arch/arm64/mm/mmu.c, where we already have

kimage_voffset:
| u64 kimage_voffset __ro_after_init;
| EXPORT_SYMBOL(kimage_voffset);

... or is it not possible to initialize kimage_vaddr correctly in C?

Currently TEXT_OFFSET is defined by the Makefile only for assembler sources and the linker script. So that would need to be exposed to CPPFLAGS as well.

Signature · 2 lines
Реми Дёни-Курмон
http://www.remlab.net/
maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Rémi Denis-Courmont
Quoted 27 lines · Rémi Denis-Courmont

From: Remi Denis-Courmont <[email protected]>

This datum is not referenced from .idmap.text: it does not need to be mapped in idmap. Lets move it to .rodata as it is never written to after early boot of the primary CPU.
(Maybe .data.ro_after_init would be cleaner though?)

---
 arch/arm64/kernel/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/arm64/kernel/head.S +7 -0
index 6e08ee2b4d55..8e5c0e0040e4 100644
@@ -457,17 +457,19 @@ SYM_FUNC_START_LOCAL(__primary_switched)
 	b	start_kernel
 SYM_FUNC_END(__primary_switched)
 
+	.pushsection ".rodata", "a"
+SYM_DATA_START(kimage_vaddr)
+	.quad		_text - TEXT_OFFSET
+SYM_DATA_END(kimage_vaddr)
+EXPORT_SYMBOL(kimage_vaddr)
+	.popsection
+

arch/arm64/kernel/head.S SYM_FUNC_START_LOCAL(__primary_switched) · line 469

Quoted 10 lines
arch/arm64/kernel/head.S +0 -4
 /*
  * end early head section, begin head code that is also used for
  * hotplug and needs to have the same protections as the text region
  */
 	.section ".idmap.text","awx"
 
-SYM_DATA_START(kimage_vaddr)
-	.quad		_text - TEXT_OFFSET
-SYM_DATA_END(kimage_vaddr)
-EXPORT_SYMBOL(kimage_vaddr)

Will

maintainer Applied
#5 lore raw
In reply to Rémi Denis-Courmont
Quoted 8 lines · Rémi Denis-Courmont

From: Remi Denis-Courmont <[email protected]>

This datum is not referenced from .idmap.text: it does not need to be mapped in idmap. Lets move it to .rodata as it is never written to after early boot of the primary CPU.
(Maybe .data.ro_after_init would be cleaner though?)

Queued for 5.7. Thanks.

Signature · 5 lines
Catalin
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm