Re: [PATCH v2 16/20] vfio/cxl: Register regions with VFIO layer
From: Dan Williams
Date: Sat Apr 04 2026 - 15:37:02 EST
Jason Gunthorpe wrote:
> On Fri, Apr 03, 2026 at 12:35:45PM -0700, Dan Williams wrote:
> > > + /*
> > > + * CXL device memory is RAM, not MMIO. Use memremap() rather than
> >
> > Right, CXL.mem is RAM, not MMIO, so I question why is this not being
> > mapped via a RAM mechanism? Can you explain a bit more about why reusing
> > vfio MMIO mapping mechanisms is suitable here and what happens when we
> > get to questions like guest_memfd integration, page conversions, and
> > large page mapping support?
>
> None of that is applicable to VFIO. VFIO owns the entire address space
> and does not share it with the mm or anything else.
I was worried less about sharing and more about how the map eventually
gets used, but makes sense all of that is enabled through the VFIO VMA.
I have more reading to do in this space.
> > Maybe this is the start of the conversation for something simple, but I
> > would actually prefer uncached ioremap() if only to avoid all the
> > coherence management and suitability of MMIO mechanisms questions.
>
> The entire thing needs to be mmapable in a cache coherent way since
> that is what the HW semantic is. If you try to do something else you
> will break KVM support since it follows the VMA.
Then I assume it matters that memremap() sometimes silently falls back
to the direct map. The "VFIO owns" expectation needs to guard against
some helpful platform firmware mapping accelerator memory as System RAM.
At a minimum having VFIO fail to map in that case helps with the
argument I have been making that "no, EFI_CONVENTIONAL_MEMORY type +
EFI_SPECIFIC_PURPOSE flag" is not suitable for accelerators with private
CXL memory. Those want to be enforcing "EFI_RESERVED".