qemu-patch-raspberry4/hw
Alex Williamson c65ee43315 vfio: Inhibit ballooning based on group attachment to a container
We use a VFIOContainer to associate an AddressSpace to one or more
VFIOGroups.  The VFIOContainer represents the DMA context for that
AdressSpace for those VFIOGroups and is synchronized to changes in
that AddressSpace via a MemoryListener.  For IOMMU backed devices,
maintaining the DMA context for a VFIOGroup generally involves
pinning a host virtual address in order to create a stable host
physical address and then mapping a translation from the associated
guest physical address to that host physical address into the IOMMU.

While the above maintains the VFIOContainer synchronized to the QEMU
memory API of the VM, memory ballooning occurs outside of that API.
Inflating the memory balloon (ie. cooperatively capturing pages from
the guest for use by the host) simply uses MADV_DONTNEED to "zap"
pages from QEMU's host virtual address space.  The page pinning and
IOMMU mapping above remains in place, negating the host's ability to
reuse the page, but the host virtual to host physical mapping of the
page is invalidated outside of QEMU's memory API.

When the balloon is later deflated, attempting to cooperatively
return pages to the guest, the page is simply freed by the guest
balloon driver, allowing it to be used in the guest and incurring a
page fault when that occurs.  The page fault maps a new host physical
page backing the existing host virtual address, meanwhile the
VFIOContainer still maintains the translation to the original host
physical address.  At this point the guest vCPU and any assigned
devices will map different host physical addresses to the same guest
physical address.  Badness.

