All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex@shazbot.org>
To: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Cc: "Cédric Le Goater" <clg@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"Nicolin Chen" <nicolinc@nvidia.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	alex@shazbot.org
Subject: Re: [PATCH] vfio/region: Skip IOMMU mapping for BARs when dma-buf is unavailable
Date: Mon, 30 Nov 2026 13:32:47 -0700	[thread overview]
Message-ID: <20261130133247.204c6c44@shazbot.org> (raw)
In-Reply-To: <LV2PR12MB5410252DFFAED76FE8DE32D61EAB4E2@LV2PR12MB541025.namprd12.prod.outlook.com>

On Mon, 30 Nov 2026 19:27:21 +0000
Shameer Kolothum Thodi <skolothumtho@nvidia.com> wrote:

> > -----Original Message-----
> > From: Cédric Le Goater <clg@redhat.com>
> > Sent: 30 November 2026 18:54
> > To: qemu-devel@nongnu.org
> > Cc: qemu-arm@nongnu.org; Alex Williamson <alex@shazbot.org>; Shameer
> > Kolothum Thodi <skolothumtho@nvidia.com>; Nicolin Chen
> > <nicolinc@nvidia.com>; Eric Auger <eric.auger@redhat.com>
> > Subject: Re: [PATCH] vfio/region: Skip IOMMU mapping for BARs when dma-
> > buf is unavailable
> > 
> > External email: Use caution opening links or attachments
> > 
> > 
> > On 11/6/26 15:51, Cédric Le Goater wrote:  
> > > When the kernel does not support the VFIO_DEVICE_FEATURE_DMA_BUF
> > > feature (e.g. old kernel or out-of-tree vGPU driver),
> > > vfio_region_create_dma_buf() returns with a warning and no fd is
> > > assigned to the BAR RAMBlocks. Later, when the VFIO listener tries
> > > to DMA-map these BAR regions, the iommufd backend falls back to
> > > IOMMU_IOAS_MAP with a vaddr pointing at device MMIO. The kernel  
> > cannot  
> > > pin device memory and fails with EFAULT on aarch64, producing these
> > > warnings:
> > >
> > >    qemu-kvm: warning: VFIO dma-buf not supported in kernel, using mmap  
> > fallback, P2P DMA will not work  
> > >    qemu-kvm: warning: IOMMU_IOAS_MAP failed: Bad address, PCI BAR?
> > >    qemu-kvm: warning: vfio_container_dma_map(0xaaabb9621a90,  
> > 0x88400000000, 0x10000, 0xfffe50100000) = -14 (Bad address)  
> > >    hostdev0: PCI peer-to-peer transactions on BARs are not supported.
> > >
> > > memory_region_set_skip_iommu_map() was recently introduced by commit
> > > 11b9798c7b52 ("memory: Allow RAM device regions to skip IOMMU
> > > mapping") for the Tegra CMDQV case. Use it to mark BAR mmap regions
> > > when dma-buf is unavailable so the VFIO listener skips them. This
> > > drops the last three messages and covers both the iommufd and legacy
> > > Type1 IOMMU backends.
> > >
> > > Cc: Shameer Kolothum <skolothumtho@nvidia.com>
> > > Cc: Nicolin Chen <nicolinc@nvidia.com>
> > > Cc: Eric Auger <eric.auger@redhat.com>
> > > Fixes: 8cfaf22668c7 ("hw/vfio/region: Create dmabuf for PCI BAR per  
> > region")  
> 
> But the last three warn messages predate 8cfaf22668c7, right?
> 
> Also, 11b9798c7b52 ("memory: Allow RAM device regions to skip IOMMU
> mapping") is a prerequisite which landed later.
> 
> > > Signed-off-by: Cédric Le Goater <clg@redhat.com>
> > > ---
> > >   hw/vfio/region.c | 3 +++
> > >   1 file changed, 3 insertions(+)
> > >
> > > diff --git a/hw/vfio/region.c b/hw/vfio/region.c
> > > index  
> > 996bc523edfe10bd256f5b09dec45cb5c9f543f0..4148d0ea8e35496e4c5a2
> > bf97d1ef6974df7ccbb 100644  
> > > --- a/hw/vfio/region.c
> > > +++ b/hw/vfio/region.c
> > > @@ -362,6 +362,9 @@ static bool  
> > vfio_region_create_dma_buf(VFIORegion *region, Error **errp)  
> > >           if (ret == -ENOTTY) {
> > >               warn_report_once("VFIO dma-buf not supported in kernel, "
> > >                                "using mmap fallback, P2P DMA will not work");
> > > +            for (i = 0; i < region->nr_mmaps; i++) {
> > > +                memory_region_set_skip_iommu_map(&region->mmaps[i].mem,  
> > true);  
> 
> This will affect the legacy VFIO path as well now. I can't recollect whether
> that had support for mapping these regions or not. Please check.

Yes, and it seems to go against the whole warning.  If dma-buf support
isn't present we fall back to legacy VFIO_IOMMU_MAP_DMA when we're
using the type1 backend.  That can DMA map against the mmap, but only
if we let it by not telling the listener to skip the mapping.

The existing warning is also misleading, falling back to mmap is a
perfectly functional option for P2P DMA to work in a legacy container.
Thanks,

Alex


  reply	other threads:[~2026-11-30 20:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 14:51 [PATCH] vfio/region: Skip IOMMU mapping for BARs when dma-buf is unavailable Cédric Le Goater
2026-11-30 18:53 ` Cédric Le Goater
2026-11-30 19:27   ` Shameer Kolothum Thodi
2026-11-30 20:32     ` Alex Williamson [this message]
2026-12-01  7:49       ` Cédric Le Goater
2026-12-01  7:49     ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130133247.204c6c44@shazbot.org \
    --to=alex@shazbot.org \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=nicolinc@nvidia.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=skolothumtho@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.