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 BA08528A1D5; Tue, 22 Jul 2025 12:09:00 +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=1753186140; cv=none; b=vGqpjUkXwCvePqcPV+Ge2O7+genlAFts4xD3SWotQNjt9GZKqDMwVdLVZ2iSLJpD0/AuRe6M6A9OTQKoAB0T5InblGGPoidL00yPsqb+6YYbbFCDGPyoDAcyCByizZmOvHzDDXC6Gmti0GX+jUeEKokOrZkmSULRmIFXf3Ys1zA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753186140; c=relaxed/simple; bh=9tnk65GQHOuj2Pt0uMyPZaXg1fEIkfzRLOs6t+AmPis=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=Jy3lOXzzlEnozqfG2iqGAAvwbZjpjc+bdJCD5jKPBAhoo5S7cOZCpJLT5Fh2JeynmRxb7+4DM6KoRJl+axbiZcMttZzx6MMZ6W1WxuFXlGbr4Nocno5wFpeO0b0foUnYOVA8gzKrx6cwWXSZb+F/JVe+LuG72hjvFjJIGleQ218= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tgh1FQ8v; 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="tgh1FQ8v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6439C4CEEB; Tue, 22 Jul 2025 12:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753186140; bh=9tnk65GQHOuj2Pt0uMyPZaXg1fEIkfzRLOs6t+AmPis=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=tgh1FQ8vA1ApjRpCVZoxwWfdsxjI65drnmgyfCudJMagNtFQiuyKiPPzx0V6+D2eA ELWFlOlAJRPfiaf8Yk5ZbcSDY8Ea/W5OQYqTm9vc/MN7P6Lx31Suw9+PbFcwhwxDyj XkkQC4A6/WkcRpCHDKWrfEVxjYTNYp+UX+HZPaJu7dm2QXDWXi86C7P1n/48fWRzf8 JgGnHqqOl1fhVjpgsaEF3y6A8TBoulnI8kcImHn1GUf1zpnUSILEx6ychMLLlJtsdA r0Zcla4jJPEq+Zy+6NwIo6sfFT5/vnMyuyDeT+4l56928DE5ZJOUPqdMwACmH+j3Uh fnML9SCe9s1YA== Precedence: bulk X-Mailing-List: rust-for-linux@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, 22 Jul 2025 14:08:55 +0200 Message-Id: Cc: "Danilo Krummrich" , "Alistair Popple" , , "Bjorn Helgaas" , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Trevor Gross" , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "John Hubbard" , "Alexandre Courbot" , , Subject: Re: [PATCH v2 1/2] rust: Update PCI binding safety comments and add inline compiler hint From: "Benno Lossin" To: "Alice Ryhl" X-Mailer: aerc 0.20.1 References: <20250710022415.923972-1-apopple@nvidia.com> In-Reply-To: On Tue Jul 22, 2025 at 1:35 PM CEST, Alice Ryhl wrote: > On Tue, Jul 22, 2025 at 12:57=E2=80=AFPM Benno Lossin = wrote: >> >> On Tue Jul 22, 2025 at 11:51 AM CEST, Danilo Krummrich wrote: >> > I think they're good, but we're pretty late in the cycle now. That sho= uld be >> > fine though, we can probably take them through the nova tree, or in th= e worst >> > case share a tag, if needed. >> > >> > Given that, it would probably be good to add the Guarantee section on = as_raw(), >> > as proposed by Benno, right away. >> > >> > @Benno: Any proposal on what this section should say? >> >> At a minimum I'd say "The returned pointer is valid.", but that doesn't >> really say for what it's valid... AFAIK you're mostly using this pointer >> to pass it to the C side, in that case, how about: >> >> /// # Guarantees >> /// >> /// The returned pointer is valid for reads and writes from the C si= de for as long as `self` exists. >> >> Maybe we need to change it a bit more, but let's just start with this. >> >> (If you're also using the pointer from Rust, then we need to make >> changes) > > Honestly I think this is a bit over the top. I wouldn't bother adding > a section like that to every single as_raw() method out there. Hmm. And then just assume that these kinds of functions return valid pointers? I get that this is annoying to put on every function... Another option would be to have a `Ptr<'a, T>` type that is a valid pointer, but doesn't allow writing/reading safely (you need to justify why it's not a data race). And for FFI there could be an `as_ptr` function. --- Cheers, Benno