All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v3 1/2] riscv: Add RV_INSN_LEN to processor.h
@ 2025-06-05 16:18 ` Jesse Taube
  0 siblings, 0 replies; 10+ messages in thread
From: Jesse Taube @ 2025-06-05 16:18 UTC (permalink / raw)
  To: kvm, kvm-riscv, linux-kselftest
  Cc: Atish Patra, Anup Patel, Palmer Dabbelt, Clément Léger,
	Himanshu Chauhan, Charlie Jenkins, Jesse Taube, Andrew Jones

When handeling traps and faults it is offten necessary to know the size
of the instruction at epc. Add RV_INSN_LEN to calculate the
instruction size.

Signed-off-by: Jesse Taube <jesse@rivosinc.com>
---
 lib/riscv/asm/processor.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/riscv/asm/processor.h b/lib/riscv/asm/processor.h
index 40104272..631ce226 100644
--- a/lib/riscv/asm/processor.h
+++ b/lib/riscv/asm/processor.h
@@ -7,6 +7,8 @@
 #define EXCEPTION_CAUSE_MAX	24
 #define INTERRUPT_CAUSE_MAX	16
 
+#define RV_INSN_LEN(insn)		((((insn) & 0x3) < 0x3) ? 2 : 4)
+
 typedef void (*exception_fn)(struct pt_regs *);
 
 struct thread_info {
-- 
2.43.0


-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-07-02 15:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05 16:18 [kvm-unit-tests PATCH v3 1/2] riscv: Add RV_INSN_LEN to processor.h Jesse Taube
2025-06-05 16:18 ` Jesse Taube
2025-06-05 16:18 ` [kvm-unit-tests PATCH v3 2/2] riscv: sbi: Add SBI Debug Triggers Extension tests Jesse Taube
2025-06-05 16:18   ` Jesse Taube
2025-06-06  8:48   ` Andrew Jones
2025-06-06  8:48     ` Andrew Jones
2025-06-06  8:32 ` [kvm-unit-tests PATCH v3 1/2] riscv: Add RV_INSN_LEN to processor.h Andrew Jones
2025-06-06  8:32   ` Andrew Jones
2025-07-02 14:49 ` Andrew Jones
2025-07-02 14:49   ` Andrew Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.