[PATCH v3 2/2] kvm: arm64: set io memory s2 pte as normalnc for vfio pci devices

Catalin Marinas catalin.marinas at arm.com
Wed Jan 3 05:33:15 PST 2024


On Tue, Jan 02, 2024 at 01:09:08PM -0400, Jason Gunthorpe wrote:
> On Thu, Dec 21, 2023 at 01:19:18PM +0000, Catalin Marinas wrote:
> > If we really want to avoid any aliases (though I think we are spending
> > too many cycles on something that's not a real issue), the only way is
> > to have fd-based mappings in KVM so that there's no VMM alias. After
> > that we need to choose between (2) and (3) since the VMM may no longer
> > be able to probe the device and figure out which ranges need what
> > attributes.
> 
> If we use a FD then KVM will be invoking some API on the FD to get the
> physical memory addreses and we can have that API also return
> information on the allowed memory types.

I think the part with a VFIO WC flag wouldn't be any different. The
fd-based mapping only solves the mismatched alias, otherwise the
decision for Normal NC vs Device still lies with the guest driver.

> > > Kinda stinks to make the VMM aware of the device, but IMO it is a
> > > fundamental limitation of the way we back memslots right now.
> > 
> > As I mentioned above, the limitation may be more complex if the
> > intra-BAR attributes are not something readily available in the device
> > documentation. Maybe Jason or Ankit can shed some light here: are those
> > intra-BAR ranges configurable by the (guest) driver or they are already
> > pre-configured by firmware and the driver only needs to probe them?
> 
> Configured by the guest on the fly, on a page by page basis.
> 
> There is no way for the VMM to pre-predict what memory type the VM
> will need. The VM must be in control of this.

That's a key argument why the VMM cannot do this, unless we come up with
some para-virtualised interface and split the device configuration logic
between the VMM and the VM. I don't think that's feasible, too much
complexity.

-- 
Catalin



More information about the linux-arm-kernel mailing list