diff mbox series

[RFC,14/15] riscv: ftrace big endian updates

Message ID 20241220155801.1988785-15-ben.dooks@codethink.co.uk (mailing list archive)
State New
Headers show
Series [RFC,01/15] riscv: add initial kconfig and build flags for big-endian | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Ben Dooks Dec. 20, 2024, 3:58 p.m. UTC
Make the ftrace code work with big endian by ensuring the
instruction stream is accessed little endian.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/riscv/include/asm/ftrace.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h
index 2cddd79ff21b..233428aeab1d 100644
--- a/arch/riscv/include/asm/ftrace.h
+++ b/arch/riscv/include/asm/ftrace.h
@@ -79,7 +79,7 @@  struct dyn_arch_ftrace {
 #define AUIPC_RA		(0x00000097)
 #define JALR_T0			(0x000282e7)
 #define AUIPC_T0		(0x00000297)
-#define NOP4			(0x00000013)
+#define NOP4			(le32_to_cpu(0x00000013))
 
 #define to_jalr_t0(offset)						\
 	(((offset & JALR_OFFSET_MASK) << JALR_SHIFT) | JALR_T0)
@@ -93,8 +93,8 @@  struct dyn_arch_ftrace {
 do {									\
 	unsigned int offset =						\
 		(unsigned long) callee - (unsigned long) caller;	\
-	call[0] = to_auipc_t0(offset);					\
-	call[1] = to_jalr_t0(offset);					\
+	call[0] = cpu_to_le32(to_auipc_t0(offset));			\
+	call[1] = cpu_to_le32(to_jalr_t0(offset));			\
 } while (0)
 
 #define to_jalr_ra(offset)						\
@@ -109,8 +109,8 @@  do {									\
 do {									\
 	unsigned int offset =						\
 		(unsigned long) callee - (unsigned long) caller;	\
-	call[0] = to_auipc_ra(offset);					\
-	call[1] = to_jalr_ra(offset);					\
+	call[0] = cpu_to_le32(to_auipc_ra(offset));			\
+	call[1] = cpu_to_le32(to_jalr_ra(offset));			\
 } while (0)
 
 /*