Skip to contentSkip to conversation

riscv/purgatory: align riscv_kernel_entry

PATCH Superseded Daniel Maslowski 7 participants 7 messages Jul 16, 2024 – Jul 22, 2024 RISC-V

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 riscv/purgatory: align riscv_kernel_entry

When alignment handling is delegated to the kernel, everything must be word-aligned in purgatory, since the trap handler is then set to the kexec one. Without the alignment, hitting the exception would ultimately crash. On other occasions, the kernel's handler would take care of exceptions.
This has been tested on a JH7110 SoC with oreboot and its SBI delegating unaligned access exceptions and the kernel configured to handle them.

Fixes 736e30af583fb6e0e2b8211b894ff99dea0f1ee7
---
 arch/riscv/purgatory/entry.S | 2 ++
 1 file changed, 2 insertions(+)
arch/riscv/purgatory/entry.S +2 -0
index 5bcf3af903da..0e6ca6d5ae4b 100644
@@ -7,6 +7,7 @@
  * Author: Li Zhengyu ([email protected])
  *
  */
+#include <asm/asm.h>
 #include <linux/linkage.h>
 
 .text
@@ -34,6 +35,7 @@ SYM_CODE_END(purgatory_start)
 
 .data
 
+.align LGREG
 SYM_DATA(riscv_kernel_entry, .quad 0)
 
 .end
Signature · 7 lines
2.45.2


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

When alignment handling is delegated to the kernel, everything must be word-aligned in purgatory, since the trap handler is then set to the kexec one. Without the alignment, hitting the exception would ultimately crash. On other occasions, the kernel's handler would take care of exceptions.
This has been tested on a JH7110 SoC with oreboot and its SBI delegating unaligned access exceptions and the kernel configured to handle them.

Fixes 736e30af583fb6e0e2b8211b894ff99dea0f1ee7

---
arch/riscv/purgatory/entry.S | 2 ++

1 file changed, 2 insertions(+)
arch/riscv/purgatory/entry.S +1 -0
index 5bcf3af903da..0e6ca6d5ae4b 100644
@@ -7,6 +7,7 @@
 * Author: Li Zhengyu ([email protected])
 *
 */
+#include <asm/asm.h>
 #include <linux/linkage.h>
 

.text

arch/riscv/purgatory/entry.S +0 -0
@@ -34,6 +35,7 @@ SYM_CODE_END(purgatory_start)
 

.data

Quoted 2 lines

+.align LGREG
SYM_DATA(riscv_kernel_entry, .quad 0)

It’s a bit weird to use LGREG for a .quad. The file is RV64-only already, anyway.

Jess

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

#2 lore raw
In reply to Daniel Maslowski
Quoted 1 line · Daniel Maslowski

This has been tested on a JH7110 SoC with oreboot and its SBI delegating

coreboot?

Signature · 8 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

Hi Conor,

Quoted 8 lines · Conor Dooley
Quoted 5 lines · Andreas Schwab
Quoted 1 line · Daniel Maslowski

This has been tested on a JH7110 SoC with oreboot and its SBI delegating

coreboot?

oreboot is coreboot without the c :)

At first I thought this was just a joke about a typo...

Quoted 1 line

https://github.com/oreboot/oreboot

Given it's mainly written in Rust, perhaps it should have been called roreboot? Or roarboot? ;-)

Gr{oetje,eeting}s,

Geert

Signature · 10 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#5 lore raw
In reply to Daniel Maslowski
Quoted 9 lines · Daniel Maslowski

When alignment handling is delegated to the kernel, everything must be word-aligned in purgatory, since the trap handler is then set to the kexec one. Without the alignment, hitting the exception would ultimately crash. On other occasions, the kernel's handler would take care of exceptions.
This has been tested on a JH7110 SoC with oreboot and its SBI delegating unaligned access exceptions and the kernel configured to handle them.

Fixes 736e30af583fb6e0e2b8211b894ff99dea0f1ee7

Should be:

Fixes 736e30af583fb ("RISC-V: Add purgatory")

Regards,
Matthias

Quoted 33 lines
---
 arch/riscv/purgatory/entry.S | 2 ++
 1 file changed, 2 insertions(+)
arch/riscv/purgatory/entry.S +2 -0
index 5bcf3af903da..0e6ca6d5ae4b 100644
@@ -7,6 +7,7 @@
  * Author: Li Zhengyu ([email protected])
  *
  */
+#include <asm/asm.h>
 #include <linux/linkage.h>
 
 .text
@@ -34,6 +35,7 @@ SYM_CODE_END(purgatory_start)
 
 .data
 
+.align LGREG
 SYM_DATA(riscv_kernel_entry, .quad 0)
 
 .end
Signature · 7 lines
2.45.2


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

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

reviewer Reviewed-by on v2 1/1
#6 lore raw
In reply to Daniel Maslowski

Hi Daniel,

Quoted 27 lines · Daniel Maslowski

When alignment handling is delegated to the kernel, everything must be word-aligned in purgatory, since the trap handler is then set to the kexec one. Without the alignment, hitting the exception would ultimately crash. On other occasions, the kernel's handler would take care of exceptions.
This has been tested on a JH7110 SoC with oreboot and its SBI delegating unaligned access exceptions and the kernel configured to handle them.

Fixes 736e30af583fb6e0e2b8211b894ff99dea0f1ee7
---
  arch/riscv/purgatory/entry.S | 2 ++
  1 file changed, 2 insertions(+)
arch/riscv/purgatory/entry.S +1 -0
index 5bcf3af903da..0e6ca6d5ae4b 100644
@@ -7,6 +7,7 @@
   * Author: Li Zhengyu ([email protected])
   *
   */
+#include <asm/asm.h>
  #include <linux/linkage.h>
 
  .text

arch/riscv/purgatory/entry.S SYM_CODE_END(purgatory_start) · line 41

Quoted 7 lines
arch/riscv/purgatory/entry.S +1 -0
@@ -34,6 +35,7 @@ SYM_CODE_END(purgatory_start)
 
  .data
 
+.align LGREG
  SYM_DATA(riscv_kernel_entry, .quad 0)
 
  .end

With the Fixes tag fixed like Matthias suggested, you can add:

Thanks,

Alex

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