* [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed
@ 2026-06-29 20:10 Nicolás Antinori
2026-06-30 1:14 ` Alexandre Courbot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nicolás Antinori @ 2026-06-29 20:10 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon
Cc: Nicolás Antinori, Alexandre Courbot, Alice Ryhl,
Andreas Hindborg, Benno Lossin, Björn Roy Baron, Boqun Feng,
Daniel Almeida, Danilo Krummrich, Gary Guo, Miguel Ojeda,
Onur Özkan, Robin Murphy, Shuah Khan, Tamir Duberstein,
Trevor Gross, linux-kernel, rust-for-linux, iommu,
linux-kernel-mentees
All types in `bindings` implement `Zeroable` if they can. This enables
using `Zeroable::zeroed` for `io_pgtable_cfg` initialization instead
of relying on `..unsafe { core::mem::zeroed() }`.
This change improves readability and removes an unnecessary unsafe
block.
Link: https://github.com/Rust-for-Linux/linux/issues/1189
Suggested-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
---
Changelog:
v2: replaced `..pin_init::zeroed()` with `..Zeroable::zeroed()` as
discussed in v1 thread.
v1:
https://lore.kernel.org/rust-for-linux/20260626203122.713317-1-nico.antinori.7@gmail.com/T/#u
rust/kernel/iommu/pgtable.rs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/rust/kernel/iommu/pgtable.rs b/rust/kernel/iommu/pgtable.rs
index c88e38fd938a..eddda8d9d62a 100644
--- a/rust/kernel/iommu/pgtable.rs
+++ b/rust/kernel/iommu/pgtable.rs
@@ -102,8 +102,7 @@ pub unsafe fn new_raw(dev: &Device<Bound>, config: Config) -> Result<IoPageTable
coherent_walk: config.coherent_walk,
tlb: &raw const NOOP_FLUSH_OPS,
iommu_dev: dev.as_raw(),
- // SAFETY: All zeroes is a valid value for `struct io_pgtable_cfg`.
- ..unsafe { core::mem::zeroed() }
+ ..Zeroable::zeroed()
};
// SAFETY:
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed
2026-06-29 20:10 [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed Nicolás Antinori
@ 2026-06-30 1:14 ` Alexandre Courbot
2026-07-02 11:06 ` Alice Ryhl
2026-07-02 11:11 ` Gary Guo
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Courbot @ 2026-06-30 1:14 UTC (permalink / raw)
To: Nicolás Antinori
Cc: Joerg Roedel, Will Deacon, Alice Ryhl, Andreas Hindborg,
Benno Lossin, Björn Roy Baron, Boqun Feng, Daniel Almeida,
Danilo Krummrich, Gary Guo, Miguel Ojeda, Onur Özkan,
Robin Murphy, Shuah Khan, Tamir Duberstein, Trevor Gross,
linux-kernel, rust-for-linux, iommu, linux-kernel-mentees
On Tue Jun 30, 2026 at 5:10 AM JST, Nicolás Antinori wrote:
> All types in `bindings` implement `Zeroable` if they can. This enables
> using `Zeroable::zeroed` for `io_pgtable_cfg` initialization instead
> of relying on `..unsafe { core::mem::zeroed() }`.
>
> This change improves readability and removes an unnecessary unsafe
> block.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1189
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed
2026-06-29 20:10 [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed Nicolás Antinori
2026-06-30 1:14 ` Alexandre Courbot
@ 2026-07-02 11:06 ` Alice Ryhl
2026-07-02 11:11 ` Gary Guo
2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2026-07-02 11:06 UTC (permalink / raw)
To: Nicolás Antinori
Cc: Joerg Roedel, Will Deacon, Alexandre Courbot, Andreas Hindborg,
Benno Lossin, Björn Roy Baron, Boqun Feng, Daniel Almeida,
Danilo Krummrich, Gary Guo, Miguel Ojeda, Onur Özkan,
Robin Murphy, Shuah Khan, Tamir Duberstein, Trevor Gross,
linux-kernel, rust-for-linux, iommu, linux-kernel-mentees
On Mon, Jun 29, 2026 at 05:10:41PM -0300, Nicolás Antinori wrote:
> All types in `bindings` implement `Zeroable` if they can. This enables
> using `Zeroable::zeroed` for `io_pgtable_cfg` initialization instead
> of relying on `..unsafe { core::mem::zeroed() }`.
>
> This change improves readability and removes an unnecessary unsafe
> block.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1189
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Joerg, is this cleanup you can pick up? Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed
2026-06-29 20:10 [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed Nicolás Antinori
2026-06-30 1:14 ` Alexandre Courbot
2026-07-02 11:06 ` Alice Ryhl
@ 2026-07-02 11:11 ` Gary Guo
2 siblings, 0 replies; 4+ messages in thread
From: Gary Guo @ 2026-07-02 11:11 UTC (permalink / raw)
To: Nicolás Antinori, Joerg Roedel, Will Deacon
Cc: Alexandre Courbot, Alice Ryhl, Andreas Hindborg, Benno Lossin,
Björn Roy Baron, Boqun Feng, Daniel Almeida,
Danilo Krummrich, Gary Guo, Miguel Ojeda, Onur Özkan,
Robin Murphy, Shuah Khan, Tamir Duberstein, Trevor Gross,
linux-kernel, rust-for-linux, iommu, linux-kernel-mentees
On Mon Jun 29, 2026 at 9:10 PM BST, Nicolás Antinori wrote:
> All types in `bindings` implement `Zeroable` if they can. This enables
> using `Zeroable::zeroed` for `io_pgtable_cfg` initialization instead
> of relying on `..unsafe { core::mem::zeroed() }`.
>
> This change improves readability and removes an unnecessary unsafe
> block.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1189
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Acked-by: Gary Guo <gary@garyguo.net>
> ---
> Changelog:
> v2: replaced `..pin_init::zeroed()` with `..Zeroable::zeroed()` as
> discussed in v1 thread.
> v1:
> https://lore.kernel.org/rust-for-linux/20260626203122.713317-1-nico.antinori.7@gmail.com/T/#u
>
> rust/kernel/iommu/pgtable.rs | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-02 11:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 20:10 [PATCH v2] rust: iommu: replace core::mem::zeroed with Zeroable::zeroed Nicolás Antinori
2026-06-30 1:14 ` Alexandre Courbot
2026-07-02 11:06 ` Alice Ryhl
2026-07-02 11:11 ` Gary Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox