[PATCH 03/11] riscv: indirect jmp in asm that's static in nature to use sw guarded jump
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Thu Jul 24 23:26:39 PDT 2025
On 25.07.25 01:36, Deepak Gupta wrote:
> Handwritten `__memset` asm routine perform static jumps within
> function and uses `a5` to do that. This would require a landing pad
> instruction at the target. Since its static jump and no memory load is
> involved, use `t2` instead which is exempt from requiring a landing pad.
>
> Signed-off-by: Deepak Gupta <debug at rivosinc.com>
Acked-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
> ---
> arch/riscv/lib/memset.S | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/lib/memset.S b/arch/riscv/lib/memset.S
> index da23b8347e2d..c4a318d8eef3 100644
> --- a/arch/riscv/lib/memset.S
> +++ b/arch/riscv/lib/memset.S
> @@ -56,12 +56,12 @@ SYM_FUNC_START(__memset)
>
> /* Jump into loop body */
> /* Assumes 32-bit instruction lengths */
> - la a5, 3f
> + la t2, 3f
> #ifdef CONFIG_64BIT
> srli a4, a4, 1
> #endif
> - add a5, a5, a4
> - jr a5
> + add t2, t2, a4
> + jr t2
> 3:
> REG_S a1, 0(t0)
> REG_S a1, SZREG(t0)
>
More information about the linux-riscv
mailing list