Re: [PATCH v5 02/20] rust: io: add missing safety requirement in `IoCapable` methods
"Alexandre Courbot" <[email protected]>
| Newsgroups | org.kernel.vger.linux-pwm,dev.linux.lists.driver-core,dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Fri Jun 26, 2026 at 11:45 PM JST, Gary Guo wrote:
<...>
> @@ -309,7 +312,11 @@ pub trait Io {
> // Always inline to optimize out error path of `build_assert`.
> #[inline(always)]
> fn io_addr_assert<U>(&self, offset: usize) -> usize {
> - build_assert!(offset_valid::<U>(offset, Self::Target::MIN_SIZE));
> + // We cannot check alignment with `offset_valid` using `self.addr()`. So set 0 for it and
> + // ensure alignment by checking that the alignment of `U` is smaller or equal to the
> + // alignment of `Self::Target`.
> + const_assert!(Alignment::of::<U>().as_usize() <= Self::Target::MIN_ALIGN.as_usize());
With `Region::MIN_ALIGN` being `4`, my understanding is that this will
make `read64` and other infallible 64-bit accessors unusable on untyped
I/O regions?