From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796144970; b=sIMhRCOKtb0+lW6UFImnGSn66//PZm3HicC6lYEJCSE130uhtkiKoONx0WDdDZCup9qJ CpZzPoEvn0/dITCXX314PLUSm5ljrbdCO6iJSr5D2BPVIKf20ddFOMIYpxPuKLKBIedXZ fmOHeUZ/WUUDfbK31ecIll+0ldhfMc3dUJ5gkAxvXPRUEZDB9NdyFfI3PgeeTMwvvTQ6O ALv69K56YmM82oN8uqjnSoF6lfF3EecDCbTwrULnZjKcVq/dqbW/a/4MoNZLUzomqYcDD K+irdcUUn6QIpVmS2bCUCng7Gw7RmZ8U2QzdQbCt6rpqRe+Rkj9N+i5C2JJdzm6dRDA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796144970; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=9vtKgl5Nw/cgbqHN0T2GSJVZxmYka9Xsw1DHvbjDeI4=; b=w3RrDLYhC5ZfpuTvrnyegrmMxXUxDebt9ojzz+EDinOGXmKSt70gqnFnWmItgNWbMeJv QdeSqrQb75GQ59H8G0r3Ib8c0mvOdR/1lTSHDODHZ/zOSpd1aTFxRJ1l8gcx0TQFK4dUy Ex8X5cYqsiFR70a4AlMoGouTyVGPeE1FTh6o9X5EVfdOpBXQsRyf1aZZHCizeVP9HcM8O eXEov6UUiJLv59ctuBUETl2UkbZo3zwkHoxW9UwyOcMyPumJgCZXGnRmhW46OJ7VdVacS 3cHEhzUYKFV1AhJ/cYqpDYat2Fb9M7nM4fQNdZjqHYf/Tzd+qly+BCPU13Y26QxSAKw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=p8G0s2mq; arc=none smtp.remote-ip=209.85.128.52 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7C06606A329 for ; Tue, 1 Dec 2026 17:09:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7C06606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=p8G0s2mq Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4a1fbd52ab6so84448205e9.0 for ; Tue, 01 Dec 2026 09:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796144968; x=1796749768; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=9vtKgl5Nw/cgbqHN0T2GSJVZxmYka9Xsw1DHvbjDeI4=; b=p8G0s2mq59NFvIli63ZKQ5l/no1cHC0rQOv4Dj5tnXs32Y/yyEj63VmVWJMr/U5nu/ FYFW4cTp/77VKNalgmacvfoapw3LqS4ismCEPWzEG8tMLvk8qYEc38wXI2mFQCu9aQaQ xqy4WqLO7FYEWA8LlNqPuEK+4Mcofnaja3c9t3AvNkRIl2EKakBK9ZUWw1hbH/K76kDq CVXTAfnWigvk/j69m9oy/BbYq5VQ313V5HmzzxILb4oTwjx12bK5zCCpoxPWAuIWdWs1 n3mMOl0YmIfHUy2C/DJL+8cBMDUsD4dO2R/0XjASjrPuAnfRGKMlLFCuEf1R9Djnb4wR rcCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796144968; x=1796749768; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9vtKgl5Nw/cgbqHN0T2GSJVZxmYka9Xsw1DHvbjDeI4=; b=nF38lg2d8f7omWoKA3AxcJsTeBBDv/Yo91+Cz6JM7wtcShhL/PoVjrOiWb6FibQTH2 qc62KIHwvNylRyKUo4wpgfw3d85Krvc8QNsL4S9pbET3hl4stNZPlfhvq63mtF16PZxn +1wofym/W4oHK2YBkNtTcl+FKQ+Y59IQ9YkhV/1qSOxU0utrbBxPwyUP7IKilFoybSDQ KXeL71yA1cI6na4fSjYWxyPUyhOI0LajxwWG2SWKtR84WeASgATJXiR2JwCxM7LECB55 eQTMUBkVud+6La1Fsu57JKCr5hyi996pxeVqytTFVVw/v6xazMbkMCXv2IUm9BqCVaZu 8xFA== X-Forwarded-Encrypted: i=1; AL+hErGJBkllHUFA+vza6sOCFzebi/TiEuZQ5p/2S0JB/6x9oIw/J8K/ChTP+0vh8ETQc907jcI+eDkMZGDQtUs=@vger.kernel.org X-Gm-Message-State: APuU4Z+vwPJ/MJAW9NVvuUc/qiXDH3ClFEmqEw47LZItT4vEQotsquKt lVekz7RMEoMTGc1hQZoFJAOgiIK6/3HEPS9YrJTD1Rwjc9MHqGQ7zFQc X-Gm-Gg: AZFdTZcbBZhKWl9sEge5UbbqGs5YZ+cZl0NRpeml4dURkJZsjgtsB3akF3FBPBSbaty fsqInmi6XlcYLbydeM/LrlKuKAN9KtoTbpGGAlERj5pEsm2dFC1WgFOQt7DdO7JtVPU6gk73HbD w/Mfqv290BKshp5sqJzYuZrtOylZFj04Ch/RH9Dqt7WxzvnI2zuy8w619Xso4ruQhiw5pbnZ5x6 MzL6+CKWrgLinzNAlXrSjxn7gMdlYRW1KzyZjC1MYIXISWgfsImSvBthURf5tR+lpAotJqMKDHi /30gJD2nrcNCO17aWhNFETcEbB1bc9HRje7VX7ChlZS2s48sJU3mAblJ08LD5c0fs5jUv6rCcgN VBaf5FYoeA7GTICoerhPmpaV9fugQTh0bdApyNXOc99BIgI6K2bhS2Wly7sK7efQs1YfA87V8nV PLMee6H6TbyfxSqRQ8iv2PaUdge1SRSf4fpr4H0/HZkfxLAlTRVfd+5JgFXnGIE1Bv+XCUboQIJ 6murvs5tEWEAKHsRVddo/sdRx8DgtoXHN2gVBpB6xnqB3bUn75fnAjOVPX9pwtxwhgBjOcd5XiU oE39kMejKpy9vYYQxFg27+pwvWUo9kQLOAFv0MiifTHpnykwsMJPBeI+lJNf0g16 X-Received: by 2002:a05:600c:4e4c:b0:4b6:5dac:b61e with SMTP id 5b1f17b1804b1-4bb88938d2dmr703765285e9.32.1796144968034; Tue, 01 Dec 2026 09:09:28 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a68048esm75755120f8f.29.2026.12.01.09.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 09:09:27 -0800 (PST) Date: Tue, 1 Dec 2026 17:09:26 +0000 From: David Laight To: "Nysal Jan K.A." Cc: linuxppc-dev@lists.ozlabs.org, Jeevitha Palanisamy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , "Ritesh Harjani (IBM)" , Shrikanth Hegde , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andrew Morton , "David Hildenbrand (Arm)" , Ryan Roberts , Andreas Larsson , Usama Arif , Kevin Brodsky , "Kiryl Shutsemau (Meta)" , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH 1/3] powerpc: Add support for 128-bit cmpxchg Message-ID: <20261201170926.39183e2a@pumpkin> In-Reply-To: <20261201145831.7d897df2@pumpkin> References: <20261125174035.1412724-1-nysal@linux.ibm.com> <20261125174035.1412724-2-nysal@linux.ibm.com> <20261126112714.021a3e66@pumpkin> <20261201144804.6a0270d5@pumpkin> <20261201145831.7d897df2@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 1 Dec 2026 14:58:31 +0000 David Laight wrote: > On Tue, 1 Dec 2026 14:48:04 +0000 > David Laight wrote: > > > On Tue, 1 Dec 2026 19:22:06 +0530 > > "Nysal Jan K.A." wrote: > > > > > On Thu, Nov 26, 2026 at 11:27:14AM +0000, David Laight wrote: > > > > On Wed, 25 Nov 2026 23:10:22 +0530 > > > > "Nysal Jan K.A." wrote: > > > > > > > > > > > > > > +#ifdef CONFIG_HAVE_CMPXCHG_DOUBLE > > > > > +union __u128_halves { > > > > > + u128 full __mode(PTI); > > > > > + struct { > > > > > + u64 low, high; > > > > > > > > There seems to be a mismatch between the register order that PTI > > > > assigns and the one that C uses. > > > > It might be less confusing to swap low and high in the above > > > > and only use 'full' (probably renamed) in the asm statement. > > > > > > > > > > I can swap high and low here to indicate that it maps to the big-endian > > > register layout if that makes it less confusing. > > > > But AFICT it doesn't (if I believe the AI from google for "ppc64le lq word order". > > The high bits (from EA + 8) end up in the even register and the low bits > > (from EA) in the odd register. > > But that doesn't match a test I just did on godbolt. > If the order is backwards then you do need to swap low and high > and only use 'full' (aka full_partially_be) for the asm constraint. I'm getting more confused. I don't have a cpu to test this on either. The above AI says you can do (reg + reg), but godbolt's gcc 16.2.0 will only assemble (reg + const*16). See https://www.godbolt.org/z/KParbvPa7 (and fiddle with what is assigned to [v]) I also found this comment in a patch to qemu: + /* Note that the low part is always in RD+1, even in LE mode. */ + lo = cpu_gpr[rd + 1]; + hi = cpu_gpr[rd]; So it might be that gcc is actually getting it wrong. Needs testing on a physical cpu. David > > David > > > > > I suspect (as in the other email I just sent) that when you do: > > u128 x; > > > > asm(... : "=r" (x)) > > you are getting the register that holds the low bits of 'x'. > > But you want the one containing the high bits so that you can use L[] > > to reference the low bits. > > The code might appear to work because on a function call the lower > > register contains the low bits; so, if the register isn't reused, > > L[x] will be the high bits. > > > > You might be able to tell which registers gcc thinks are 'live' > > by adding one to the clobber list. > > You can't add one that is in use; so it should force an alternative > > register allocation. > > > > David > > > > > > >