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 B41C04C83; Mon, 23 Jun 2025 23:27:44 +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=1750721264; cv=none; b=MGQOn5NopY7U7lG6GKowncurw+iE+Lh/6VDIzyOBlu6yqaPLmNnk7yifdyXxEKryvzUdhzu95D4mytSz7pG4p8CxikrvGfNugvhcKZpN158KO75x89xSFSoBRhFmGYH8fD6y+FZg75u+ktr2qTavVuJEcx96y4G//diUUWTwS/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750721264; c=relaxed/simple; bh=EkXhrcleDOrAWV+vLVGauR+++glgCUMjevKJJH/V2+I=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=NllGBzu+P9Z77H7IzktRlHf99wnDvYvMTFFNWWGPWbi/EoCpjn6o9ghtkGGZTy30DboPk2mwWsNYh+Umo1C+W/TF17yIjwjBXWSkV3JPj7ZPkRGeBHCphbHUpeDvXTV+RxAGIoxrdKpaT87L20C2xfC7gnRNzL4KFOhsoT1ReFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TQ7U3QbY; 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="TQ7U3QbY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A81FFC4CEEA; Mon, 23 Jun 2025 23:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750721264; bh=EkXhrcleDOrAWV+vLVGauR+++glgCUMjevKJJH/V2+I=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=TQ7U3QbYplPJEbo+K21z0uvaH3Vdr5u1iRtXNeVFrbkPYpgQxY1PE/i4kRnkiIm87 XRcTwbg9YSveVE79+kCj8ZkAxP+uR4lcmc0wvjwa361uBMypj2JfSa/M66dtP3uGyn /Qy+0lclK/DO7Y+fAKiIj7QzMiuRqZhlBwx0MpHt/qWMoi5ygkIDL1hOZnt1X/5+v3 2Zkq/Q5KEf+iyVRZfh+9khhJkHPkjvy2jKNWlK81O1NH5NWJ5O8MEKtrRCvIsO5RRE eNmyI/nNo9Fc7ib1iYpQiyQwZ2jMcpVGGx5LSTMjfGujysrb1+DAUHhK2MufdgI1fT OFlaWbVdigmyA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 24 Jun 2025 01:27:38 +0200 Message-Id: Cc: , , , , "Miguel Ojeda" , "Alex Gaynor" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Will Deacon" , "Peter Zijlstra" , "Mark Rutland" , "Wedson Almeida Filho" , "Viresh Kumar" , "Lyude Paul" , "Ingo Molnar" , "Mitchell Levy" , "Paul E. McKenney" , "Greg Kroah-Hartman" , "Linus Torvalds" , "Thomas Gleixner" Subject: Re: [PATCH v5 04/10] rust: sync: atomic: Add generic atomics From: "Benno Lossin" To: "Boqun Feng" , "Gary Guo" X-Mailer: aerc 0.20.1 References: <20250618164934.19817-1-boqun.feng@gmail.com> <20250618164934.19817-5-boqun.feng@gmail.com> <20250621123212.66fb016b.gary@garyguo.net> <20250623193019.6c425467.gary@garyguo.net> In-Reply-To: On Mon Jun 23, 2025 at 9:09 PM CEST, Boqun Feng wrote: > On Mon, Jun 23, 2025 at 07:30:19PM +0100, Gary Guo wrote: >> cannot just transmute between from pointers to usize (which is its >> Repr): >> * Transmuting from pointer to usize discards provenance >> * Transmuting from usize to pointer gives invalid provenance >>=20 >> We want neither behaviour, so we must store `usize` directly and >> always call into repr functions. >>=20 > > If we store `usize`, how can we support the `get_mut()` then? E.g. > > static V: i32 =3D 32; > > let mut x =3D Atomic::new(&V as *const i32 as *mut i32); > // ^ assume we expose_provenance() in new(). > > let ptr: &mut *mut i32 =3D x.get_mut(); // which is `&mut self.0.get(= )`. > > let ptr_val =3D *ptr; // Does `ptr_val` have the proper provenance? If `get_mut` transmutes the integer into a pointer, then it will have the wrong provenance (it will just have plain invalid provenance). --- Cheers, Benno