Skip to contentSkip to conversation

riscv: Set text_offset correctly for M-Mode

PATCH Superseded Sean Anderson 2 participants 3 messages Oct 17, 2020 – Oct 22, 2020 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Set text_offset correctly for M-Mode

M-Mode Linux is loaded at the start of RAM, not 2MB later. Perhaps this should be calculated based on PAGE_OFFSET somehow? Even better would be to deprecate text_offset and instead introduce something absolute.

---

 arch/riscv/kernel/head.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/riscv/kernel/head.S +5 -0
index 0a4e81b8dc79..74679f338c65 100644
@@ -27,12 +27,17 @@ ENTRY(_start)
 	/* reserved */
 	.word 0
 	.balign 8
+#ifdef CONFIG_RISCV_S_MODE
 #if __riscv_xlen == 64
 	/* Image load offset(2MB) from start of RAM */
 	.dword 0x200000
 #else
 	/* Image load offset(4MB) from start of RAM */
 	.dword 0x400000
+#endif
+#else
+	/* Image load offset (0MB) from start of RAM for M-mode */
+	.dword 0
 #endif
 	/* Effective size of kernel image */
 	.dword _end - _start
Signature · 7 lines
2.28.0


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw
Quoted 15 lines · Sean Anderson

M-Mode Linux is loaded at the start of RAM, not 2MB later. Perhaps this should be calculated based on PAGE_OFFSET somehow? Even better would be to deprecate text_offset and instead introduce something absolute.

---

 arch/riscv/kernel/head.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/riscv/kernel/head.S +0 -0
index 0a4e81b8dc79..74679f338c65 100644

arch/riscv/kernel/head.S ENTRY(_start) · line 30

Quoted 4 lines
arch/riscv/kernel/head.S +1 -0
@@ -27,12 +27,17 @@ ENTRY(_start)
 	/* reserved */
 	.word 0
 	.balign 8
+#ifdef CONFIG_RISCV_S_MODE

Shouldn't this be:

#ifndef CONFIG_RISCV_M_MODE

CONFIG_RISCV_S_MODE does not exist.

Quoted 4 lines
arch/riscv/kernel/head.S +0 -0
 #if __riscv_xlen == 64
 	/* Image load offset(2MB) from start of RAM */
 	.dword 0x200000

arch/riscv/kernel/head.S ENTRY(_start) · line 43

Quoted 10 lines
arch/riscv/kernel/head.S +4 -0
 #else
 	/* Image load offset(4MB) from start of RAM */
 	.dword 0x400000
+#endif
+#else
+	/* Image load offset (0MB) from start of RAM for M-mode */
+	.dword 0
 #endif
 	/* Effective size of kernel image */
 	.dword _end - _start

Otherwise, looks good to me.

Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw
Quoted 27 lines · Damien Le Moal
Quoted 15 lines · Sean Anderson

M-Mode Linux is loaded at the start of RAM, not 2MB later. Perhaps this should be calculated based on PAGE_OFFSET somehow? Even better would be to deprecate text_offset and instead introduce something absolute.

---

 arch/riscv/kernel/head.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/riscv/kernel/head.S +0 -0
index 0a4e81b8dc79..74679f338c65 100644

arch/riscv/kernel/head.S ENTRY(_start) · line 30

Quoted 4 lines
arch/riscv/kernel/head.S +1 -0
@@ -27,12 +27,17 @@ ENTRY(_start)
 	/* reserved */
 	.word 0
 	.balign 8
+#ifdef CONFIG_RISCV_S_MODE

Shouldn't this be:

#ifndef CONFIG_RISCV_M_MODE

CONFIG_RISCV_S_MODE does not exist.

Quoted 17 lines
Quoted 4 lines
arch/riscv/kernel/head.S +0 -0
 #if __riscv_xlen == 64
 	/* Image load offset(2MB) from start of RAM */
 	.dword 0x200000

arch/riscv/kernel/head.S ENTRY(_start) · line 43

Quoted 10 lines
arch/riscv/kernel/head.S +4 -0
 #else
 	/* Image load offset(4MB) from start of RAM */
 	.dword 0x400000
+#endif
+#else
+	/* Image load offset (0MB) from start of RAM for M-mode */
+	.dword 0
 #endif
 	/* Effective size of kernel image */
 	.dword _end - _start

Otherwise, looks good to me.

Thanks for spotting that. Should be fixed in v2.

--Sean

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