From b752bc99c6a687a8f6dcd9ff8f00a024c021899a Mon Sep 17 00:00:00 2001 From: gaorui Date: Wed, 3 Sep 2025 15:44:14 +0800 Subject: [PATCH 1/2] riscv: uaccess: Allow the last potential unrolled copy mainline inclusion from mainline-v6.10-rc1 commit f1905946bed052522522303f1d144f506ef5d9f9 category: feature bugzilla: https://github.com/RVCK-Project/rvck/issues/112 -------------------------------- When the dst buffer pointer points to the last accessible aligned addr, we could still run another iteration of unrolled copy. Signed-off-by: Xiao Wang Reviewed-by: Alexandre Ghiti Link: https://lore.kernel.org/r/20240313103334.4036554-1-xiao.w.wang@intel.com Signed-off-by: Palmer Dabbelt Signed-off-by: gaorui --- arch/riscv/lib/uaccess.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 09b47ebacf2e8..1f14b0d874ca9 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -95,7 +95,7 @@ ENTRY(__asm_copy_from_user) fixup REG_S t4, 7*SZREG(a0), 10f addi a0, a0, 8*SZREG addi a1, a1, 8*SZREG - bltu a0, t0, 2b + bleu a0, t0, 2b addi t0, t0, 8*SZREG /* revert to original value */ j .Lbyte_copy_tail From 90bffeae0693025c9fa41d743837b60a21d28672 Mon Sep 17 00:00:00 2001 From: gaorui Date: Wed, 3 Sep 2025 15:22:48 +0800 Subject: [PATCH 2/2] riscv: uaccess: Relax the threshold for fast path mainline inclusion from mainline-v6.10-rc1 commit 9850e73e82972f518b75dd0d94d2322f44d9191d category: feature bugzilla: https://github.com/RVCK-Project/rvck/issues/112 -------------------------------- The bytes copy for unaligned head would cover at most SZREG-1 bytes, so it's better to set the threshold as >= (SZREG-1 + word_copy stride size) which equals to 9*SZREG-1. Signed-off-by: Xiao Wang Reviewed-by: Alexandre Ghiti Link: https://lore.kernel.org/r/20240313091929.4029960-1-xiao.w.wang@intel.com Signed-off-by: Palmer Dabbelt Signed-off-by: gaorui --- arch/riscv/lib/uaccess.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 1f14b0d874ca9..f4500f9584729 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -36,7 +36,7 @@ ENTRY(__asm_copy_from_user) * Use byte copy only if too small. * SZREG holds 4 for RV32 and 8 for RV64 */ - li a3, 9*SZREG /* size must be larger than size in word_copy */ + li a3, 9*SZREG-1 /* size must >= (word_copy stride + SZREG-1) */ bltu a2, a3, .Lbyte_copy_tail /*