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

From: Jason Gunthorpe
Date: Tue Dec 12 2023 - 13:12:04 EST


On Tue, Dec 12, 2023 at 05:46:34PM +0000, Catalin Marinas wrote:
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index a422cc123a2d..8d3c4820c492 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -391,6 +391,13 @@ extern unsigned int kobjsize(const void *objp);
> > # define VM_UFFD_MINOR VM_NONE
> > #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */
> >
> > +#ifdef CONFIG_64BIT
> > +#define VM_VFIO_ALLOW_WC_BIT 39 /* Convey KVM to map S2 NORMAL_NC */
>
> This comment shouldn't be in the core header file. It knows nothing
> about S2 and Normal-NC, that's arm64 terminology. You can mention
> something like VFIO can use this flag hint that write-combining is
> allowed.

Let's write a comment down here to address both remarks:

This flag is used to connect VFIO to arch specific KVM code. It
indicates that the memory under this VMA is safe for use with any
non-cachable memory type inside KVM. Some VFIO devices, on some
platforms, are thought to be unsafe and can cause machine crashes if
KVM does not lock down the memory type.

> should know the implications. There's also an expectation that the
> actual driver (KVM guests) or maybe later DPDK can choose the safe
> non-cacheable or write-combine (Linux terminology) attributes for the
> BAR.

DPDK won't rely on this interface

Thanks,
Jason