[RFC PATCH 02/18] arm64: align kernel text and rodata
From: Nikita Panov
Date: Thu Aug 27 2026 - 12:26:03 EST
In order to comply with AArch64 page table entries type -
table and block descriptor format, we need to use correct alignment
for replicated memory areas. Physical blocks allocated for replicated areas
must have the same offset for all replicas and same relative offset
to the virtual address.
For simplicity, we just use an explicit alignment for kernel sections.
If 4K pages are used, 2MB alignment should be applied.
Otherwise CONT_PTE_SIZE alignment is used.
Acked-by: Artem Kuzin <artem.kuzin@xxxxxxxxxx>
Acked-by: Alexander Grubnikov <alexander.grubnikov@xxxxxxxxxx>
Acked-by: Ilya Hanov <ilya.hanov@xxxxxxxxxxxxxxxxxxx>
Acked-by: Denis Darvish <darvish.denis@xxxxxxxxxx>
Signed-off-by: Nikita Panov <panov.nikita@xxxxxxxxxx>
---
arch/arm64/kernel/vmlinux.lds.S | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index af1d72020976..aaf07e926c54 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -192,6 +192,13 @@ SECTIONS
_text = .;
HEAD_TEXT
}
+#ifdef CONFIG_KERNEL_REPLICATION
+#ifdef CONFIG_ARM64_4K_PAGES
+ . = ALIGN(PMD_SIZE);
+#else
+ . = ALIGN(CONT_PTE_SIZE);
+#endif
+#endif
.text : ALIGN(SEGMENT_ALIGN) { /* Real text segment */
_stext = .; /* Text and read-only data */
IRQENTRY_TEXT
@@ -207,10 +214,25 @@ SECTIONS
}
. = ALIGN(SEGMENT_ALIGN);
+#ifdef CONFIG_KERNEL_REPLICATION
+#ifdef CONFIG_ARM64_4K_PAGES
+ . = ALIGN(PMD_SIZE);
+#else
+ . = ALIGN(CONT_PTE_SIZE);
+#endif
+#endif
_etext = .; /* End of text section */
/* everything from this point to __init_begin will be marked RO NX */
+#ifdef CONFIG_KERNEL_REPLICATION
+#ifdef CONFIG_ARM64_4K_PAGES
+ RO_DATA(PMD_SIZE)
+#else
+ RO_DATA(CONT_PTE_SIZE)
+#endif
+#else
RO_DATA(PAGE_SIZE)
+#endif
HYPERVISOR_RODATA_SECTIONS
--
2.34.1