Currently the epc is set to zero when there is a misaligned emulation
error. This will print a misleading error message with the current epc
value of zero instead of the epc value that triggered the emulation.
Avoid setting epc to zero to maintain the state of epc.

Signed-off-by: Charlie Jenkins <[email protected]>
---
 arch/riscv/kernel/traps_misaligned.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/riscv/kernel/traps_misaligned.c 
b/arch/riscv/kernel/traps_misaligned.c
index 81b7682e6c6d..524215a186e0 100644
--- a/arch/riscv/kernel/traps_misaligned.c
+++ b/arch/riscv/kernel/traps_misaligned.c
@@ -238,8 +238,6 @@ static int handle_scalar_misaligned_load(struct pt_regs 
*regs)
        if (get_insn(regs, epc, &insn))
                return -1;
 
-       regs->epc = 0;
-
        if ((insn & INSN_MASK_LW) == INSN_MATCH_LW) {
                len = 4;
                shift = 8 * (sizeof(unsigned long) - len);
@@ -303,7 +301,6 @@ static int handle_scalar_misaligned_load(struct pt_regs 
*regs)
                shift = 8 * (sizeof(ulong) - len);
                insn = RVC_RS2S(insn) << SH_RD;
        } else {
-               regs->epc = epc;
                return -1;
        }
 
@@ -349,8 +346,6 @@ static int handle_scalar_misaligned_store(struct pt_regs 
*regs)
        if (get_insn(regs, epc, &insn))
                return -1;
 
-       regs->epc = 0;
-
        val.data_ulong = GET_RS2(insn, regs);
 
        if ((insn & INSN_MASK_SW) == INSN_MATCH_SW) {
@@ -405,7 +400,6 @@ static int handle_scalar_misaligned_store(struct pt_regs 
*regs)
                len = 2;
                val.data_ulong = GET_RS2S(insn, regs);
        } else {
-               regs->epc = epc;
                return -1;
        }
 

-- 
2.54.0


Reply via email to