From nobody Fri Oct 3 06:37:03 2025 Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 465BE259C98; Thu, 4 Sep 2025 18:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.133.4.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757012060; cv=none; b=CZ6QG4lp0tmCUaO6EIL4wmk4ZnyVM8KzLtQj7ACvQ5gR8XRMQcbj6eYjHOSRNUReo+qV/Alj3iA16hQTPPivB39QKUqi4XOnRzW9Dr6ZdNWs3If03FByhda/g1uuccoweedyyx2NuS2hLvdGhF+ghcNvxWW33W2PZIwWnQA6hNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757012060; c=relaxed/simple; bh=4gZYdso538D/vBBL8aPfqXvitL5zibN0q6xFS0Y3Fxk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eieq1NObyd4z3IlzomnWesw3q4yG5zac5VdQNRN+fdDldjbhJ3srUyfdeZpLn+mAMcCZSd4VrPSumWxnE0WP0No3aqmwdklRb4zLptvGnLukbv+H7tE8DXBmIgqo3hKHtLV/94v9ZJ6Kwyohlx1beEeHVsZUEitdtwR/0h7FZBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mkarcher.dialup.fu-berlin.de; spf=pass smtp.mailfrom=zedat.fu-berlin.de; dkim=pass (2048-bit key) header.d=fu-berlin.de header.i=@fu-berlin.de header.b=X0liRJ4i; arc=none smtp.client-ip=130.133.4.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mkarcher.dialup.fu-berlin.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zedat.fu-berlin.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fu-berlin.de header.i=@fu-berlin.de header.b="X0liRJ4i" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fu-berlin.de; s=fub01; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:From: Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:In-Reply-To: References; bh=CRlIIJkKwDfqWd0EKq7H0qTeIMtD+bIteX8nMSNMb7Y=; t=1757012057; x=1757616857; b=X0liRJ4ipskj3b3iyzt8ZLznr99vFalqSOlGICBaM9cCcSgoLIXRHhPbJXLGX 5OvQaTTRImqEuCW22MMHPhwhi+PweW5+ubndpiOeXdNLkLqEgbm37VbZs1DkgHDS2M/VzggBOhVAs fggSwbe7ipMaeG8sTwja0pV3Mgrw2mSNMaBXeduvDh2FD1R4Vkg73191zfM8h3Kx4j7aQmNFLbWnU kI99W4LodmFXF0ELWL+pgoSnsFva/5WsbTPrEVnHWXLenAIBryoyoVyW/56dtORooJAi+1Le0PsB2 L61Rc4ZjG7/A2a544dGNNykCHnywtReflrSP9uQHSEV461JhsQ==; Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.98) with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1uuF67-00000000LyN-26nI; Thu, 04 Sep 2025 20:54:15 +0200 Received: from 89-103-142-46.pool.kielnet.net ([46.142.103.89] helo=Geist14.) by inpost2.zedat.fu-berlin.de (Exim 4.98) with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1uuF67-00000001W6v-1CT8; Thu, 04 Sep 2025 20:54:15 +0200 From: Michael Karcher Date: Thu, 04 Sep 2025 20:53:53 +0200 Subject: [PATCH v2 3/5] sparc: fix accurate exception reporting in copy_{from_to}_user for Niagara Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250904-memcpy_series-v2-3-9806dd1784e7@mkarcher.dialup.fu-berlin.de> References: <20250904-memcpy_series-v2-0-9806dd1784e7@mkarcher.dialup.fu-berlin.de> In-Reply-To: <20250904-memcpy_series-v2-0-9806dd1784e7@mkarcher.dialup.fu-berlin.de> To: Andreas Larsson , Babu Moger Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Karcher , John Paul Adrian Glaubitz , Anthony Yznaga , Magnus Lindholm X-Mailer: b4 0.14.2 X-Original-Sender: kernel@mkarcher.dialup.fu-berlin.de X-ZEDAT-Hint: PO 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 ca= lculate the remaining bytes left to copy using the current register contents. This commit fixes a couple of bad calculations and a broken epilogue in the exception handlers. This will prevent crashes and ensure correct return values of copy_from_user and copy_to_user in the faulting case. The behaviour of memcpy stays unchanged. Fixes: 7ae3aaf53f16 ("sparc64: Convert NGcopy_{from,to}_user to accurate ex= ception reporting.") Tested-by: John Paul Adrian Glaubitz Tested-by: Magnus Lindholm Signed-off-by: Michael Karcher --- 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 ee51c12306894eee4195887d2b28b2619f63c2b1..bbd3ea0a64822c7410278fcc3d1= 01ce9cef96c89 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 =20 .align 64 @@ -405,13 +412,13 @@ FUNC_NAME: /* %i0=3Ddst, %i1=3Dsrc, %i2=3Dlen */ 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=3Ddst, %i1=3Dsrc, %i2=3Dlen */ 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 --=20 2.50.1