qemu/include/hw
David Gibson 3898aad323 vfio: Check guest IOVA ranges against host IOMMU capabilities
The current vfio core code assumes that the host IOMMU is capable of
mapping any IOVA the guest wants to use to where we need.  However, real
IOMMUs generally only support translating a certain range of IOVAs (the
"DMA window") not a full 64-bit address space.

The common x86 IOMMUs support a wide enough range that guests are very
unlikely to go beyond it in practice, however the IOMMU used on IBM Power
machines - in the default configuration - supports only a much more limited
IOVA range, usually 0..2GiB.

If the guest attempts to set up an IOVA range that the host IOMMU can't
map, qemu won't report an error until it actually attempts to map a bad
IOVA.  If guest RAM is being mapped directly into the IOMMU (i.e. no guest
visible IOMMU) then this will show up very quickly.  If there is a guest
visible IOMMU, however, the problem might not show up until much later when
the guest actually attempt to DMA with an IOVA the host can't handle.

This patch adds a test so that we will detect earlier if the guest is
attempting to use IOVA ranges that the host IOMMU won't be able to deal
with.

For now, we assume that "Type1" (x86) IOMMUs can support any IOVA, this is
incorrect, but no worse than what we have already.  We can't do better for
now because the Type1 kernel interface doesn't tell us what IOVA range the
IOMMU actually supports.

