[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4a48338e-64a1-4740-ae1f-7458507a009e@gmail.com>
Date: Thu, 10 Apr 2025 12:02:37 +0300
From: Abdiel Janulgue <abdiel.janulgue@...il.com>
To: Alexandre Courbot <acourbot@...dia.com>, a.hindborg@...nel.org,
ojeda@...nel.org
Cc: Danilo Krummrich <dakr@...nel.org>,
Daniel Almeida <daniel.almeida@...labora.com>,
Robin Murphy <robin.murphy@....com>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
"open list:DMA MAPPING HELPERS DEVICE DRIVER API [RUST]"
<rust-for-linux@...r.kernel.org>, Marek Szyprowski
<m.szyprowski@...sung.com>,
"open list:DMA MAPPING HELPERS" <iommu@...ts.linux.dev>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] rust: dma: add as_slice/write functions for
CoherentAllocation
Hi Alex,
On 08/04/2025 06:08, Alexandre Courbot wrote:
>> + }
>> + // SAFETY:
>> + // - The pointer is valid due to type invariant on `CoherentAllocation`
>> + // and we've just checked that the range and index is within bounds.
>> + // - `offset` can't overflow since it is smaller than `self.count` and we've checked
>> + // that `self.count` won't overflow early in the constructor.
>> + unsafe {
>> + core::ptr::copy_nonoverlapping(src.as_ptr(), self.cpu_addr.add(offset), src.len())
>> + };
>
> How about leveraging as_slice_mut() so this unsafe block can be removed?
as_slice_mut is still unsafe, no? So we couldn't remove unsafe block still?
Thanks,
Abdiel
Powered by blists - more mailing lists