* [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs
@ 2026-03-21 17:27 Danilo Krummrich
2026-03-21 18:42 ` Gary Guo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Danilo Krummrich @ 2026-03-21 17:27 UTC (permalink / raw)
To: abdiel.janulgue, daniel.almeida, robin.murphy, a.hindborg, ojeda,
boqun, gary, bjorn3_gh, lossin, aliceryhl, tmgross
Cc: driver-core, rust-for-linux, linux-kernel, Danilo Krummrich,
stable
When DMA_ATTR_NO_KERNEL_MAPPING is passed to dma_alloc_attrs(), the
returned CPU address is not a pointer to the allocated memory but an
opaque handle (e.g. struct page *).
Coherent<T> (or CoherentAllocation<T> respectively) stores this value as
NonNull<T> and exposes methods that dereference it and even modify its
contents.
Remove the flag from the public attrs module such that drivers cannot
pass it to Coherent<T> (or CoherentAllocation<T> respectively) in the
first place.
Instead DMA_ATTR_NO_KERNEL_MAPPING can be supported with an additional
opaque type (e.g. CoherentHandle) which does not provide access to the
allocated memory.
Cc: stable@vger.kernel.org
Fixes: ad2907b4e308 ("rust: add dma coherent allocator abstraction")
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
rust/kernel/dma.rs | 3 ---
1 file changed, 3 deletions(-)
diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 6d2bec52806b..9e0c9ff91cba 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -264,9 +264,6 @@ pub mod attrs {
/// Specifies that writes to the mapping may be buffered to improve performance.
pub const DMA_ATTR_WRITE_COMBINE: Attrs = Attrs(bindings::DMA_ATTR_WRITE_COMBINE);
- /// Lets the platform to avoid creating a kernel virtual mapping for the allocated buffer.
- pub const DMA_ATTR_NO_KERNEL_MAPPING: Attrs = Attrs(bindings::DMA_ATTR_NO_KERNEL_MAPPING);
-
/// Allows platform code to skip synchronization of the CPU cache for the given buffer assuming
/// that it has been already transferred to 'device' domain.
pub const DMA_ATTR_SKIP_CPU_SYNC: Attrs = Attrs(bindings::DMA_ATTR_SKIP_CPU_SYNC);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs
2026-03-21 17:27 [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs Danilo Krummrich
@ 2026-03-21 18:42 ` Gary Guo
2026-03-22 11:07 ` Alice Ryhl
2026-03-22 14:52 ` Alexandre Courbot
2 siblings, 0 replies; 4+ messages in thread
From: Gary Guo @ 2026-03-21 18:42 UTC (permalink / raw)
To: Danilo Krummrich, abdiel.janulgue, daniel.almeida, robin.murphy,
a.hindborg, ojeda, boqun, gary, bjorn3_gh, lossin, aliceryhl,
tmgross
Cc: driver-core, rust-for-linux, linux-kernel, stable
On Sat Mar 21, 2026 at 5:27 PM GMT, Danilo Krummrich wrote:
> When DMA_ATTR_NO_KERNEL_MAPPING is passed to dma_alloc_attrs(), the
> returned CPU address is not a pointer to the allocated memory but an
> opaque handle (e.g. struct page *).
>
> Coherent<T> (or CoherentAllocation<T> respectively) stores this value as
> NonNull<T> and exposes methods that dereference it and even modify its
> contents.
>
> Remove the flag from the public attrs module such that drivers cannot
> pass it to Coherent<T> (or CoherentAllocation<T> respectively) in the
> first place.
>
> Instead DMA_ATTR_NO_KERNEL_MAPPING can be supported with an additional
> opaque type (e.g. CoherentHandle) which does not provide access to the
> allocated memory.
>
> Cc: stable@vger.kernel.org
> Fixes: ad2907b4e308 ("rust: add dma coherent allocator abstraction")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/dma.rs | 3 ---
> 1 file changed, 3 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs
2026-03-21 17:27 [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs Danilo Krummrich
2026-03-21 18:42 ` Gary Guo
@ 2026-03-22 11:07 ` Alice Ryhl
2026-03-22 14:52 ` Alexandre Courbot
2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2026-03-22 11:07 UTC (permalink / raw)
To: Danilo Krummrich
Cc: abdiel.janulgue, daniel.almeida, robin.murphy, a.hindborg, ojeda,
boqun, gary, bjorn3_gh, lossin, tmgross, driver-core,
rust-for-linux, linux-kernel, stable
On Sat, Mar 21, 2026 at 6:27 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> When DMA_ATTR_NO_KERNEL_MAPPING is passed to dma_alloc_attrs(), the
> returned CPU address is not a pointer to the allocated memory but an
> opaque handle (e.g. struct page *).
>
> Coherent<T> (or CoherentAllocation<T> respectively) stores this value as
> NonNull<T> and exposes methods that dereference it and even modify its
> contents.
>
> Remove the flag from the public attrs module such that drivers cannot
> pass it to Coherent<T> (or CoherentAllocation<T> respectively) in the
> first place.
>
> Instead DMA_ATTR_NO_KERNEL_MAPPING can be supported with an additional
> opaque type (e.g. CoherentHandle) which does not provide access to the
> allocated memory.
>
> Cc: stable@vger.kernel.org
> Fixes: ad2907b4e308 ("rust: add dma coherent allocator abstraction")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs
2026-03-21 17:27 [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs Danilo Krummrich
2026-03-21 18:42 ` Gary Guo
2026-03-22 11:07 ` Alice Ryhl
@ 2026-03-22 14:52 ` Alexandre Courbot
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Courbot @ 2026-03-22 14:52 UTC (permalink / raw)
To: Danilo Krummrich
Cc: abdiel.janulgue, daniel.almeida, robin.murphy, a.hindborg, ojeda,
boqun, gary, bjorn3_gh, lossin, aliceryhl, tmgross, driver-core,
rust-for-linux, linux-kernel, stable
On Sun Mar 22, 2026 at 2:27 AM JST, Danilo Krummrich wrote:
> When DMA_ATTR_NO_KERNEL_MAPPING is passed to dma_alloc_attrs(), the
> returned CPU address is not a pointer to the allocated memory but an
> opaque handle (e.g. struct page *).
>
> Coherent<T> (or CoherentAllocation<T> respectively) stores this value as
> NonNull<T> and exposes methods that dereference it and even modify its
> contents.
>
> Remove the flag from the public attrs module such that drivers cannot
> pass it to Coherent<T> (or CoherentAllocation<T> respectively) in the
> first place.
>
> Instead DMA_ATTR_NO_KERNEL_MAPPING can be supported with an additional
> opaque type (e.g. CoherentHandle) which does not provide access to the
> allocated memory.
>
> Cc: stable@vger.kernel.org
> Fixes: ad2907b4e308 ("rust: add dma coherent allocator abstraction")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-22 14:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 17:27 [PATCH 1/2] rust: dma: remove DMA_ATTR_NO_KERNEL_MAPPING from public attrs Danilo Krummrich
2026-03-21 18:42 ` Gary Guo
2026-03-22 11:07 ` Alice Ryhl
2026-03-22 14:52 ` Alexandre Courbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox