From nobody Wed Mar 2 22:08:56 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5ADF119E7119; Wed, 2 Mar 2022 22:08:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K87Yj0Z8Pz3jb3; Wed, 2 Mar 2022 22:08:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646258937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JV/5BxESpoU9aB6xrCEsoRVBEq9Ix9LdImIWG88e7d4=; b=BGUKViXAXSsujWri+d8sffOSbiARvYCH216nZbUqYlI+wAMo5jHBhPmoYX0ELjyff2lfiv LvBt1PlsvtfWn0IgGRs1BjDf0p9OyIChl1k3gWYBvrOmkbfe9BWVB55ByKdCvXQprt/WH9 +d4GXw8kCXm7sOq5CAXX5K7e5WAhEN5CrP1dPKpE7XWopEfIPSESBtQDY8ss7LI99uEXOV DgdDacIRYmKoR+hpKgYgIA6B7Uy/gBN2zqOzDpsnBJbwN4Xk2rACFbwRpouQoMaUChWWuh BgCl891XMeVJXte6GeVSpYPpMcXc7tXvHaVggJ9EHLpefyHLiMOcjZDVJfSfVA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 739673C98; Wed, 2 Mar 2022 22:08:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 222M8uon080074; Wed, 2 Mar 2022 22:08:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222M8uAd080073; Wed, 2 Mar 2022 22:08:56 GMT (envelope-from git) Date: Wed, 2 Mar 2022 22:08:56 GMT Message-Id: <202203022208.222M8uAd080073@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: c9c6985b8a18 - stable/13 - powerpc/atomic: Fix atomic_testand_*_long on powerpc64 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c9c6985b8a180b2270db83d3a2389d452362dd8f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646258937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JV/5BxESpoU9aB6xrCEsoRVBEq9Ix9LdImIWG88e7d4=; b=ojkQ/vpALnMGkdcwBuyudzj/ebntxrh85edFVqS7/n0ddkcQYnCuZt+fBMYOMo5OD+PcXP 9vD+XhO+MqyJ9bRKMvq4fLUmDCUAhOv8EIzpaYFBFFWLzYSnETTqm2HHWDoMKV0obJlQfp eSILtKPIUwM6XGFbZRax2i/Y3G7jTeaJ3a7Sdq7uWWmqpY5daB8HwnildMUcs00uXa/Rp1 X5MafYjfSOsVufEZu+8wxoypVDWlcpxQn6GTj10XSMHgwa8vRglAfDAbPhtHdMXKuOoVHk jEYXgBkmPc3g5Jnnx+g9czNYC9pi9AhHmtNfKVYQUic8dRmrIDM0iBwN3DYyhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646258937; a=rsa-sha256; cv=none; b=KPMFDrqYmhZDgkxl7gc3Sw9WNL5D+t43fjgm8SA9MXPWtgDDtE44lNC6oSNcNeW4lfjMeO /mN8fWs+1LfVCtTSPAiRiQXLRqGQsh/cGM+0Qqhr33JOw94/UaG+LF+5g2Rbm8zbeAzg+r 2olkcYwEg3y5X6ZSIzGRbCiMubBIjRNqK3O7syACJG20DDaIeGYscjBMfC+q/qv2QBUjSs nF0FQ4D7NJQLBX8JY8nzsHOo6JOAJ9j7Bf7QGXXa2NOLVm8boQT5YQmcXdFjGk/ZVfrvWU VR1J/H3eh47rDFHoLE5Xb5RFWvKhJpMtQSp1/mKRdvUE7dLlP7+0RsjiOlMrHA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=c9c6985b8a180b2270db83d3a2389d452362dd8f commit c9c6985b8a180b2270db83d3a2389d452362dd8f Author: Justin Hibbits AuthorDate: 2022-02-03 23:20:36 +0000 Commit: Navdeep Parhar CommitDate: 2022-03-02 22:08:33 +0000 powerpc/atomic: Fix atomic_testand_*_long on powerpc64 After b5d227b0 FreeBSD was panicking on boot with "Duplicate free" in UMA. Analyzing the asm, the '1' mask was treated as an integer, rather than a long, causing 'slw' (shift left word) to be used for the shifting instruction, not 'sld' (shift left double). This means the upper bits of the bitfield were not getting used, resulting in corruption of the bitfield. While fixing this, the 'and' check of the mask does not need to be recorded, so don't record (drop the '.'). (cherry picked from commit aa4736459ee2d314dc90ae9cbb4ad9c1cf48d796) --- sys/powerpc/include/atomic.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index c3d353cba3d3..da80cf85fc9f 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -997,13 +997,13 @@ atomic_swap_64(volatile u_long *p, u_long v) static __inline int atomic_testandset_int(volatile u_int *p, u_int v) { - u_int m = (1 << (v & 0x1f)); + u_int m = (1u << (v & 0x1f)); u_int res; u_int tmp; __asm __volatile( "1: lwarx %0,0,%3\n" - " and. %1,%0,%4\n" + " and %1,%0,%4\n" " or %0,%0,%4\n" " stwcx. %0,0,%3\n" " bne- 1b\n" @@ -1017,13 +1017,13 @@ atomic_testandset_int(volatile u_int *p, u_int v) static __inline int atomic_testandclear_int(volatile u_int *p, u_int v) { - u_int m = (1 << (v & 0x1f)); + u_int m = (1u << (v & 0x1f)); u_int res; u_int tmp; __asm __volatile( "1: lwarx %0,0,%3\n" - " and. %1,%0,%4\n" + " and %1,%0,%4\n" " andc %0,%0,%4\n" " stwcx. %0,0,%3\n" " bne- 1b\n" @@ -1038,13 +1038,13 @@ atomic_testandclear_int(volatile u_int *p, u_int v) static __inline int atomic_testandset_long(volatile u_long *p, u_int v) { - u_long m = (1 << (v & 0x3f)); + u_long m = (1ul << (v & 0x3f)); u_long res; u_long tmp; __asm __volatile( "1: ldarx %0,0,%3\n" - " and. %1,%0,%4\n" + " and %1,%0,%4\n" " or %0,%0,%4\n" " stdcx. %0,0,%3\n" " bne- 1b\n" @@ -1058,13 +1058,13 @@ atomic_testandset_long(volatile u_long *p, u_int v) static __inline int atomic_testandclear_long(volatile u_long *p, u_int v) { - u_long m = (1 << (v & 0x3f)); + u_long m = (1ul << (v & 0x3f)); u_long res; u_long tmp; __asm __volatile( "1: ldarx %0,0,%3\n" - " and. %1,%0,%4\n" + " and %1,%0,%4\n" " andc %0,%0,%4\n" " stdcx. %0,0,%3\n" " bne- 1b\n"