[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250919104123.7c6ba069.alex.williamson@redhat.com>
Date: Fri, 19 Sep 2025 10:41:23 -0600
From: Alex Williamson <alex.williamson@...hat.com>
To: Ajay Garg <ajaygargnsit@...il.com>
Cc: iommu@...ts.linux-foundation.org, linux-pci@...r.kernel.org, Linux
Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: How are iommu-mappings set up in guest-OS for
dma_alloc_coherent
On Thu, 18 Sep 2025 23:24:19 +0530
Ajay Garg <ajaygargnsit@...il.com> wrote:
> Hi everyone.
>
> Let's say we have a following setup :
>
> i)
> x86_64 host-os, booted up with iommu enabled and pass-through mode.
>
> ii)
> x86_64 guest-os, booted up using vfio+qemu+kvm and a pci-device attached to it.
>
> iii)
> A guest-os-device-driver calls "dma_alloc_coherent", after which the
> returned dma-address / iova is programmed to the pci-device's
> mmio-register.
>
>
> In the above case, how are the IOMMU mappings set up during the
> guest-os-device-driver's "dma_alloc_coherent" call?
> Does :
>
> a)
> The VMM / KVM intercept the "dma_alloc_coherent" call, and use the
> host-iommu to set up things?
>
> OR
>
> b)
> There is no interception from VMM / KVM, but rather the guest-OS
> itself has a view of the IOMMU (through the regular ACPI tables
> populated during guest boot up)?
>
> OR
>
> c)
> Anything else under the hood?
>
>
> Will be grateful for clearing the haze.
Depends on details not revealed about the VM configuration.
If the VM is configured without a vIOMMU or the vIOMMU is inactive in
the guest, all of the guest physical memory is pinned and mapped
through the physical IOMMU when the guest is started. Nothing happens
regarding the IOMMU when a coherent mapping is created in the guest,
it's already setup.
If there is an active vIOMMU in the VM, then the guest act of
programming the IOMMU results in mappings through to the host IOMMU.
This is a result of the IOMMU emulation in the VM. Thanks,
Alex
Powered by blists - more mailing lists