VFIO device gets DMA failures when virtio-balloon leak from highmem to lowmem
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Is there any known conflict between VFIO passthrough device and virtio-balloon?
The VM has:
1. 4GB system memory
2. one VFIO passthrough device which supports high address memory DMA and uses GFP_HIGHUSER pages.
3. Memory balloon device with 4GB target.
When setting the memory balloon target to 1GB and 4GB in loop during runtime (I used the command "virsh qemu-monitor-
More clues:
1. configure 2GB system memory (no highmem) VM, no issue with similar operations
2. setting the memory balloon to higher like 8GB, no issue with similar operations
I'm also trying to narrow down this issue. It's appreciated for that you guys may share some thoughts.
Ballooning is currently incompatible with device assignment. When the balloon is inflated (memory removed from the VM), the pages are zapped from the process without actually removing them from the vfio DMA mapping. The pages are still pinned from the previous mapping, making the balloon inflation ineffective (pages are not available for re-use). When the balloon is deflated, new (different) pages are faulted in for the previously zapped pages, but these are again not DMA mapped for the IOMMU, so now the physical memory backing a given address in the VM are different for processor and assigned device access and DMA will fail. In order to support this, QEMU would need to do more than simply zap pages from the process address space, they'd need to be unmapped from the IOMMU, but we can only do that using the original mapping size. Effectively, memory hotplug is a better solution when device assignment is involved.