From nobody Sat Sep 26 01:05:30 2026 Received: from mail-24416.protonmail.ch (mail-24416.protonmail.ch [109.224.244.16]) (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 22581420483 for ; Sun, 6 Sep 2026 10:28:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788690543; cv=none; b=jPleh75ow1tPzJqRgv8PlL1YGVbR+A9yKQQj/w2F/WtQ7oVDETOkzv4pMT/NTUCC4FXcqJddfHDcuJdgjS+Ar3sCw/V8XAq/qn7ayViTOl4Yd3Ye0120vd1fsQjvBWnmgJkCzK6laO8oqb8QtgE7pFRFM0fSewAo9KSFTCCz1tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788690543; c=relaxed/simple; bh=ynRHsB0rPgolb7fdfyRkCtQgSz+nlUJngxRzFWHzoKk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HoyT6wNtzVTBYwXgru51WGLluBIN5wKo/0MuhkYhVvvuEdOUdB8+pP+bYjsPRn7OpUBAnkWv1LFQRjBarFUUshbNOD5CPyvdLqpm48YVrIB+v0WiiNgLv9AMId8K6jQ5ABQXE3Dkk11twedNx4pOrfvQFKeekFyUek3FfpWQdlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=XBEc04Au; arc=none smtp.client-ip=109.224.244.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="XBEc04Au" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1788690536; x=1788949736; bh=tP659RLA9s5qNftKGJLlD1bl1sHOz2kkTiGEXzdTQ5c=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=XBEc04Au+VgILSvhkfcvwHnwdC2LDukix+pztumDnGJ308YOxZO5ZNNxl4KEOjfch FI0dgnk0MEmJAPIqhXTyVNKFd24yLKjaPcJFGg3khvaOgdiUPvcxJQai1IoRq6sTIS WHJ38aJvZAkRXhEHXWlkyYoNJKkKBG/VQaDpLY0ZkhAqqwaOy1AskDsS7PP7N2BYQu WWgLJ6b1O1jWt3F2bqOBXysrGR+qdMHByVphYAZvBBHupqlAwVz+5aheSUCXDzJQ+L y7Fcd4pWv5vGRCHTvFdZ9fE8p1KhMTfaGGCkhvH51pX0PoaVqWBeVqrO/owkOUENd6 iUe0A8vJd5vzg== Date: Sun, 06 Sep 2026 10:28:47 +0000 To: Miguel Ojeda , Danilo Krummrich From: Sagar Taunk Cc: Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S . Miller" , Simon Horman , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Andreas Hindborg , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Trevor Gross , Tamir Duberstein , Alexandre Courbot , =?utf-8?Q?Onur_=C3=96zkan?= , Greg Kroah-Hartman , driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sagar Taunk Subject: [PATCH v2 1/3] rust: net: netlink: Migrate to zerocopy's `IntoBytes` Message-ID: <20260906102826.202874-2-sagartaunk@proton.me> In-Reply-To: <20260906102826.202874-1-sagartaunk@proton.me> References: <20260906102826.202874-1-sagartaunk@proton.me> Feedback-ID: 130121444:user:proton X-Pm-Message-ID: 9e8ba046a928d64ad136061a529b4ed5de3c58b5 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" Replace remaining imports of kernel's own `transmute::FromBytes`/`AsBytes` traits with their zerocopy equivalent. In this case, `IntoBytes` which is already re-exported through kernel's prelude. Link: https://github.com/Rust-for-Linux/linux/issues/1241 Signed-off-by: Sagar Taunk --- rust/kernel/net/netlink.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/kernel/net/netlink.rs b/rust/kernel/net/netlink.rs index 22ef3dde36fa..c3b50dd50a4c 100644 --- a/rust/kernel/net/netlink.rs +++ b/rust/kernel/net/netlink.rs @@ -12,7 +12,6 @@ alloc::{self, AllocError}, error::to_result, prelude::*, - transmute::AsBytes, types::Opaque, ThisModule, }; @@ -84,7 +83,7 @@ impl GenlMsg { #[inline] fn put(&mut self, attrtype: c_int, value: &T) -> Result where - T: ?Sized + AsBytes, + T: ?Sized + IntoBytes, { let skb =3D self.skb.skb.as_ptr(); let len =3D size_of_val(value); --=20 2.55.0 From nobody Sat Sep 26 01:05:30 2026 Received: from mail-24418.protonmail.ch (mail-24418.protonmail.ch [109.224.244.18]) (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 821BB422556 for ; Sun, 6 Sep 2026 10:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788690562; cv=none; b=E4NOOrC9zIh0Gs6K0Xz+J7+XCpfxl6/aS8xPo6DYGaEXeRrHeqYcAZHv3mLH7g9H5ExPhbk1AkWQj1Tym+pa2BZhf3qsnDpruMasxblNpqV8/55U/PkLvZaz1AepWnScAFT+l0Ezf1ya0SSfS4dQRULkK7LOlBROzjGRGpZDcIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788690562; c=relaxed/simple; bh=1Ri6jWwNAKWKJpRPAfcZVQJ0GPmWeJJo7bFkWZHv8sw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a59cnRlB5JzZ9QPuOex7j2r2JRh8+pIJFG5CCBPUfqWkmM5pk2+J8R9HEfi9mbC3vDBaNuF4naHev3k15j+iDTA4lofw6+PkCMGnP1j0Fr8+RD96mq2Ndtexv3mHMC+oRr4s4dWVLmr6MNhr7PDYJD1f/foCbecSoymsVvg9kAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=iWmmOaG8; arc=none smtp.client-ip=109.224.244.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="iWmmOaG8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=5xsldwhxyndpbioxtjqkg3w3jm.protonmail; t=1788690550; x=1788949750; bh=/Y/AqUbNVZkajcwTPWzScwSYtBpnkVaFtxCp5vUyZqE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=iWmmOaG8iMFcjILQLysmKvPr+kydjPoPIeDLLsJmCOoZJESNxmgrVKBGlirOAUmC/ c3DbbKkuyRKAgmDpLZnuVMEIWMybFCu/owtoCvGgB57JZAz70SpWSR64xkdwNLLSLk MlnyFc7OpQUXhx/csslQipFm9JUbdh8g2ZBx5lqxVJi/dIhON36A8SczzwXswk0Lx1 c47pmbh5wJr29UBlZWe8whHe/U2UMDvKjkWDIln9Q6OipFd+TtXqIImsjFq5mdcKCj pPfvUO1/kChaOv8lEqyN3+rMlHhHFfWmmzQWD1MAc8k8F/sBHZsYRWCy1ddkAwMUbc 9DbttZJRRToqQ== Date: Sun, 06 Sep 2026 10:29:03 +0000 To: Miguel Ojeda , Danilo Krummrich From: Sagar Taunk Cc: Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S . Miller" , Simon Horman , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Andreas Hindborg , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Trevor Gross , Tamir Duberstein , Alexandre Courbot , =?utf-8?Q?Onur_=C3=96zkan?= , Greg Kroah-Hartman , driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sagar Taunk Subject: [PATCH v2 2/3] rust: uaccess: migrate to zerocopy's `Frombytes/IntoBytes` Message-ID: <20260906102826.202874-3-sagartaunk@proton.me> In-Reply-To: <20260906102826.202874-1-sagartaunk@proton.me> References: <20260906102826.202874-1-sagartaunk@proton.me> Feedback-ID: 130121444:user:proton X-Pm-Message-ID: 92510db30cc554a2ad5147f3f732f9f06e9d8cf7 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" Replace explicit imports of `transmute::FromBytes`/`AsBytes` marker traits with their zerocopy equivalents. Link: https://github.com/Rust-for-Linux/linux/issues/1241 Signed-off-by: Sagar Taunk --- rust/kernel/uaccess.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs index 5f6c4d7a1a51..d93c1a21f324 100644 --- a/rust/kernel/uaccess.rs +++ b/rust/kernel/uaccess.rs @@ -13,7 +13,6 @@ fs::file, prelude::*, ptr::KnownSize, - transmute::{AsBytes, FromBytes}, }; use core::mem::{size_of, MaybeUninit}; =20 @@ -525,7 +524,7 @@ pub fn write_slice(&mut self, data: &[u8]) -> Result { /// writer.write_dma(alloc, 0, 256) /// } /// ``` - pub fn write_dma( + pub fn write_dma( &mut self, alloc: &Coherent, offset: usize, @@ -599,7 +598,7 @@ pub fn write_slice_file(&mut self, data: &[u8], offset:= &mut file::Offset) -> Re /// Fails with [`EFAULT`] if the write happens on a bad address, or if= the write goes out of /// bounds of this [`UserSliceWriter`]. This call may modify the assoc= iated userspace slice even /// if it returns an error. - pub fn write(&mut self, value: &T) -> Result { + pub fn write(&mut self, value: &T) -> Result { let len =3D size_of::(); if len > self.length { return Err(EFAULT); --=20 2.55.0 From nobody Sat Sep 26 01:05:30 2026 Received: from mail-244123.protonmail.ch (mail-244123.protonmail.ch [109.224.244.123]) (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 2C7D539902B; Sun, 6 Sep 2026 10:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788690575; cv=none; b=YUrZjKgpc0WPy2cJ97suSVhES52bKZcHspvJ3kWBwBn8SijgcHJMpQDNprtaBoC3kYWttsXs7QFGQlV60H4Cj7blHi6a/0xhtX+oq5ZIxju/QseMUNWLzyYPL7tBr3llG/BNCfsNhJSKFE7Q3PNdP6leSWAH4I9WLim+7++uy3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788690575; c=relaxed/simple; bh=rRCH8gt/5mOkrlJvq466GnwekETqDZn0YclcWLINKjM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R/36x/cZhs/jw6DWpHYO+SwHerXRm2iMgqwIMczkm1zhVtM30Z9Yjm6Hlcx4dnMvIZ+DAVYshMTXQ/+ybEs4ea636TRvTUAqp+wXl/kkhiFTRQQs7PAmcNLiUI44QhM2JnSxf+ZN0BqI6Pc7P23cIM/VhX/sZU8qQs9cHxaR9bs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=XeFFx3iZ; arc=none smtp.client-ip=109.224.244.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="XeFFx3iZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1788690564; x=1788949764; bh=QcZeDQsDI8IiVvV9Mls8GpNfSv4icCfhUiY5ki37lz8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=XeFFx3iZOMlBRB0osVoQHp8FL6mr7gh/Aa7TIcVzsD9lYKVYE6e6hwQAM5TOzLMCT G9G1/tjYA9hbhsLDAo5vLx5fcIrHTOMZAvpI/gIAayZnXyYVCMFd5ao78YZEK1WYte X64zHT0wvJ3VnTm9sgt+38n1gziSKL4S0dK/N/L0kozGKGNLfPzWZIm2dYkeLWP30k 9XpPLIm5laksDHbAQLnn7d84sMQb5dOQ3V3nrnB7G4ZHzqjsE2wQR40zEjPNO1u63d LkW83q4M0utek52d284QpzO5/deD3h0swI+sGR2SfnpLNWAj2GpS2s7kXXhcD6/Z3R A2+74sjuNEx3w== Date: Sun, 06 Sep 2026 10:29:18 +0000 To: Miguel Ojeda , Danilo Krummrich From: Sagar Taunk Cc: Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S . Miller" , Simon Horman , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Andreas Hindborg , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Trevor Gross , Tamir Duberstein , Alexandre Courbot , =?utf-8?Q?Onur_=C3=96zkan?= , Greg Kroah-Hartman , driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sagar Taunk Subject: [PATCH v2 3/3] rust: dma.rs: Migrate to zerocopy's `Frombytes/IntoBytes` Message-ID: <20260906102826.202874-4-sagartaunk@proton.me> In-Reply-To: <20260906102826.202874-1-sagartaunk@proton.me> References: <20260906102826.202874-1-sagartaunk@proton.me> Feedback-ID: 130121444:user:proton X-Pm-Message-ID: 76b9c1b357a8041559dba81548bae2c6353a0efd 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" Replace explicit imports of `transmute::FromBytes`/`AsBytes` with zerocopy's equivalents. Link: https://github.com/Rust-for-Linux/linux/issues/1241 Signed-off-by: Sagar Taunk --- rust/kernel/dma.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs index 2ce09f8e90c6..9bd47f20c784 100644 --- a/rust/kernel/dma.rs +++ b/rust/kernel/dma.rs @@ -25,10 +25,6 @@ prelude::*, ptr::KnownSize, sync::aref::ARef, - transmute::{ - AsBytes, - FromBytes, // - }, uaccess::UserSliceWriter, // }; use core::{ @@ -417,7 +413,7 @@ fn from(direction: DataDirection) -> Self { /// ``` pub struct CoherentBox(Coherent); =20 -impl CoherentBox<[T]> { +impl CoherentBox<[T]> { /// [`CoherentBox`] variant of [`Coherent::zeroed_slice_with_attrs`]. #[inline] pub fn zeroed_slice_with_attrs( @@ -454,7 +450,7 @@ pub fn init_at(&mut self, i: usize, init: impl Init<= T, E>) -> Result =20 // SAFETY: // - `ptr` is valid, properly aligned, and within this allocation. - // - `T: AsBytes + FromBytes` guarantees all bit patterns are vali= d, so partial writes on + // - `T: IntoBytes + FromBytes` guarantees all bit patterns are va= lid, so partial writes on // error cannot leave the element in an invalid state. // - The DMA address has not been exposed yet, so there is no conc= urrent device access. unsafe { pin_init::raw_try_init(ptr, init)? }; @@ -523,7 +519,7 @@ pub fn from_slice( } } =20 -impl CoherentBox { +impl CoherentBox { /// Same as [`CoherentBox::zeroed_slice_with_attrs`], but for a single= element. #[inline] pub fn zeroed_with_attrs( @@ -554,7 +550,7 @@ fn deref(&self) -> &Self::Target { } } =20 -impl DerefMut for CoherentBox= { +impl DerefMut for CoherentB= ox { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { // SAFETY: @@ -565,7 +561,7 @@ fn deref_mut(&mut self) -> &mut Self::Target { } } =20 -impl From> for= Coherent { +impl From> f= or Coherent { #[inline] fn from(value: CoherentBox) -> Self { value.0 @@ -663,7 +659,7 @@ pub unsafe fn as_mut(&self) -> &mut T { } } =20 -impl Coherent { +impl Coherent { /// Allocates a region of `T` of coherent memory. fn alloc_with_attrs( dev: &device::Device, @@ -753,7 +749,7 @@ pub fn init_with_attrs( // SAFETY: // - `ptr` is valid, properly aligned, and points to exclusively o= wned memory. // - If `raw_try_init` fails, `self` is dropped, which safely free= s the underlying - // `Coherent`'s DMA memory. `T: AsBytes + FromBytes` ensures the= re are no complex `Drop` + // `Coherent`'s DMA memory. `T: IntoBytes + FromBytes` ensures t= here are no complex `Drop` // requirements we are bypassing. unsafe { pin_init::raw_try_init(ptr, init)? }; =20 @@ -948,9 +944,9 @@ unsafe impl Send for Cohe= rent {} // methods that access the buffer contents (`field_read`, `field_write`, `= as_slice`, // `as_slice_mut`) are `unsafe`, and callers are responsible for ensuring = no data races occur. // The safe methods only return metadata or raw pointers whose use require= s `unsafe`. -unsafe impl Sync for C= oherent {} +unsafe impl Sync for= Coherent {} =20 -impl debugfs::BinaryWriter for Coherent { +impl debugfs::BinaryWriter for Coherent= { fn write_to_slice( &self, writer: &mut UserSliceWriter, --=20 2.55.0