diff options
author | Zong Li <zong.li@sifive.com> | 2020-03-10 00:55:42 +0800 |
---|---|---|
committer | Palmer Dabbelt <palmerdabbelt@google.com> | 2020-03-26 09:24:49 -0700 |
commit | b42d763a2d412d6ef7c29cb2f1b3e9985e2b1e38 (patch) | |
tree | ec1aaa9c051806f02bf08ae62e66a93302b3c64a /arch/riscv/include/asm/bug.h | |
parent | d27c3c90817e4c5ea655714065a725b4abd576f9 (diff) |
riscv: add macro to get instruction length
Extract the calculation of instruction length for common use.
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch/riscv/include/asm/bug.h')
-rw-r--r-- | arch/riscv/include/asm/bug.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h index 75604fec1b1b..d6f1ec08d97b 100644 --- a/arch/riscv/include/asm/bug.h +++ b/arch/riscv/include/asm/bug.h @@ -19,6 +19,14 @@ #define __BUG_INSN_32 _UL(0x00100073) /* ebreak */ #define __BUG_INSN_16 _UL(0x9002) /* c.ebreak */ +#define GET_INSN_LENGTH(insn) \ +({ \ + unsigned long __len; \ + __len = ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? \ + 4UL : 2UL; \ + __len; \ +}) + typedef u32 bug_insn_t; #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS |