lkml.org 
[lkml]   [2024]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 05/12] riscv: fix certain indirect jumps for kernel cfi
Date
Handwritten `__memset` asm routine performs certain 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@rivosinc.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 35f358e70bdb..e129ebf66986 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)
--
2.43.2

\
 
 \ /
  Last update: 2024-05-27 16:30    [W:0.178 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site