On Wed Sep 9, 2026 at 5:59 AM CEST, Eliot Courtney wrote:
> +impl PteOps for Pte {
> +    fn from_raw(val: u64) -> Self {
> +        Self::from_raw(val)
> +    }
> +
> +    fn invalid() -> Self {
> +        Self::zeroed()
> +    }
> +
> +    fn new(aperture: AperturePte, pfn: Pfn, writable: bool) -> Self {
> +        let base = Self::zeroed()
> +            .with_valid(true)
> +            .with_aperture(aperture)
> +            .with_read_only(!writable);
> +        match aperture {
> +            AperturePte::VideoMemory => base.with_frame_number_vid(pfn),
> +            // Sysmem PTEs use VOL=1 to bypass L2 for cache coherency.
> +            AperturePte::SystemCoherent => 
> base.with_frame_number_sys(pfn).with_volatile(true),
> +            AperturePte::PeerMemory | AperturePte::SystemNonCoherent => {
> +                kernel::pr_warn!("MMU v2 PTE aperture {:?} not supported\n", 
> aperture);
> +                Self::invalid()
> +            }

This looks pretty odd. The aperture argument should either be of a type that can
only contain valid Aperture variants (which might be tricky as v2 and v3 are
different) or the constructor should just be fallible. The same goes for the v3
code and the Pde code.

Besides that, please don't use pr_*() print primitives, please use dev_*()
instead. But with this being fallible there's no more reason to warn here.

Reply via email to