Skip to contentSkip to conversation

About VFIO Device Pass-through on Qemu.

DISCUSSION tugouxp 2 participants 2 messages Jul 5, 2024

lore
Share & tools
lore

tugouxp

author
#0 lore raw

Hi folks:

I have a questions about device vfio pass-through usage snarios, PCI device pass-throug for example. did the GPA that host physical memory mapped to Guest vcpu through MMU must be identical with the IOVA that host physical memory mapped to gust device thourgh iommu? if so, that will be convenient for driver developer, because then can share data physical address between device and share memory. but is this true? is this the
pass-through user manner?

my thought: it will be very convent for driver developer if GPA == IOVA. because theuy are all "physical" on Guest, will offer a consistent view of memory resource for vCPU and vDevice, but is this true?

VCPU:
GVA----(MMU)----GPA-------(+offset)----->HVA------>(MMU)----->HPA. Device in Guest:
IOVA---->(IOMMU)---->HPA

Thankyou !
BRs
zlcao.

#1 lore raw
Quoted 7 lines · On Fri, 5 Jul 2024 17:08:49 +0800 (CST) tugouxp <[email protected]> wrote:

Hi folks:

I have a questions about device vfio pass-through usage snarios,
PCI device pass-throug for example. did the GPA that host physical memory mapped to Guest vcpu through MMU must be identical with the IOVA that host physical memory mapped to gust device thourgh iommu?

I'm having trouble parsing that wording, but without a vIOMMU the device operates in the GPA address space, so IOVA == GPA.

Quoted 3 lines

if so, that will be convenient for driver developer, because then can share data physical address between device and share memory. but is this true? is this the pass-through user manner?

If you're asking about a shared DMA memory buffer between devices, yes, without a vIOMMU the buffer GPA (IOVA) would be the same between devices. Also note that device MMIO is mapped into the device address space, so depending on the underlying host support for peer-to-peer DMA there might be a working "direct" path between devices (where "direct" means bounced through the IOMMU).

Quoted 10 lines

my thought: it will be very convent for driver developer if GPA == IOVA. because theuy are all "physical" on Guest, will offer a consistent view of memory resource for vCPU and vDevice, but is this true?

VCPU:
GVA----(MMU)----GPA-------(+offset)----->HVA------>(MMU)----->HPA. Device in Guest:
IOVA---->(IOMMU)---->HPA

Yes. In fact this is the only way we can do transparent device assignment without a paravirtualized DMA layer is to use the IOMMU to map the device into the GPA address space. Also the fixed IOVA/GPA to HPA mapping in the IOMMU is what necessitates memory pinning. Thanks,

Alex