From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C60B2326944; Thu, 29 Jan 2026 01:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769649687; cv=none; b=UzJ3//WKgF5GQ3vbsl4fGB0gXEtGhpP7q4py9n34QsTrhmUGP80YPYuao8STnnGBlA9TcIqVAgzsxccGStkJRQiZ4WAcYn6pcdtPUrBUS3ZNOCS87RxuoFQlbJnxjb1QPKt0OqNmssYL76G3be4I/ygDz9pdml/KR1N3jOjIplg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769649687; c=relaxed/simple; bh=T131svMu2T3ISOZCqIcwsEXJug1tYGuujwIwl9rBKfg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gn0JMSUyLQTfI/PkZfg8V9YHh4kwmaVq1x77wTLnpEOx1D03Zv5HWVoGoAEcAc6Y4nXyQT2DKoV4oe0Qu0Rhazz+NNyx87NHh2SqVerMLzjdFtHT1sE+eiGG6aDiCtWTOX2k88py6ZHGFDyK2Hit2LBkRm29yyoxYOUCqoouC/o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ao8jMlci; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ao8jMlci" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FA24C4CEF1; Thu, 29 Jan 2026 01:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769649687; bh=T131svMu2T3ISOZCqIcwsEXJug1tYGuujwIwl9rBKfg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ao8jMlciFjG/h68WfinfE4v/z5xPoxsTvbDrKSu69RUh4ufknA8/TMKu1dOPPD9Rn 90oj8KngFyQQWlnwJi4Cg/StF5Ri6meN/nUzeC2w3qSwEANpE1LWow3G2e/GI+TiIO rPwFhPtTU3YAjLshLOX/4LejkKHv1VQNTHhVpK8AmSsvXFoslfOsmnLhRAyispehJ0 VFSk7tRWvPvHI9tc0WlN/aaij+bBYaZ5WZ3YCLblYaIemSQ8IWKoXWJMBLM5P8wsdK 2AdMSjzruOlwhU9Hw24BHx06O7iHSzkBJwFOX0aJRYWO4hNKj4v+LeFCOI9N9yShhJ YGzE64w5KbIkg== Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfauth.phl.internal (Postfix) with ESMTP id 56B0FF40068; Wed, 28 Jan 2026 20:21:26 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Wed, 28 Jan 2026 20:21:26 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduieegkeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunheskhgvrhhnvghlrdhorhhgqeenucggtffrrghtthgvrhhnpe ekgffhhfeuheelhfekteeuffejveetjeefffettedtteegfefftdduteduudfgleenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnod hmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduieejtdelkeegjeduqddujeej keehheehvddqsghoqhhunheppehkvghrnhgvlhdrohhrghesfhhigihmvgdrnhgrmhgvpd hnsggprhgtphhtthhopeduhedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvghl vhgvrhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepphgvthgvrhiisehinhhfrhgrug gvrggurdhorhhgpdhrtghpthhtohepfihilhhlsehkvghrnhgvlhdrohhrghdprhgtphht thhopehmihhnghhosehkvghrnhgvlhdrohhrghdprhgtphhtthhopehtghhlgieslhhinh huthhrohhnihigrdguvgdprhgtphhtthhopegsohhquhhnrdhfvghnghesghhmrghilhdr tghomhdprhgtphhtthhopehlohhnghhmrghnsehrvgguhhgrthdrtghomhdprhgtphhtth hopegsvhgrnhgrshhstghhvgesrggtmhdrohhrghdprhgtphhtthhopehllhhvmheslhhi shhtshdrlhhinhhugidruggvvh X-ME-Proxy: Feedback-ID: i8dbe485b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jan 2026 20:21:25 -0500 (EST) Date: Wed, 28 Jan 2026 17:21:24 -0800 From: Boqun Feng To: Marco Elver Cc: Peter Zijlstra , Will Deacon , Ingo Molnar , Thomas Gleixner , Boqun Feng , Waiman Long , Bart Van Assche , llvm@lists.linux.dev, Catalin Marinas , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2 1/3] arm64: Fix non-atomic __READ_ONCE() with CONFIG_LTO=y Message-ID: References: <20260129005645.747680-1-elver@google.com> <20260129005645.747680-2-elver@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260129005645.747680-2-elver@google.com> On Thu, Jan 29, 2026 at 01:52:32AM +0100, Marco Elver wrote: > The implementation of __READ_ONCE() under CONFIG_LTO=y incorrectly > qualified the fallback "once" access for types larger than 8 bytes, > which are not atomic but should still happen "once" and suppress common > compiler optimizations. > > The cast `volatile typeof(__x)` applied the volatile qualifier to the > pointer type itself rather than the pointee. This created a volatile > pointer to a non-volatile type, which violated __READ_ONCE() semantics. > > Fix this by casting to `volatile typeof(*__x) *`. I guess a `volatile typeof(x) *` also works. Either way, good catch! Reviewed-by: Boqun Feng Regards, Boqun > > With a defconfig + LTO + debug options build, we see the following > functions to be affected: > > xen_manage_runstate_time (884 -> 944 bytes) > xen_steal_clock (248 -> 340 bytes) > ^-- use __READ_ONCE() to load vcpu_runstate_info structs > > Fixes: e35123d83ee3 ("arm64: lto: Strengthen READ_ONCE() to acquire when CONFIG_LTO=y") > Cc: > Signed-off-by: Marco Elver > --- > arch/arm64/include/asm/rwonce.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h > index 78beceec10cd..fc0fb42b0b64 100644 > --- a/arch/arm64/include/asm/rwonce.h > +++ b/arch/arm64/include/asm/rwonce.h > @@ -58,7 +58,7 @@ > default: \ > atomic = 0; \ > } \ > - atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(__x))__x);\ > + atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(*__x) *)__x);\ > }) > > #endif /* !BUILD_VDSO */ > -- > 2.53.0.rc1.217.geba53bf80e-goog >