]> www.infradead.org Git - users/hch/misc.git/commitdiff
sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC
authorMichael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Thu, 4 Sep 2025 22:03:30 +0000 (00:03 +0200)
committerAndreas Larsson <andreas@gaisler.com>
Fri, 19 Sep 2025 18:56:36 +0000 (20:56 +0200)
The referenced commit introduced exception handlers on user-space memory
references in copy_from_user and copy_to_user. These handlers return from
the respective function and calculate the remaining bytes left to copy
using the current register contents. This commit fixes a couple of bad
calculations. This will fix the return value of copy_from_user and
copy_to_user in the faulting case. The behaviour of memcpy stays unchanged.

Fixes: cb736fdbb208 ("sparc64: Convert U1copy_{from,to}_user to accurate exception reporting.")
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> # on QEMU 10.0.3
Tested-by: René Rebe <rene@exactcode.com> # on Ultra 5 UltraSparc IIi
Tested-by: Jonathan 'theJPster' Pallant <kernel@thejpster.org.uk> # on Sun Netra T1
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Link: https://lore.kernel.org/r/20250905-memcpy_series-v4-1-1ca72dda195b@mkarcher.dialup.fu-berlin.de
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
arch/sparc/lib/U1memcpy.S

index 635398ec7540ee3d344151ddc4c6f07ad41e11f9..154fbd35400ca8fe547c222d26aec18f46fcb1d2 100644 (file)
@@ -164,17 +164,18 @@ ENTRY(U1_gs_40_fp)
        retl
         add            %o0, %o2, %o0
 ENDPROC(U1_gs_40_fp)
-ENTRY(U1_g3_0_fp)
-       VISExitHalf
-       retl
-        add            %g3, %o2, %o0
-ENDPROC(U1_g3_0_fp)
 ENTRY(U1_g3_8_fp)
        VISExitHalf
        add             %g3, 8, %g3
        retl
         add            %g3, %o2, %o0
 ENDPROC(U1_g3_8_fp)
+ENTRY(U1_g3_16_fp)
+       VISExitHalf
+       add             %g3, 16, %g3
+       retl
+        add            %g3, %o2, %o0
+ENDPROC(U1_g3_16_fp)
 ENTRY(U1_o2_0_fp)
        VISExitHalf
        retl
@@ -547,18 +548,18 @@ FUNC_NAME:                /* %o0=dst, %o1=src, %o2=len */
 62:    FINISH_VISCHUNK(o0, f44, f46)
 63:    UNEVEN_VISCHUNK_LAST(o0, f46, f0)
 
-93:    EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_0_fp)
+93:    EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_8_fp)
        add             %o1, 8, %o1
        subcc           %g3, 8, %g3
        faligndata      %f0, %f2, %f8
-       EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
+       EX_ST_FP(STORE(std, %f8, %o0), U1_g3_16_fp)
        bl,pn           %xcc, 95f
         add            %o0, 8, %o0
-       EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_0_fp)
+       EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_8_fp)
        add             %o1, 8, %o1
        subcc           %g3, 8, %g3
        faligndata      %f2, %f0, %f8
-       EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
+       EX_ST_FP(STORE(std, %f8, %o0), U1_g3_16_fp)
        bge,pt          %xcc, 93b
         add            %o0, 8, %o0