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=1796233951; b=t7pv1kmdAd5j+IOZL7Mi1GQb037Nwhs4IVTSQP47AbZJC38ENn5BO+iyxaUAWIFJM81A 5vonszXrlz9e7c4HaGfJ16nGrN1zQOGNwGEWQ8ZdfPLjUBlejE80cCrx1TwEbeclysNQZ TM9LW9OxI4qpxFtVRA45JUIYCxu1I0X6GpGoF6SpJseBWvyxcbB+QCXDBfxlJyfcS7ty0 omkBbOR1aGrpKbAb2kp7/sQ7jhvu6gJKgJuRivY2VW9KFtmRP45inALlHMCYQT750oBUG xCgWM2zlr2HGP/xosUNJlsk2ZrECcd+WPNB5ApahaoCb2eeYhr241NBKk/q3qe8AJ6A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796233951; 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=ooN7LWd2/Oot+GtAZAuSg6pIqoHZxWRvkEziR3/kiEU=; b=T9imbeg4xFZ3hynNh7BEmDxkBidJ+Q/vp+INJbwo6SOrjjhu0uaCcLAHfc5/1MazBa35 xmEPc+xhGARD1XWXtWCoA9GIol4fDvEbCHSHlm35krlpQmbjFDEYpFnI5VW9XRGCe/FTx 7PF/cNoWC5nkR2JOpWjswrv0ZcKKuHR3rioQo/f8YBDtrUGceD9eKdYyjuTHQkSKO4FMJ oiM/Zcr51QcSYrpRK006U9KzrQeYabvHS87PPQgHD/9WAjJobkfySy0aw8N08HStOzfh6 /rYrj845AszJjeMDdQBXoGLJc+SMJ+AnhMzGUGBngKkhAdZNZT6SXj9ZjJIMni/xisQ== 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="AL7/+Yer"; 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 0F76F606A32F for ; Wed, 2 Dec 2026 17:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0F76F606A32F 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=AL7/+Yer Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4bbcb9bccf6so567975e9.1 for ; Wed, 02 Dec 2026 09:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796233949; x=1796838749; 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=ooN7LWd2/Oot+GtAZAuSg6pIqoHZxWRvkEziR3/kiEU=; b=AL7/+Yerp/N1r6tpMH3h4dprzxG94BklhlHC0brkLLbNafc/MJwSRuavTX75WV4/Ej RVBRNy5g4LO/BN3Ox9ClSykVMwIClYNKV4V1U8uNh9JqLcOFLxz6KTKoJ0WqfmwNWW3r uPNqHKXUTpzlS6J5CMzs5ahPZtvxKaQ01yOZHJq6MbJ24+6taqHKWASC4p1D++cMZcGV UKIxQ/zU5TboJOaPKdqezYC81Dh4G/0hmtRx+LLJ+aATke/FRqwdaZri3ukVqCP67r+s kPDSEpYgfHYSTmn7FrX9EAxQbn4AkNjAaGvos8HU+05wcWBV+XfSOfnIRQ8ahoaj/KR/ opUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796233949; x=1796838749; 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=ooN7LWd2/Oot+GtAZAuSg6pIqoHZxWRvkEziR3/kiEU=; b=YTtm8M7dJEmAPygzNLvo1iO5zSF0neYrxyjoqxit4VTNhtmxrSFHRFcAPoh4jGhgMg fNWQyGDy3HdhgmP75OPlV39OGWIu3O/dqdEOk1CoD0nUsx1FLHjxKjIVqw3pM7FYcuTR RIJULQu2N/bG6CPI3EM2Lt2P9Hk4I52Scpz+J1M+/m87BfXN9FtjTM/5FOFhZEA0JseD qk/45G1L6Sj2JZrGGEha/JbuhJY+OsVnQbLabi3u3FYxPFNC58gojPdh4GG40yd0ljtF yjVttsbXdo7eLhfFzcSggDD5pvryQpaIlsIiJvT3VAY1R9hROeU018nXySxbsbAIMBhQ bIvg== X-Forwarded-Encrypted: i=1; AL+hErHDsWYZTQNNp9mfTYzwGIi0WqmskgnalOY76xyWrbJg+oohCMSyIihE87ZNzl7kBGs4hluWDLZBRqHuzpU=@vger.kernel.org X-Gm-Message-State: APuU4Z9yjuZ+DIkRd+Ylcm58qKJU17We5yBQuQ7lhYcZ96FNZX8FCAja Hw4tf838H7u8FWYFUqbb+ApuaYwSDGmv9XI9O6MWL62m2mYQm34I5vHh X-Gm-Gg: AZFdTZdsXODXA0QDUj6ObkWGWXrbnEidTzzxtPghlHYYvVlSthHbW8r2nYnxVb3H0md eok0nPTHss5H0r0mxwINpX1lJaHX7H+VkzW2gx3gIVLlWWnnkYbyXQdSnp4bgOdPfMGk0I1uOzP oE7SSa/jTH5pMG4q+hLn8njjZd1wtUg0C0x+vyzMB6A2N5DwUQj66aCL4vKjop8czyfYoi5klrn pJ237V9ENKFkFgmkLsbj9NNe8a4sCnZ5MefSB+yFTsVFnV19eW51eBsJsNFsgBSef8q5LFxeaxj aP1m22jjSVEzh7XfemysVkn1bA0/8OMzm8uPFWKZigd9Kdcv6ByjwG18R3kC772ekl9ruEhhE4F 2gP4odCejzUzDbVx/JxInYPFNjtHRoPQhw3+Gp4Wi57DoV7rQUNENf1Kpd4dK6JRlgFRTZIic8Q RFQnvCw3uDFcOezHPTeI9zYrejF+T9FMaxjpRZQXkXccmf4/Cec2OrMgE9j9ScHnsV2uXndColQ Onb6P52DqusPhmSnIghd2cBPwZ/gT2T+yLnFEH8F5b8Q7Ir3e+xX4cCCnaZzwV5MxaPrr6yXH7J BkH8+n42iD2jZr2IFXLz+UIcqqwFwJtxGC7U70nk91AF/DPGPJA3KXaFbn4ScRLX X-Received: by 2002:a05:600c:3b10:b0:4bb:db77:2a59 with SMTP id 5b1f17b1804b1-4bbdb7730a3mr34441425e9.14.1796233949361; Wed, 02 Dec 2026 09:52:29 -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 5b1f17b1804b1-4bbe00dafdfsm3196845e9.12.2026.12.02.09.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 09:52:29 -0800 (PST) Date: Wed, 2 Dec 2026 17:52:27 +0000 From: David Laight To: "Christophe Leroy (CS GROUP)" Cc: "Nysal Jan K.A." , linuxppc-dev@lists.ozlabs.org, Jeevitha Palanisamy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "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: <20261202175227.68aedaa6@pumpkin> In-Reply-To: <2b03573f-da09-479c-a87d-6ac41737caa8@kernel.org> References: <20261125174035.1412724-1-nysal@linux.ibm.com> <20261125174035.1412724-2-nysal@linux.ibm.com> <82516881-5ffa-40f6-9d6a-549fcbb0ab00@kernel.org> <20261202095747.0009eb79@pumpkin> <2b03573f-da09-479c-a87d-6ac41737caa8@kernel.org> 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 2 Dec 2026 11:13:24 +0100 "Christophe Leroy (CS GROUP)" wrote: > Le 02/12/2026 =C3=A0 10:57, David Laight a =C3=A9crit=C2=A0: > > On Mon, 30 Nov 2026 18:58:11 +0100 > > "Christophe Leroy (CS GROUP)" wrote: > > =20 > >> Why a memory clobber ? Is it to get a barrier ? Otherwise I see no > >> direct hidden memory modification in the sequence. =20 > >=20 > > I found something horrid during testing: > > The compiler (gcc) will spill the value of a memory operand to stack. > > So: > > long f(long *p) > > { > > register long x asm("r3"); > >=20 > > asm( "opcode %[x],%[p]" : [x] "=3D&r" (x) : [p] "m" (*p)); > > return x; > > } > > compiles to: > > f: > > ld 9,0(3) > > std 9,-16(1) > > ori 2,2,0 > > opcode 3,-16(1) > > blr =20 >=20 > What 'opcode' is that ? Because powerpc is a RISC processor, there is no= =20 > way ALU operation can operate on something else than registers. A memory read would do. I was playing around trying to get the compiler to generate addressing modes that lq doesn't support. The point is that the asm block isn't given a reference to the address it expects. It also means that the size of the variable has to be right. If it can do the same for an output then asm blocks that try to do atomic operations will do them on a copy. Or consider (with -mno-altivec) this: u128 f(int xx, u128 *p) { register u128 x asm("r4"); asm( "lq %[x],%[p]" : [x] "=3D&r" (x) : [p] "m" (*p)); return x; } generates: f: ld 9,0(4) ld 10,8(4) std 9,-16(1) std 10,-8(1) ori 2,2,0 lq 4,-16(1) mr 3,4 mr 4,5 blr A little contrived and the byte order is wrong but it is failing to do the expected atomic read of the 128bit value. David >=20 > With xor as opcode I get: >=20 > 11 .previous > 12 .type f, @function > 13 .L.f: > 14 .LFB0: > 15 ???? 00000010 .cfi_startproc > 15 00000000 > 15 017A5200 > 15 04784101 > 15 1B0C0100 > 16 ???? E9230000 ld 9,0(3) > 17 ???? F921FFF0 std 9,-16(1) > 18 ???? 60420000 ori 2,2,0 > 19 #APP > 20 # 5 "toto.c" 1 > 21 ???? 7E030278 xor 3,-16(1) > **** Error: operand out of range (-16 is not between 0 and 31) > **** Error: syntax error; found `(', expected `,' > 22 # 0 "" 2 > 23 #NO_APP > 24 ???? 4E800020 blr >=20 >=20 > > That really isn't what was intended. > > (I suspect it can also to the same for an output.) > > The only way I can see to avoid that is to explicitly pass the address > > in a register and use a memory clobber. > >=20 > > I wonder how much asm assumes a "m" operand references the > > 'obvious' memory area. > >=20 > > I'm not sure what the 'ori 2,2,0' is for. > > I also tried casting the pointer to a struct with a 'char x[]' > > member - that generated an ICE when it tried to copy it. > > Using volatile makes no difference. > >=20 > > David > >=20 > > =20 >=20 > Christophe