freebsd-nq/sys/amd64
Bjoern A. Zeeb dd113f67df bhyve: Do not remove guest physical addresses from IOMMU host domain
This permits I/O devices on the host to directly access wired memory
dedicated to guests using passthru devices.  Note that wired memory
belonging to guests that do not use passthru devices has always been
accessible by I/O devices on the host.

bhyve maps guest physical addresses into the user address space of
the bhyve process by mmap'ing /dev/vmm/<vmname>.  Device models pass
pointers derived from this mapping directly to system calls such as
preadv() to minimize copies when emulating DMA.  If the backing store
for a device model is a raw host device (e.g. when exporting a raw disk
device such as /dev/ada<n> as a drive in the guest), the host device
driver (e.g. ahci for /dev/ada<n>) can itself use DMA on the host
directly to the guest's memory.  However, if the guest's memory is
not present in the host IOMMU domain, these DMA requests by the host
device will fail without raising an error visible to the host device
driver or to the guest resulting in non-working I/O in the guest.

It is unclear why guest addresses were removed from the IOMMU host domain
initially, especially only for VM's with a passthru device as the
host IOMMU domain does not affect the permissions of passthru devices,
only devices on the host.

A considered alternative was using bounce buffers instead (D34535
is a proof of concept), but that adds additional overhead for unclear
benefit.

This solves a long-standing problem when using passthru devices and
physical disks in the same VM.

Thanks to:	grehan (patience and help)
Thanks to:	jhb (for improving the commit message)
PR:		260178, 215740
Reviewed by:	grehan, jhb
Differential Revision: https://reviews.freebsd.org/D34607

(cherry picked from commit 246c398145)
2022-03-27 17:57:28 +00:00
..
acpica amd64 wakeup: rework trampoline page allocation 2021-09-20 03:47:21 +03:00
amd64 amd64: micro-optimize vptopte()/vtopde() further 2022-02-09 02:42:44 +02:00
cloudabi32 Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead. 2020-09-27 18:47:06 +00:00
cloudabi64 Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead. 2020-09-27 18:47:06 +00:00
conf smbios: support getting address from EFI 2022-03-03 08:20:07 -06:00
ia32 exec: Introduce the PROC_PS_STRINGS() macro 2022-01-31 09:46:57 -05:00
include smbios: support getting address from EFI 2022-03-03 08:20:07 -06:00
linux linux: Make PTRACE_GETREGSET return proper buffer size 2022-02-21 13:36:23 +00:00
linux32 linux: refactor bsd_to_linux_regset() out of linux_ptrace.c 2022-02-21 12:46:06 +00:00
pci pci_cfgreg.c: Use io port config access for early boot time. 2019-04-09 18:07:17 +00:00
sgx Convert remaining cap_rights_init users to cap_rights_init_one 2021-01-12 13:16:10 +00:00
vmm bhyve: Do not remove guest physical addresses from IOMMU host domain 2022-03-27 17:57:28 +00:00
Makefile Bring the tags and links entries for amd64 up to date. 2021-10-07 16:01:46 -07:00