From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11964C02196 for ; Mon, 3 Feb 2025 15:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+XJsMs8duiyfW18oQDdYOd+ZSPQ34mkGtuf6T48Zr/U=; b=xwOX+wZ1Fo2bjQ LSsnmA+ZeiCY+Do6XY9C/Aher5e+3/9Q4xvMj2LXUT1vpBEPxS6nnbz+o/BBS+6b/kKwzTxkeWbNk sEpBmv7CQvIq+PfZ1AIrwlIUptde18Blg7WwWbDLlLRYBTBdh4tWvbETbySt8Yhx3nR1PrxiP4oOD YFB2zVwDsMavyVDxTPov5VjIr4HXBeUouDf5vvujsoi8KLjv/mTJ8gjLH1+R8WwglOrV0lQk4tlgY /uRohdB6EuIoIVdCCCmGCwm4525HdRw3VZ0BzzTwkcLyuc54yRT6nRy78qkm2T3iuv0wKn53cEqbz GQSSdXfWDi/OvHIp33QA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1teydO-0000000FuZc-05mJ; Mon, 03 Feb 2025 15:45:14 +0000 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1teyd4-0000000FuVJ-02aZ for linux-riscv@lists.infradead.org; Mon, 03 Feb 2025 15:44:55 +0000 Received: from hawking.nue2.suse.org (unknown [10.168.4.11]) by smtp-out2.suse.de (Postfix) with ESMTP id 70C621F381; Mon, 3 Feb 2025 15:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=lQXKuEEODvVX9SAns9BV/mPBaMxhgf2XJNtICeqN6nbpjMBZWo+aEmortLXgnLfK8V8n6G AAXDGBsir9tBQlI3RGTKLIzEEZfrutcC7ENYBBxU7t8lcpzxLVKWSOGHnfA5/e5kLn79eY OaLO7jEgkZ5C0rbz0CZc0R9Gtrspw18= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=OTNX7fVmyQbr4QWulI5iJ4zsgek4rKbs7iVUrbJPyVfRMLyd7VAPUfnPozl75k382ddCqt VZlaPEkPtpicnbCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=lQXKuEEODvVX9SAns9BV/mPBaMxhgf2XJNtICeqN6nbpjMBZWo+aEmortLXgnLfK8V8n6G AAXDGBsir9tBQlI3RGTKLIzEEZfrutcC7ENYBBxU7t8lcpzxLVKWSOGHnfA5/e5kLn79eY OaLO7jEgkZ5C0rbz0CZc0R9Gtrspw18= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=OTNX7fVmyQbr4QWulI5iJ4zsgek4rKbs7iVUrbJPyVfRMLyd7VAPUfnPozl75k382ddCqt VZlaPEkPtpicnbCA== Received: by hawking.nue2.suse.org (Postfix, from userid 17005) id 6098B4A0551; Mon, 3 Feb 2025 16:44:52 +0100 (CET) From: Andreas Schwab To: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg In-Reply-To: <87jza7oxep.fsf@all.your.base.are.belong.to.us> (=?utf-8?Q?=22Bj=C3=B6rn_T=C3=B6pel=22's?= message of "Mon, 03 Feb 2025 16:33:50 +0100") References: <87jza7oxep.fsf@all.your.base.are.belong.to.us> Date: Mon, 03 Feb 2025 16:44:52 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Spamd-Result: default: False [-4.20 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.988]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250203_074454_207333_A849229A X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org T24gRmViIDAzIDIwMjUsIEJqw7ZybiBUw7ZwZWwgd3JvdGU6Cgo+IEFuZHJlYXMgU2Nod2FiIDxz Y2h3YWJAc3VzZS5kZT4gd3JpdGVzOgo+Cj4+IE1ha2Ugc3VyZSB0aGUgY29tcGFyZSB2YWx1ZSBp biB0aGUgbHIvc2MgbG9vcCBpcyBzaWduIGV4dGVuZGVkIHRvIG1hdGNoCj4+IHdoYXQgbHIudyBk b2VzLiAgRm9ydHVuYXRlbHksIGR1ZSB0byB0aGUgY29tcGlsZXIga2VlcGluZyB0aGUgcmVnaXN0 ZXIKPj4gY29udGVudHMgc2lnbiBleHRlbmRlZCBhbnl3YXkgdGhlIGxhY2sgb2YgdGhlIGV4cGxp Y2l0IGV4dGVuc2lvbiBkaWRuJ3QKPj4gcmVzdWx0IGluIHdyb25nIGNvZGUgc28gZmFyLCBidXQg d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y5pbmZy YWRlYWQub3JnCmh0dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vbGlu dXgtcmlzY3YK From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78086433A4 for ; Mon, 3 Feb 2025 15:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738597496; cv=none; b=Qr9t3IWzYxcx+l9PzavwTqkjoZJqXHqQmdLR4BpZJIn+uBwBQaOht0pJ6jj8fVcN698U+77lATMQF27zoZ6PfZ9GMFWC1XiI+0LkQ+jR0++iQzvIY64/YdLLS4p5HqYKReVC1+XngSffZK58gDiOzQPOWRGyK2cAJzjl1MOYRvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738597496; c=relaxed/simple; bh=nh4Y7ByCUeK4CK2OL1IjDHZ5W27BHqm/ziCONx+3O3g=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=PyNbck9tNBuAVzZpcq5uKcIVj6OKV5OZizXRjPORzTMIiEqqI5IzstZMKlqSclx5XPCoTaSVyDawmJJZSUgrn9aPzZj7t0dpe/guqB4JHj1/aMAmMb050twUFfD40frDacmWmHXKW9qsZbZAYb8AOXexqXR9MKvlAStkVC+pBEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=lQXKuEEO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=OTNX7fVm; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=lQXKuEEO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=OTNX7fVm; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="lQXKuEEO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="OTNX7fVm"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="lQXKuEEO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="OTNX7fVm" Received: from hawking.nue2.suse.org (unknown [10.168.4.11]) by smtp-out2.suse.de (Postfix) with ESMTP id 70C621F381; Mon, 3 Feb 2025 15:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=lQXKuEEODvVX9SAns9BV/mPBaMxhgf2XJNtICeqN6nbpjMBZWo+aEmortLXgnLfK8V8n6G AAXDGBsir9tBQlI3RGTKLIzEEZfrutcC7ENYBBxU7t8lcpzxLVKWSOGHnfA5/e5kLn79eY OaLO7jEgkZ5C0rbz0CZc0R9Gtrspw18= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=OTNX7fVmyQbr4QWulI5iJ4zsgek4rKbs7iVUrbJPyVfRMLyd7VAPUfnPozl75k382ddCqt VZlaPEkPtpicnbCA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=lQXKuEEODvVX9SAns9BV/mPBaMxhgf2XJNtICeqN6nbpjMBZWo+aEmortLXgnLfK8V8n6G AAXDGBsir9tBQlI3RGTKLIzEEZfrutcC7ENYBBxU7t8lcpzxLVKWSOGHnfA5/e5kLn79eY OaLO7jEgkZ5C0rbz0CZc0R9Gtrspw18= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738597492; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U38BP1iA2Wv6XLn0cNaO7LCMdtkWZ8Pq3wyAGjQFYwU=; b=OTNX7fVmyQbr4QWulI5iJ4zsgek4rKbs7iVUrbJPyVfRMLyd7VAPUfnPozl75k382ddCqt VZlaPEkPtpicnbCA== Received: by hawking.nue2.suse.org (Postfix, from userid 17005) id 6098B4A0551; Mon, 3 Feb 2025 16:44:52 +0100 (CET) From: Andreas Schwab To: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg In-Reply-To: <87jza7oxep.fsf@all.your.base.are.belong.to.us> (=?utf-8?Q?=22Bj=C3=B6rn_T=C3=B6pel=22's?= message of "Mon, 03 Feb 2025 16:33:50 +0100") References: <87jza7oxep.fsf@all.your.base.are.belong.to.us> Date: Mon, 03 Feb 2025 16:44:52 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-4.20 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.988]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid] X-Spam-Score: -4.20 X-Spam-Flag: NO On Feb 03 2025, Björn Töpel wrote: > Andreas Schwab writes: > >> Make sure the compare value in the lr/sc loop is sign extended to match >> what lr.w does. Fortunately, due to the compiler keeping the register >> contents sign extended anyway the lack of the explicit extension didn't >> result in wrong code so far, but this cannot be relied upon. >> >> Fixes: b90edb33010b ("RISC-V: Add futex support.") >> Signed-off-by: Andreas Schwab > > Hmm, in this scenario we *can* rely on it, no (inline vs macro)? No, the issue is that the asm operand (oldval) is u32, but the asm is using the 64-bit value from the register. You cannot expect that the compiler keeps the upper half defined in any way at this point. That is different for the operand that is passed in from newval, because sc.w is only using the low 32-bits from the operand. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."