For the Power "sPAPR TCE" IOMMU, however, we can retrieve the supported
IOVA range and validate guest IOVA ranges against it, and this patch does
so.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2015-10-05 12:38:13 -06:00
..
acpi hw/arm/virt: Add gic-version option to virt machine 2015-09-24 01:29:37 +01:00
arm hw/arm/virt: Add gic-version option to virt machine 2015-09-24 01:29:37 +01:00
audio isa: QOM'ify ISADevice 2013-06-07 14:55:33 +02:00
block BlockConf: Call backend functions to detect geometry and blocksizes 2015-03-10 14:02:22 +01:00
char i.MX: Split UART emulator in a header file and a source file 2015-08-13 11:26:19 +01:00
cpu icc_bus: QOM'ify ICC 2013-12-24 18:02:18 +01:00
cris cris: Remove the CRIS PIC glue 2014-02-03 14:04:00 +00:00
gpio i.MX: Add GPIO device 2015-09-14 14:39:49 +01:00
i2c i.MX: Add I2C controller emulator 2015-09-07 10:39:30 +01:00
i386 pc: memhp: force gaps between DIMM's GPA 2015-10-02 17:04:32 +03:00
input input: switch hid mouse and tablet to the new input layer api. 2014-05-26 08:42:43 +02:00
intc hw/intc: Implement GIC-500 base class 2015-09-24 01:29:36 +01:00
ipack ipack: Move IndustryPack out of hw/char/ 2014-02-14 21:11:53 +01:00
isa i8257: remove cpu_request_exit irq 2015-09-09 15:34:53 +02:00
kvm hw: move headers to include/ 2013-04-08 18:13:10 +02:00
lm32 hmp: Name HMP info handler functions hmp_info_SUBCOMMAND() 2015-02-18 11:58:50 +01:00
m68k hw: move headers to include/ 2013-04-08 18:13:10 +02:00
mem memhp: extend address auto assignment to support gaps 2015-10-02 17:04:32 +03:00
mips net/dp8393x: QOM'ify 2015-06-11 10:13:30 +01:00
misc i.MX: Split CCM emulator in a header file and a source file 2015-08-13 11:26:20 +01:00
net i.MX: Add FEC Ethernet Emulator 2015-09-07 10:39:30 +01:00
nvram fw_cfg: remove support for guest-side data writes 2015-06-10 08:00:37 +02:00
pci hw/pci-assign: split pci-assign.c 2015-09-10 12:04:27 +00:00
pci-host spapr: Merge sPAPREnvironment into sPAPRMachineState 2015-07-07 17:44:50 +02:00
ppc ppc/spapr: Implement H_RANDOM hypercall in QEMU 2015-09-23 10:51:11 +10:00
s390x s390/sclp: store the increment_size in the sclp device 2015-09-07 16:10:44 +02:00
scsi esp: Do not overwrite ESP_TCHI after reset 2014-11-12 10:27:03 +01:00
sh4 sh7750: Change cpu field type to SuperHCPU 2013-04-13 13:51:45 +02:00
smbios smbios: add smbios 3.0 support 2015-09-07 10:39:28 +01:00
sparc QOM infrastructure fixes and device conversions 2015-03-02 13:20:43 +00:00
timer hpet: remove muldiv64() 2015-09-25 14:56:05 +02:00
tricore target-tricore: Add board for systemmode 2014-09-01 14:49:20 +01:00
unicore32 hw: move headers to include/ 2013-04-08 18:13:10 +02:00
usb usb: move ehci register defines to header file 2014-06-02 16:28:59 +02:00
vfio vfio: Check guest IOVA ranges against host IOMMU capabilities 2015-10-05 12:38:13 -06:00
virtio virtio: introduce virtqueue_discard() 2015-10-01 16:16:52 +03:00
watchdog s390x/watchdog: introduce diag288 watchdog device 2015-06-11 17:45:49 +02:00
xen xen-2015-09-10 2015-09-10 18:25:52 +01:00
boards.h machine: Eliminate QEMUMachine and qemu_register_machine() 2015-09-19 16:40:30 +02:00
bt.h Preparation for usb-bt-dongle conditional build 2013-09-10 11:14:41 +02:00
compat.h pc: Introduce pc-*-2.5 machine classes 2015-09-24 13:42:00 +03:00
devices.h arm: fix location of some include files 2013-04-15 15:16:01 +02:00
elf_ops.h elf: Update EM_MOXIE definition 2015-09-25 12:04:43 +02:00
empty_slot.h hw: move headers to include/ 2013-04-08 18:13:10 +02:00
fw-path-provider.h fw-path-provider: Change GPL version to 2+ 2014-04-07 15:36:07 +02:00
hotplug.h misc: Fix new typos in comments 2015-01-15 10:44:13 +03:00
hw.h bootdevice: move code about bootorder from vl.c to bootdevice.c 2014-12-22 14:39:20 +08:00
ide.h Call pci_piix3_xen_ide_unplug from unplug_disks 2014-02-20 17:28:08 +00:00
irq.h irq: Remove qemu_irq_intercept_out 2014-10-23 16:41:25 +02:00
loader.h vl: move rom_load_all after machine init done 2015-07-07 11:03:16 +02:00
nmi.h nmi: Implement inject_nmi() for non-monitor context use 2015-06-11 17:45:50 +02:00
pcmcia.h hmp: Remove "info pcmcia" 2014-10-24 12:19:11 +01:00
platform-bus.h sysbus: Add new platform bus helper device 2014-11-04 23:26:14 +01:00
ptimer.h vmstate: Make VMSTATE_STRUCT_POINTER take type, not ptr-to-type 2014-02-04 15:51:45 +01:00
qdev-core.h qdev: Un-deprecate qdev_init_nofail() 2015-06-19 19:14:32 +02:00
qdev-dma.h qdev: Remove hex8/32/64 property types 2014-02-14 21:12:04 +01:00
qdev-properties.h qdev: fix 64 bit properties 2015-07-13 14:42:24 +03:00
qdev.h hw: move headers to include/ 2013-04-08 18:13:10 +02:00
sd.h hw: Convert from BlockDriverState to BlockBackend, mostly 2014-10-20 14:02:25 +02:00
ssi.h ssi: Name the CS GPIO 2014-05-28 17:36:21 +02:00
stream.h Trivial grammar and spelling fixes 2013-05-01 20:55:21 +04:00
sysbus.h sysbus: add irq_routing_notifier 2015-07-06 12:15:14 -06:00
usb.h usb: Remove unused functions 2015-04-30 16:05:48 +03:00