[PATCH RFC 15/19] riscv: Align init data to the ESP32-P4 PMP granularity

Vítor Hugo Silva vitorhg20080 at gmail.com
Wed Nov 25 15:30:16 PST 2026


ESP32-P4 has a PMP granularity of 128 bytes. The RISC-V linker
script can place __init_data_begin at a smaller alignment, so a boot
stage using that symbol to separate executable code from writable
data cannot always encode the boundary exactly.

Align __init_data_begin to 128 bytes on ESP32-P4 so PMP can apply
distinct permissions to the two regions.

Verified the alignment in an RV32 NOMMU kernel that booted to the
UART shell on a Waveshare ESP32-P4-Module-DEV-KIT.

AI assisted with preparing the patch and validating the
linker layout.

Link: https://github.com/espressif/esp-idf/blob/master/components/soc/esp32p4/include/soc/soc_caps.h#L191
Signed-off-by: Vítor Hugo Silva <vitorhg20080 at gmail.com>
---
 arch/riscv/kernel/vmlinux.lds.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 1f4f8496941a..e4498a9fdc6c 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -77,6 +77,10 @@ SECTIONS
 #ifdef CONFIG_EFI
 	. = ALIGN(PECOFF_SECTION_ALIGNMENT);
 	__pecoff_text_end = .;
+#endif
+#ifdef CONFIG_RISCV_ESP32P4_CLIC
+	/* Keep init data outside the last executable PMP granule. */
+	. = ALIGN(SZ_128);
 #endif
 	/* Start of init data section */
 	__init_data_begin = .;
-- 
2.56.1




More information about the linux-riscv mailing list