Re: [PATCH V2 3/7] dax/fsdev: fix kaddr for multi-range and fail probe on invalid pgmap offset
From: John Groves
Date: Fri May 29 2026 - 20:05:00 EST
On 26/05/26 04:31PM, Dave Jiang wrote:
>
>
> On 5/22/26 12:19 PM, John Groves wrote:
> > From: John Groves <John@xxxxxxxxxx>
> >
> > Two fixes for virtual address handling in fsdev:
> >
> > 1. Use __va(phys) instead of virt_addr + linear_offset for the kaddr
> > return in __fsdev_dax_direct_access(). The previous code added a
> > device-linear byte offset to virt_addr (which is __va of ranges[0]),
> > but for multi-range devices with physical gaps between ranges, this
> > linear arithmetic crosses the gap and produces a wrong kernel virtual
> > address. Using __va(phys) where phys comes from dax_pgoff_to_phys()
> > is correct for any range layout because the direct map translates
> > each physical address independently.
> >
> > 2. Convert the WARN_ON to a fatal error when pgmap_phys > phys. This
> > condition means the remapped region starts after the device's data
> > region, which is an impossible state. Previously the probe continued
> > with data_offset=0, leaving virt_addr silently misaligned. Now probe
> > returns -EINVAL with a diagnostic message.
>
> Split to 2 different patches I'd say.
>
> DJ
Agree - done. Thanks!
John
<snip>