Skip to content

Commit 4fba171

Browse files
Michael Karcherandreas-gaisler
authored andcommitted
sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC
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: cb736fd ("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>
1 parent 7205ef7 commit 4fba171

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

arch/sparc/lib/U1memcpy.S

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,18 @@ ENTRY(U1_gs_40_fp)
164164
retl
165165
add %o0, %o2, %o0
166166
ENDPROC(U1_gs_40_fp)
167-
ENTRY(U1_g3_0_fp)
168-
VISExitHalf
169-
retl
170-
add %g3, %o2, %o0
171-
ENDPROC(U1_g3_0_fp)
172167
ENTRY(U1_g3_8_fp)
173168
VISExitHalf
174169
add %g3, 8, %g3
175170
retl
176171
add %g3, %o2, %o0
177172
ENDPROC(U1_g3_8_fp)
173+
ENTRY(U1_g3_16_fp)
174+
VISExitHalf
175+
add %g3, 16, %g3
176+
retl
177+
add %g3, %o2, %o0
178+
ENDPROC(U1_g3_16_fp)
178179
ENTRY(U1_o2_0_fp)
179180
VISExitHalf
180181
retl
@@ -547,18 +548,18 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
547548
62: FINISH_VISCHUNK(o0, f44, f46)
548549
63: UNEVEN_VISCHUNK_LAST(o0, f46, f0)
549550

550-
93: EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_0_fp)
551+
93: EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_8_fp)
551552
add %o1, 8, %o1
552553
subcc %g3, 8, %g3
553554
faligndata %f0, %f2, %f8
554-
EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
555+
EX_ST_FP(STORE(std, %f8, %o0), U1_g3_16_fp)
555556
bl,pn %xcc, 95f
556557
add %o0, 8, %o0
557-
EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_0_fp)
558+
EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_8_fp)
558559
add %o1, 8, %o1
559560
subcc %g3, 8, %g3
560561
faligndata %f2, %f0, %f8
561-
EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
562+
EX_ST_FP(STORE(std, %f8, %o0), U1_g3_16_fp)
562563
bge,pt %xcc, 93b
563564
add %o0, 8, %o0
564565

0 commit comments

Comments
 (0)