From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 EC5EC606A6B8 for ; Tue, 1 Dec 2026 17:09:37 +0000 (UTC) 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=SoskMrLl Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jf6nW6Dwtz3f1J; Wed, 02 Dec 2026 04:09:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2a00:1450:4864:20::335" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1796144975; cv=none; b=Npr3qvVNxj0LSpEtKFpWNuQUTQy5nuu2ihfecZ6cSxomS+n+4MzKZ7Z806YdvenAKLmtC9v5CS0b5UhVeHuWpJXvEVi2WLHERTSW/rb8YqP5p84kIXJEenHuugoezQ18pErQj07Fja41oZeOTg/+8kfOV2zaVDeLzWSUQ9tmHrUXx5girvbZ0XT+vUgJj1V0qafcOiW8psa/6PZybvOW2BW/oY7JPEffPV+TE/HNfSREqJ1MGb+4pzWl/yYf1Mlq6yBJRTnAoJKLVwtuvVHyDo0fTOvehxlNmSngUcHbHHPMJJJjfF7VRZWoY7gL6VSGx5xsmJYG+DDuEwdvOyGUuQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1796144975; c=relaxed/relaxed; bh=9vtKgl5Nw/cgbqHN0T2GSJVZxmYka9Xsw1DHvbjDeI4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bW42knRsb4lGZB8B/buph/005OvXHQu4KE136mm+Wq85ggck6eiMDxZIWZMQj+3plY5wLqszXTETZFZFVrHDUntiSSw/88n6iQAbLiVEr8erpY4kSyEUSbwjtm8LcdB60cO1JUkpadb8FdwR4k3YikQz+stNL1H+oEGfk3t11CWiR4Crf9EPaWal4d9AjgfzimZp2tiZhkSzvEzgAfp0yzKv6WhyyPtq1CIJKqe8JNpKA6W0dHoKtikflYOP/KCdbvSMaFvgKez52zf9XyY4BVYFOTTqeMQKMrGDOTmEgRYlKtCb+++c5putym1l2nB7gJh86zh6xnt/nOuutUBM4g== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SoskMrLl; dkim-atps=neutral; spf=pass (client-ip=2a00:1450:4864:20::335; helo=mail-wm1-x335.google.com; envelope-from=david.laight.linux@gmail.com; receiver=lists.ozlabs.org) smtp.mailfrom=gmail.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SoskMrLl; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::335; helo=mail-wm1-x335.google.com; envelope-from=david.laight.linux@gmail.com; receiver=lists.ozlabs.org) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jf6nS5fDQz3dLZ for ; Wed, 02 Dec 2026 04:09:31 +1100 (AEDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4ba013938d7so113041695e9.2 for ; Tue, 01 Dec 2026 09:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796144968; x=1796749768; darn=lists.ozlabs.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=SoskMrLlOhTOj6eu0GqVTUfl5cLODcbnJxuJBH+M2L3eN/t5TOtuxZWYlGNmaJqXzZ IlDMDBrFVhsfRDv9Ti2hibwZ78/5Sq0VhIY8zgeTGG3F0dRP9CE0WyPFq2NLaLBxH9Vj 3iPLs9IyYnTtWtbZ7Rzx0HPtg9Fb4zse/NQvQZ5zJ4v0W6j/nCROO5bG9jX/LlXPdXQu z3xkbrsX/GR89GhWcg3jl/QA4rV2e4p71E2+Mo1in6rxIAzhn2g6xgMPBlJPaJleTD2a HgHPFVmMSZnLoA0bSwciXVMGyhwCgDE6W+9mUFn30+hXD6GDIbuHpSdbdqZ+2JYZi6tr 3lAA== 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=xs0daAdilvG1HPmEVYylFSAbyun069ePb66j3SUw0LUoKnjV6yHGYwe33l/vx68X+7 ci5RLv92mf4T15OBtbxzTSpbvQw6gvSNVc/cgaK1QxWHhrVI6PXVeN3esrqfbIkSFanA n7G5wKPMexcaO12OFygPdwSzXX/j6Hc/YtQzZqf7F+xQ50H9PiA/UjwOTWOC4KaNIJ/v 1RNZBEjFWa6q2wJJp/3dO4JHHBSRoMfop57KlF5R1obrvikCkhsM56qyJPKx5uEQcem7 GPeObO5Yuga/qYAmA41NyeUVkbA4fyfh/ZfiulR2j6L1Ub2381FXmH0yHLl3ysl3Wyqv XlVA== X-Gm-Message-State: APuU4Z/8AI+OmAp4mRrdIPU0YTFWt0BhAp+7QXBh6VdkF5igQ4PKkWQn 9MCAf5HoywI6UPpJS97wWS0pM2rgBZ/PIFwoNVzT1xdK1WKDfqhZAJt+ X-Gm-Gg: AZFdTZdPvdbXGHj5eUP+azttI/XRc3WC6BTYdyUDCDH4qTKRSjrB7OKen2WoKkLzMuA Qrq+YjmdF5D1rf7rRmYWBC/sg57srmE0SleMj7MmUWzXILpkiXWv1vVWyqNnCrOGpaQAVbDaF1W 7g1abiqM/h5y8uQymWsK7d2eekfaqkYy7/ENIpwEUWxXAArwaovlelQzCB/j4FAkRI0IvGs2/9U FD6nPjfIteiRopaxC6918bDnjObcZ8p6aV2gkPjCLCGkGFYiXVSIQYa97gIC3XJvfCW2LSBtkog nPDirhuaJltzTDvKNUdpFdiTuFsKmusYDQj1BbTfzonbRbSrEDqjQnyPLW2Wq/xrs8cGpECEPEq /oSy9lDPzwL8ZAXtRl/vBxqWSITAq/ORY9tDyUfFGsgsDbvR8jIIzdpy8qQU153x6VffixRUGKH v1w2n9iUJC4Qo2uW2J8+IehFmjbifeCR5J6gGKiL5SQgukUVgCINtOVEeomDZB0s+bRb7Ag5Zwx j3NcggCvZag8WVk7x3DXQdjFQDkf0NepuTJLRcLBCyEM1RWzBn7+67OhokSADN+f9clfpuX2A06 v0xIq/nWofdatOphQBmfeW5xcja+Qsf4tMD0dWaLUdQ/J4HoakzsArt7xEDGTb+h 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: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 > > > > > > >