From 86d37bbd7ddf44430eb63ac521261f2fa11733b0 Mon Sep 17 00:00:00 2001 From: Damien Le Moal <damien.lemoal@wdc.com> Date: Thu, 12 Mar 2020 14:20:37 +0900 Subject: lib: sbi: Fix misaligned trap handling Compile time checks of __riscv_compressed can only check if OpenSBI is being compiled using compressed instructions or not. Checking this macro does not indicate if an instruction that generated a misaligned trap is a compressed instruction or not. Since the misaligned trap handling code inspects instructions _C_ bits to detect compressed instructions, we can remove all static checks on __riscv_compressed and dissociate hanlding of misaligned traps and OpenSBI compilation. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> --- lib/sbi/sbi_misaligned_ldst.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/sbi/sbi_misaligned_ldst.c b/lib/sbi/sbi_misaligned_ldst.c index 400372c..b59efa0 100644 --- a/lib/sbi/sbi_misaligned_ldst.c +++ b/lib/sbi/sbi_misaligned_ldst.c @@ -72,7 +72,6 @@ int sbi_misaligned_load_handler(u32 hartid, ulong mcause, shift = 8 * (sizeof(ulong) - len); } else if ((insn & INSN_MASK_LHU) == INSN_MATCH_LHU) { len = 2; -#ifdef __riscv_compressed #if __riscv_xlen >= 64 } else if ((insn & INSN_MASK_C_LD) == INSN_MATCH_C_LD) { len = 8; @@ -108,7 +107,6 @@ int sbi_misaligned_load_handler(u32 hartid, ulong mcause, fp = 1; len = 4; #endif -#endif #endif } else { uptrap.epc = regs->mepc; @@ -189,7 +187,6 @@ int sbi_misaligned_store_handler(u32 hartid, ulong mcause, #endif } else if ((insn & INSN_MASK_SH) == INSN_MATCH_SH) { len = 2; -#ifdef __riscv_compressed #if __riscv_xlen >= 64 } else if ((insn & INSN_MASK_C_SD) == INSN_MATCH_C_SD) { len = 8; @@ -221,7 +218,6 @@ int sbi_misaligned_store_handler(u32 hartid, ulong mcause, len = 4; val.data_ulong = GET_F32_RS2C(insn, regs); #endif -#endif #endif } else { uptrap.epc = regs->mepc; -- cgit v1.2.3