Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Infallible 64-bit I/O accesses (`read64`, `write64`, etc.) will fail 
to compile on 64-bit systems due to a failing `const_assert!` in 
`io_view_assert` (formerly `io_addr_assert`).
--

commit 9e28956aa7e8253fe2ab41dc7ddbf9af5d160ab2
Author: Gary Guo <[email protected]>

rust: io: restrict untyped IO access and register! to Region

This commit restricts untyped I/O accesses and the register macro to the Region
type. It adds a generic type to IoLoc to indicate allowed base types, paving
the way for typed register blocks.

Link: 
https://lore.kernel.org/rust-for-linux/[email protected]/

> diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs
> index d821ee48ed317..87141eb070564 100644
> --- a/rust/kernel/io.rs
> +++ b/rust/kernel/io.rs

[ ... ]

> @@ -437,6 +449,7 @@ fn read32(&self, offset: usize) -> u32
>      #[inline(always)]
>      fn read64(&self, offset: usize) -> u64
>      where
> +        usize: IoLoc<Self::Target, u64, IoType = u64>,
>          Self: IoCapable<u64>,
>      {
>          self.read(offset)

[Severity: High]
Does this regression cause a failure to compile when a driver invokes an
infallible 64-bit access method on 64-bit systems?

By restricting usize offsets to target Region, invoking an infallible 64-bit
access like read64(), write64(), or write_reg() with 64-bit registers
instantiates io_addr_assert() with U = u64.

Region has a hardcoded MIN_ALIGN of 4. The compile-time check explicitly
requires:

const_assert!(Alignment::of::<U>().as_usize() <= 
Self::Target::MIN_ALIGN.as_usize());

On 64-bit architectures, align_of::<u64>() is 8. Thus, 8 <= 4 evaluates to
false, causing an immediate unconditional compilation error for any driver
attempting to perform an infallible 64-bit MMIO access. Fallible variants
like try_read64() use runtime alignment checks and are unaffected.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to