From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796209321; b=meCEThQ5mbu8/NCIkFtJrvC87rXswWcND2vZBYlwVRmdd8U+dwmbbe/5fSr8KhKBHWiE hGwQkqkz7w6zPsZZ7VzOfXPRea3k1TskoBEEINz1KobKdpdQKL4Z+PpCYrmDPQ9H3wScB CD5i+4ZhepNSvnp9bA+jBB71nLLRM1WfFzF1kwu1F/lRDf+XbfJz7T3S67CJx6PXo+GRc vNlK5EIbRR8qdi1IiFuTIT2B9wdie1SF3BAtlUo/5FOgmlg/MF7sTDGOTFiXvoeOH9rtz FonkgseYSXY1MionUVSuSaXL7RfQYj9mIwhekPnCgLp/uW3/d47tKXeETRs9logjh5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796209321; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:From:To:Cc:References:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=NXUzVKbAlWEJPiIdbp5Pcm+0GRSouvgcF+GSUMw2XiY=; b=TuThxfb7yi0HgWZg5y+KR9y3GMF6jcTp6nYsSvmzED9odOKfcfdPMcke2Q7d3+BIUaHm 6iII6T3+/vY+qAtpqk4HaPpHaMhS8+4qFrZQ6vT7Zd719vUDzsF7G5lkrr3D2Acgct+Xw nMjLJ+zdd4Ckx2OYOBO/chQO0JHYczseGhY8S1ZFISB688Ld5gEg0TYlrzz9Lx2HOK83g WWP2LE/821ECGscZFf3ACV1hVt64PJxttXtxx3ya/DA3fUc33KEaURo5I8whEGJPuzl0E M0dJzKzHkFQgnAPwxlihcBVbacHJGN8BK7VtXaLPUOTo6eSTcEj0aeAbOl5iEu02QSQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AGyeLs90; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFF22606A335; Wed, 2 Dec 2026 11:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=AGyeLs90 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 620241F00925; Wed, 2 Dec 2026 11:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796209321; bh=NXUzVKbAlWEJPiIdbp5Pcm+0GRSouvgcF+GSUMw2XiY=; h=Date:Subject:From:To:Cc:References:In-Reply-To; b=AGyeLs90Y8bHCKF1JgBpXe6jQYUnROdqrG4yWjfswQ+th3rc9xVP0/++qMq9MA1ae /+ZpDVTqDrcBI31FqU2eWSLPZu/7gT9Ed6i+/a5i9bBscRkU5KUkPjwLBbBttPBmzT my3xpi5yFtLWHjeiDdQ/tOXyhKI9/LLKqFW4BJGmEv7tlIMUvq67VSVN4lDYTYoVna 7TLhsNrMvUToml2DVZSXZhSzrX5EJkETIdJKLC0erARLt6LjM4KN8AKp1Rp5LypKbM BpfXIZB5R7UZvf6B8r/qMFDTBeBQ3hD1yAqj6pklVl2VnI8glsP3To43c8l9dCXe13 KgwC4gQB1LW1A== Message-ID: <4c1987da-92ea-40bd-82c4-22cbd1cd4dcf@kernel.org> Date: Wed, 2 Dec 2026 12:01:54 +0100 X-Mailing-List: llvm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] powerpc: Add support for 128-bit cmpxchg From: "Christophe Leroy (CS GROUP)" To: David Laight 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 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> Content-Language: fr-FR In-Reply-To: <2b03573f-da09-479c-a87d-6ac41737caa8@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 02/12/2026 à 11:13, Christophe Leroy (CS GROUP) a écrit : > > > Le 02/12/2026 à 10:57, David Laight a écrit : >> On Mon, 30 Nov 2026 18:58:11 +0100 >> "Christophe Leroy (CS GROUP)" wrote: >> >>> Why a memory clobber ? Is it to get a barrier ? Otherwise I see no >>> direct hidden memory modification in the sequence. >> >> 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"); >> >>      asm( "opcode %[x],%[p]" : [x] "=&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 > > What 'opcode' is that ? Because powerpc is a RISC processor, there is no > way ALU operation can operate on something else than registers. > > With xor as opcode I get: > >   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 > > >> 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. >> >> I wonder how much asm assumes a "m" operand references the >> 'obvious' memory area. >> >> 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. >> Wondering what you intent to do exactly. Isn't is something like: long f(long *p) { register long x asm("r3"); asm( "xor %[x],%[p],%[p]" : [x] "=&r" (x) : [p] "r" (*p)); return x; } Which gives 0000000000005460 : 5460: 00 00 23 e9 ld r9,0(r3) 5464: 78 4a 23 7d xor r3,r9,r9 5468: 20 00 80 4e blr Christophe