[RFC PATCH 1/2] riscv: lib: Give the scalar memcpy() body a symbol of its own
From: Cong Wang
Date: Tue Dec 01 2026 - 23:03:55 EST
From: Cong Wang <cwang@xxxxxxxxxxxxxx>
memcpy() and __memcpy() are about to become an entry point that may hand
large copies to a vector routine. Three users must keep reaching the
scalar code directly: the purgatory, which builds memcpy.S into an image
with no kernel symbols and no alternatives patching, the __pi_ aliases
used by position independent early boot code, and the fallback of the
vector routine itself.
Name the scalar body __memcpy_scalar and make the existing names aliases
of it. No functional change.
Signed-off-by: Cong Wang <cwang@xxxxxxxxxxxxxx>
Reviewed-by: Troy Mitchell <troy@xxxxxxxxxx>
---
arch/riscv/lib/memcpy.S | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S
index 44e009ec5fef..6f1d3681fecf 100644
--- a/arch/riscv/lib/memcpy.S
+++ b/arch/riscv/lib/memcpy.S
@@ -7,7 +7,7 @@
#include <asm/asm.h>
/* void *memcpy(void *, const void *, size_t) */
-SYM_FUNC_START(__memcpy)
+SYM_FUNC_START(__memcpy_scalar)
move t6, a0 /* Preserve return value */
/* Defer to byte-oriented copy for small sizes */
@@ -104,7 +104,8 @@ SYM_FUNC_START(__memcpy)
bltu a1, a3, 5b
6:
ret
-SYM_FUNC_END(__memcpy)
+SYM_FUNC_END(__memcpy_scalar)
+SYM_FUNC_ALIAS(__memcpy, __memcpy_scalar)
SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy)
-SYM_FUNC_ALIAS(__pi_memcpy, __memcpy)
-SYM_FUNC_ALIAS(__pi___memcpy, __memcpy)
+SYM_FUNC_ALIAS(__pi_memcpy, __memcpy_scalar)
+SYM_FUNC_ALIAS(__pi___memcpy, __memcpy_scalar)
--
2.43.0