freebsd-dev/sys/amd64/vmm
Bjoern A. Zeeb 246c398145 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
Reviewed by:	grehan, jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D34607
2022-03-24 15:21:24 +00:00
..
amd bhyve: add support for MTRR 2022-01-14 12:41:44 +01:00
intel vmm: fix "set but not used" warnings 2022-02-28 14:55:37 -09:00
io vmm: fix "set but not used" warnings 2022-02-28 15:09:32 -09:00
vmm_dev.c Extend the VMM stats interface to support a dynamic count of statistics. 2022-02-07 14:11:10 -08:00
vmm_host.c
vmm_host.h
vmm_instruction_emul.c Add bhyve support for LA57 guest mode. 2020-08-23 20:37:21 +00:00
vmm_ioport.c
vmm_ioport.h
vmm_ktr.h
vmm_lapic.c cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it 2021-10-18 09:56:58 -04:00
vmm_lapic.h
vmm_mem.c
vmm_mem.h
vmm_snapshot.c Initial support for bhyve save and restore. 2020-05-05 00:02:04 +00:00
vmm_stat.c Extend the VMM stats interface to support a dynamic count of statistics. 2022-02-07 14:11:10 -08:00
vmm_stat.h Extend the VMM stats interface to support a dynamic count of statistics. 2022-02-07 14:11:10 -08:00
vmm_util.c Convert vmm_ops calls to IFUNC 2020-11-28 01:16:59 +00:00
vmm_util.h Convert vmm_ops calls to IFUNC 2020-11-28 01:16:59 +00:00
vmm.c bhyve: Do not remove guest physical addresses from IOMMU host domain 2022-03-24 15:21:24 +00:00
x86.c bhyve: add support for MTRR 2022-01-14 12:41:44 +01:00
x86.h bhyve: add support for MTRR 2022-01-14 12:41:44 +01:00