freebsd-dev/sys
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
..
amd64 bhyve: Do not remove guest physical addresses from IOMMU host domain 2022-03-24 15:21:24 +00:00
arm arm,arm64: Add a NT_ARM_TLS read-only register set. 2022-03-23 13:33:06 -07:00
arm64 arm,arm64: Add a NT_ARM_TLS read-only register set. 2022-03-23 13:33:06 -07:00
bsm
cam vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
cddl zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
compat LinuxKPI: allow bsddriver name to be set for PCI 2022-03-24 15:19:15 +00:00
conf Retire broken snd_ds1 and snd_maestro drivers 2022-03-18 20:33:19 -04:00
contrib vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
crypto armv8crypto: Remove leftover debug printfs 2022-02-17 14:25:45 -05:00
ddb ddb: Remove SOFTWARE_SSTEP support 2022-01-07 09:25:33 -07:00
dev vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
dts dts: add IPQ4018/IPQ4019 ethernet MAC and ethernet switch definitions 2022-02-03 21:26:45 -08:00
fs vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
gdb gdb(4): Do not use run length encoding for 3-symbol repetitions 2022-01-22 14:46:06 -05:00
geom GEOM: Introduce partial confxml API 2022-03-12 11:55:52 -05:00
gnu
i386 x86/tsc: fetch frequency from CPUID when running on Xen 2022-03-18 10:21:04 +01:00
isa sys/isa: Use C99 fixed-width integer types. 2021-12-28 09:41:57 -08:00
kern vfs: hoist trailing slash handling out of the loop 2022-03-24 14:36:31 +00:00
kgssapi
libkern sys/libkern: Use C99 fixed-width integer types. 2021-12-28 09:42:11 -08:00
modules Retire broken snd_ds1 and snd_maestro drivers 2022-03-18 20:33:19 -04:00
net if_epair: build fix 2022-03-17 06:43:47 +01:00
net80211 net80211: introduce (*iv_update_bss)() 2022-03-22 18:51:43 +00:00
netgraph ng pppoe(4): Add the required NET_EPOCH section to the hook 2022-02-09 22:00:50 +03:00
netinet IPv4 multicast: fix netstat -g 2022-03-22 07:38:01 -05:00
netinet6 Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues 2022-01-27 10:34:34 -05:00
netipsec ipsec: sprinkle CURVNET_ASSERT_SET 2022-02-19 13:10:41 +00:00
netpfil pf: fix !INET or !INET6 builds 2022-03-16 12:52:07 -07:00
netsmb
nfs
nfsclient
nfsserver
nlm sys/nlm: Use C99 fixed-width integer types. 2021-12-28 09:42:42 -08:00
ofed ibcore: Fix multiple includes of same header file. 2022-03-03 12:51:20 +01:00
opencrypto crypto: hide crypto_destroyreq behind a tunable 2022-02-16 07:45:12 +00:00
powerpc powerpcspe: fix PCI enumeration on ppce500 2022-03-21 16:11:33 -03:00
riscv riscv: Add support for enabling SV48 mode 2022-03-01 09:39:44 -05:00
rpc sys/rpc: Use C99 fixed-width integer types. 2021-12-28 09:43:15 -08:00
security vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
sys vfs: retire the NDF_ONLY_PNBUF flag 2022-03-24 10:20:51 +00:00
teken teken: color #3 is yellow not brown - use TC_YELLOW as the name 2022-03-12 09:17:29 -05:00
tests
tools Revert "syscallarg_t: Add a type for system call arguments" 2022-01-12 23:29:20 +00:00
ufs vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
vm vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
x86 x86/tsc: fetch frequency from CPUID when running on Xen 2022-03-18 10:21:04 +01:00
xdr sys/xdr: Use C99 fixed-width integer types. 2021-12-28 09:43:26 -08:00
xen xen: remove public headers in sys/xen/interface 2022-02-07 10:12:34 +01:00
Makefile Fix 'make cscope' with ALL_ARCH defined 2022-01-07 11:53:52 -04:00