[PATCH] riscv: entry: Save a0 prior syscall_enter_from_user_mode()

Geert Uytterhoeven geert at linux-m68k.org
Tue Apr 4 08:06:35 PDT 2023


On Mon, Apr 3, 2023 at 8:54 AM Björn Töpel <bjorn at kernel.org> wrote:
> From: Björn Töpel <bjorn at rivosinc.com>
>
> The RISC-V calling convention passes the first argument, and the
> return value in the a0 register. For this reason, the a0 register
> needs some extra care; When handling syscalls, the a0 register is
> saved into regs->orig_a0, so a0 can be properly restored for,
> e.g. interrupted syscalls.
>
> This functionality was broken with the introduction of the generic
> entry patches. Here, a0 was saved into orig_a0 after calling
> syscall_enter_from_user_mode(), which can change regs->a0 for some
> paths, incorrectly restoring a0.
>
> This is resolved, by saving a0 prior doing the
> syscall_enter_from_user_mode() call.
>
> Fixes: f0bddf50586d ("riscv: entry: Convert to generic entry")
> Reviewed-by: Heiko Stuebner <heiko.stuebner at vrull.eu>
> Tested-by: Heiko Stuebner <heiko.stuebner at vrull.eu>
> Signed-off-by: Björn Töpel <bjorn at rivosinc.com>

Tested-by: Geert Uytterhoeven <geert+renesas at glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



More information about the linux-riscv mailing list