[PATCH v3] riscv: misaligned: Restore epc in error path
Maciej W. Rozycki
macro at orcam.me.uk
Tue May 12 19:13:55 PDT 2026
On Mon, 11 May 2026, Zishun Yi wrote:
> diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
> index 2a27d3ff4ac6..21a3ceb1fae8 100644
> --- a/arch/riscv/kernel/traps_misaligned.c
> +++ b/arch/riscv/kernel/traps_misaligned.c
> @@ -303,17 +304,18 @@ 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;
> + goto out_restore_epc;
> }
>
> - if (!IS_ENABLED(CONFIG_FPU) && fp)
> - return -EOPNOTSUPP;
> + if (!IS_ENABLED(CONFIG_FPU) && fp) {
> + ret = -EOPNOTSUPP;
> + goto out_restore_epc;
> + }
Does it make sense to maintain this -EOPNOTSUPP special case given that
this function does not otherwise make use of error numbers and the caller
only checks whether the return value is nonzero? Likewise for the store.
Maciej
More information about the linux-riscv
mailing list