Re: [PATCH 3/4] sparc: fix accurate exception reporting in copy_{from_to}_user for Niagara
From: Magnus Lindholm
Date: Thu Sep 04 2025 - 14:37:14 EST
I've tested this patch from on my T2000, I've booted up the ISO
https://dl.t2sde.org/binary/2025/incoming/t2-25.9-sparc64-base-wayland-glibc-gcc-ultrasparc3.iso
And have been running some "regular stuff" like unpacking files and
building some packages
with gcc. It seems to work fine. The system has been running stable
with load for some hours now
install:/etc# uname -a
Linux t2 6.16.4-t2 #1 SMP Tue Sep 2 23:17:46 CEST 2025 sparc64 GNU/Linux
install:/etc# cat /proc/cpuinfo
cpu : UltraSparc T1 (Niagara)
fpu : UltraSparc T1 integrated FPU
pmu : niagara
prom : OBP 4.30.4.d 2011/07/06 14:29
type : sun4v
ncpus probed : 8
ncpus active : 8
D$ parity tl1 : 0
I$ parity tl1 : 0
cpucaps : flush,stbar,swap,muldiv,v9,blkinit,mul32,div32,v8plus,ASIBlkInit
Cpu0ClkTck : 000000003b9aca00
Cpu1ClkTck : 000000003b9aca00
Cpu2ClkTck : 000000003b9aca00
Cpu3ClkTck : 000000003b9aca00
Cpu4ClkTck : 000000003b9aca00
Cpu5ClkTck : 000000003b9aca00
Cpu6ClkTck : 000000003b9aca00
Cpu7ClkTck : 000000003b9aca00
MMU Type : Hypervisor (sun4v)
MMU PGSZs : 8K,64K,4MB,256MB
State:
CPU0: online
CPU1: online
CPU2: online
CPU3: online
CPU4: online
CPU5: online
CPU6: online
CPU7: online
tested-by: Magnus Lindholm <linmag7@xxxxxxxxx>
On Tue, Aug 26, 2025 at 6:05 PM Michael Karcher
<kernel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Fixes: 7ae3aaf53f16 ("sparc64: Convert NGcopy_{from,to}_user to accurate exception reporting.")
> Signed-off-by: Michael Karcher <kernel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
> ---
> arch/sparc/lib/NGmemcpy.S | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/arch/sparc/lib/NGmemcpy.S b/arch/sparc/lib/NGmemcpy.S
> index ee51c1230689..bbd3ea0a6482 100644
> --- a/arch/sparc/lib/NGmemcpy.S
> +++ b/arch/sparc/lib/NGmemcpy.S
> @@ -79,8 +79,8 @@
> #ifndef EX_RETVAL
> #define EX_RETVAL(x) x
> __restore_asi:
> - ret
> wr %g0, ASI_AIUS, %asi
> + ret
> restore
> ENTRY(NG_ret_i2_plus_i4_plus_1)
> ba,pt %xcc, __restore_asi
> @@ -125,15 +125,16 @@ ENTRY(NG_ret_i2_plus_g1_minus_56)
> ba,pt %xcc, __restore_asi
> add %i2, %g1, %i0
> ENDPROC(NG_ret_i2_plus_g1_minus_56)
> -ENTRY(NG_ret_i2_plus_i4)
> +ENTRY(NG_ret_i2_plus_i4_plus_16)
> + add %i4, 16, %i4
> ba,pt %xcc, __restore_asi
> add %i2, %i4, %i0
> -ENDPROC(NG_ret_i2_plus_i4)
> -ENTRY(NG_ret_i2_plus_i4_minus_8)
> - sub %i4, 8, %i4
> +ENDPROC(NG_ret_i2_plus_i4_plus_16)
> +ENTRY(NG_ret_i2_plus_i4_plus_8)
> + add %i4, 8, %i4
> ba,pt %xcc, __restore_asi
> add %i2, %i4, %i0
> -ENDPROC(NG_ret_i2_plus_i4_minus_8)
> +ENDPROC(NG_ret_i2_plus_i4_plus_8)
> ENTRY(NG_ret_i2_plus_8)
> ba,pt %xcc, __restore_asi
> add %i2, 8, %i0
> @@ -160,6 +161,12 @@ ENTRY(NG_ret_i2_and_7_plus_i4)
> ba,pt %xcc, __restore_asi
> add %i2, %i4, %i0
> ENDPROC(NG_ret_i2_and_7_plus_i4)
> +ENTRY(NG_ret_i2_and_7_plus_i4_plus_8)
> + and %i2, 7, %i2
> + add %i4, 8, %i4
> + ba,pt %xcc, __restore_asi
> + add %i2, %i4, %i0
> +ENDPROC(NG_ret_i2_and_7_plus_i4)
> #endif
>
> .align 64
> @@ -405,13 +412,13 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
> andn %i2, 0xf, %i4
> and %i2, 0xf, %i2
> 1: subcc %i4, 0x10, %i4
> - EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4)
> + EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4_plus_16)
> add %i1, 0x08, %i1
> - EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4)
> + EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4_plus_16)
> sub %i1, 0x08, %i1
> - EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4)
> + EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4_plus_16)
> add %i1, 0x8, %i1
> - EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_minus_8)
> + EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_plus_8)
> bgu,pt %XCC, 1b
> add %i1, 0x8, %i1
> 73: andcc %i2, 0x8, %g0
> @@ -468,7 +475,7 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
> subcc %i4, 0x8, %i4
> srlx %g3, %i3, %i5
> or %i5, %g2, %i5
> - EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4)
> + EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4_plus_8)
> add %o0, 0x8, %o0
> bgu,pt %icc, 1b
> sllx %g3, %g1, %g2
> --
> 2.50.1
>
>