The IOMMU typically does not have page level granularity with which
it can track this mapping without also incurring inefficiencies in
using page size mappings throughout.  MMU notifiers in the host
kernel also provide indicators for invalidating the mapping on
balloon inflation, not for updating the mapping when the balloon is
deflated.  For these reasons we assume a default behavior that the
mapping of each VFIOGroup into the VFIOContainer is incompatible
with memory ballooning and increment the balloon inhibitor to match
the attached VFIOGroups.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2018-08-17 09:27:16 -06:00
..
9pfs 9p: darwin: Explicitly cast comparisons of mode_t with -1 2018-06-29 12:32:10 +02:00
acpi nvdimm: make persistence option symbolic 2018-06-11 22:19:57 +03:00
adc Include qapi/error.h exactly where needed 2018-02-09 13:50:17 +01:00
alpha hw/alpha: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
arm hw/arm/mps2-tz: Replace init_sysbus_child() with sysbus_init_child_obj() 2018-08-16 14:29:58 +01:00
audio audio/hda: Fix migration 2018-07-24 17:02:02 +01:00
block block: Remove deprecated -drive option serial 2018-08-15 12:50:39 +02:00
bt hw/bt: Replace fprintf(stderr, "*\n" with error_report() 2018-01-22 09:51:00 +01:00
char Bug fixes. 2018-07-17 17:06:32 +01:00
core loader: Implement .hex file loader 2018-08-16 14:05:28 +01:00
cpu hw/*/realview: Fix introspection problem with 'realview_mpcore' & 'realview_gic' 2018-07-17 13:12:49 +01:00
cris hw/cris: Use the IEC binary prefix definitions 2018-07-02 15:41:15 +02:00
display virtio-gpu: fix crashes upon warm reboot with vga mode 2018-08-07 15:03:58 +01:00
dma hw/dma/omap_dma: Use qemu_log_mask(GUEST_ERROR) instead of fprintf 2018-06-26 17:50:40 +01:00
gpio hw/i2c: Use DeviceClass::realize instead of I2CSlaveClass::init 2018-06-01 15:14:31 +02:00
hppa hw/hppa: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
i2c ppc4xx_i2c: Rewrite to model hardware more closely 2018-07-03 09:56:52 +10:00
i386 pc: acpi: fix memory hotplug regression by reducing stub SRAT entry size 2018-08-03 11:35:21 +03:00
ide block: Remove deprecated -drive option serial 2018-08-15 12:50:39 +02:00
input hw/input/tsc2005: Convert a fprintf() call to trace events 2018-06-29 15:04:18 +01:00
intc target/arm: Provide accessor functions for HCR_EL2.{IMO, FMO, AMO} 2018-08-14 17:17:21 +01:00
ipack hw/ipack: Use the IEC binary prefix definitions 2018-07-02 15:41:12 +02:00
ipmi object: fix OBJ_PROP_LINK_UNREF_ON_RELEASE ambivalence 2018-06-12 12:07:30 +02:00
isa hw/isa/smc37c669: Change the parallel I/O base to 378H 2018-06-16 19:46:54 -10:00
lm32 hw/lm32: Use the IEC binary prefix definitions 2018-07-02 15:41:15 +02:00
m68k hw/m68k: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
mem pc-dimm: get_memory_region() will not fail after realize 2018-06-28 19:05:34 +02:00
microblaze hw/microblaze/xlnx-zynqmp-pmu: Fix introspection problem in 'xlnx, zynqmp-pmu-soc' 2018-07-23 15:21:25 +01:00
mips * IEC units series (Philippe) 2018-07-02 19:07:19 +01:00
misc aspeed: add a max_ram_size property to the memory controller 2018-08-16 14:29:58 +01:00
moxie Change references to serial_hds[] to serial_hd() 2018-04-26 13:57:00 +01:00
net e1000e: Prevent MSI/MSI-X storms 2018-07-20 08:30:48 +08:00
nios2 hw/nios2: Use the IEC binary prefix definitions 2018-07-02 15:41:15 +02:00
nvram hw/ppc: Use the IEC binary prefix definitions 2018-07-02 15:41:16 +02:00
openrisc Change references to serial_hds[] to serial_hd() 2018-04-26 13:57:00 +01:00
pci virtio,vhost,pci,pc: features, cleanups 2018-03-20 15:48:34 +00:00
pci-bridge virtio,vhost,pci,pc: features, fixes and cleanups 2018-02-13 16:33:31 +00:00
pci-host hw/ppc: Use the IEC binary prefix definitions 2018-07-02 15:41:16 +02:00
pcmcia hw: Clean up includes 2016-01-29 15:07:25 +00:00
ppc sam460ex: Fix PCI interrupts with multiple devices 2018-08-01 11:01:38 +10:00
rdma hw/rdma: Use the IEC binary prefix definitions 2018-07-02 15:41:17 +02:00
riscv spike: Fix crash when introspecting the device 2018-07-19 09:05:48 -07:00
s390x s390x/sclp: fix maxram calculation 2018-07-30 17:41:52 +02:00
scsi block: Remove deprecated -drive option serial 2018-08-15 12:50:39 +02:00
sd hw/sd/bcm2835_sdhost: Fix PIO mode writes 2018-07-23 15:21:26 +01:00
sh4 hw/sh4: Use the IEC binary prefix definitions 2018-07-02 15:41:15 +02:00
smbios hw/smbios: Use the IEC binary prefix definitions 2018-07-02 15:41:12 +02:00
sparc * IEC units series (Philippe) 2018-07-02 19:07:19 +01:00
sparc64 * IEC units series (Philippe) 2018-07-02 19:07:19 +01:00
ssi imx_spi: Unset XCH when TX FIFO becomes empty 2018-08-16 14:29:57 +01:00
timer hw/timer/cmsdk-apb-timer: run or stop timer on writes to RELOAD and VALUE 2018-07-09 14:51:34 +01:00
tpm tpm: extend TPM TIS with state migration support 2018-05-24 12:07:04 -04:00
tricore hw/tricore: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
unicore32 hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
usb block: Remove deprecated -drive option serial 2018-08-15 12:50:39 +02:00
vfio vfio: Inhibit ballooning based on group attachment to a container 2018-08-17 09:27:16 -06:00
virtio kvm: Use inhibit to prevent ballooning without synchronous mmu 2018-08-17 09:27:15 -06:00
watchdog hw/watchdog/wdt_i6300esb: Convert away from old_mmio 2018-06-15 15:23:34 +01:00
xen xen: Don't use memory_region_init_ram_nomigrate() in pci_assign_dev_load_option_rom() 2018-06-22 13:28:42 +01:00
xenpv hw/xen: Use the IEC binary prefix definitions 2018-07-02 15:41:13 +02:00
xtensa hw/xtensa: Use the IEC binary prefix definitions 2018-07-02 15:41:14 +02:00
Makefile.objs hw: allow compiling out SCSI 2018-06-01 15:14:31 +02:00