opnsense-src/usr.sbin/bhyve
Mark Johnston bec64e75a5 bhyve: Avoid holding /dev/pci open unnecessarily
Some device models, LPC in particular, will call pci_host_read_config()
when probing for devices.  Currently this results in pcifd_init()
opening /dev/pci, and thus bhyve holds the fd open even when it's not
needed.

Modify pci_host_{read,write}_config() to open /dev/pci independent of
the global pcifd.  This means that these routines can only be used
during VM initialization, as capsicum will prevent further opens
afterward.  Introduce internal wrappers which use the global pcifd,
intended for the passthru code.

Reviewed by:	jhb
MFC after:	3 weeks
Fixes:		563fd2240e ("bhyve: export funcs for read/write pci config")
Differential Revision:	https://reviews.freebsd.org/D48908

(cherry picked from commit 649a910e34)
2025-03-07 22:51:49 +00:00
..
amd64 bhyve: merge adjacent E820 entries 2024-11-12 08:54:22 +01:00
gdb bhyve/gdb: Avoid rebuilding target.xml for install targets 2024-03-29 09:53:05 -04:00
kbdlayout Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
acpi.c bhyve: return ENOMEM instead of EFAULT and call free() after being used 2024-01-25 09:57:05 -05:00
acpi.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
acpi_device.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
acpi_device.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
ahci.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
audio.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
audio.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
basl.c bhyve: add config option to load ACPI tables into memory 2023-08-22 07:49:00 +02:00
basl.h bhyve: maintain RSDT and XSDT by basl 2023-06-20 10:56:23 +02:00
bhyve.8 bhyve: TPM 2.0 emulation with swtpm 2024-11-12 08:54:22 +01:00
bhyve_config.5 bhyve: TPM 2.0 emulation with swtpm 2024-11-12 08:54:22 +01:00
bhyvegc.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
bhyvegc.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
bhyverun.c bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN 2023-10-24 11:44:44 -07:00
bhyverun.h bhyve: Move most early initialization into an MD routine 2023-10-11 09:24:38 -04:00
block_if.c bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN 2023-10-24 11:44:44 -07:00
block_if.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
bootrom.c bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN 2023-10-24 11:44:44 -07:00
bootrom.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
config.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
config.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
console.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
console.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
debug.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
gdb.c bhyve: Escape binary data sent in reply packets 2024-08-15 14:29:49 +00:00
gdb.h bhyve: refactor gdbstub to enable single-stepping on AMD CPUs 2024-01-04 16:26:28 -08:00
hda_codec.c bhyve: improve bounds checks in hda_codec 2024-10-06 11:04:29 -04:00
hda_reg.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
hdac_reg.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
iov.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
iov.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
ipc.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
libslirp.h bhyve: Add a slirp network backend 2023-12-25 11:57:14 -05:00
Makefile bhyve: TPM 2.0 emulation with swtpm 2024-11-12 08:54:22 +01:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.depend.options Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
mem.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
mem.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
mevent.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
mevent.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
mevent_test.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
net_backend_netgraph.c bhyve: Split backends into separate files 2023-12-14 09:43:02 -05:00
net_backend_netmap.c bhyve: Split backends into separate files 2023-12-14 09:43:02 -05:00
net_backend_slirp.c bhyve: Implement the libslirp notify callback 2025-02-07 14:46:53 +00:00
net_backends.c bhyve: Split backends into separate files 2023-12-14 09:43:02 -05:00
net_backends.h bhyve: Split backends into separate files 2023-12-14 09:43:02 -05:00
net_backends_priv.h bhyve: Split backends into separate files 2023-12-14 09:43:02 -05:00
net_utils.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
net_utils.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pci_ahci.c bhyve ahci: Improve robustness of TRIM handling 2024-10-29 15:19:51 -04:00
pci_e82545.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_emul.c bhyve: Make most I/O port handling specific to amd64 2023-10-11 09:22:07 -04:00
pci_emul.h bhyve: Move legacy PCI interrupt handling under amd64/ 2023-10-11 09:22:05 -04:00
pci_fbuf.c bhyve: avoid updating fbaddr when vm_mmap_memseg fails 2024-09-03 10:53:19 -04:00
pci_hda.c bhyve: validate corb->wp to avoid infinite loop 2024-09-24 13:30:35 -04:00
pci_hda.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pci_hostbridge.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_nvme.c bhyve/nvme: Fix Infinite loop in queue processing 2024-10-19 11:42:15 -04:00
pci_passthru.c bhyve: Avoid holding /dev/pci open unnecessarily 2025-03-07 22:51:49 +00:00
pci_passthru.h bhyve: Improve pcifd function naming 2023-10-11 09:21:48 -04:00
pci_uart.c bhyve: Move device model-independent UART code into a separate file 2024-03-29 09:53:28 -04:00
pci_virtio_9p.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_virtio_block.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_virtio_console.c bhyve: avoid buffer overflow in pci_vtcon_control_send 2024-10-17 08:31:39 -04:00
pci_virtio_input.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_virtio_net.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_virtio_rnd.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_virtio_scsi.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pci_xhci.c bhyve: simplify slot validation in xHCI emulation 2024-09-25 12:50:41 -04:00
pci_xhci.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
pctestdev.c bhyve: Make most I/O port handling specific to amd64 2023-10-11 09:22:07 -04:00
pctestdev.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
qemu_fwcfg.c bhyve: Make most I/O port handling specific to amd64 2023-10-11 09:22:07 -04:00
qemu_fwcfg.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
qemu_loader.c bhyve: add helper struct for qemus acpi table loader 2023-04-25 08:29:25 +02:00
qemu_loader.h bhyve: add helper struct for qemus acpi table loader 2023-04-25 08:29:25 +02:00
rfb.c bhyve: support noVNC SetPixelFormat request 2024-10-31 07:41:17 -07:00
rfb.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
smbiostbl.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
smbiostbl.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
snapshot.c bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN 2023-10-24 11:44:44 -07:00
snapshot.h bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN 2023-10-24 11:44:44 -07:00
sockstream.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
sockstream.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
tpm_device.c bhyve: add cmdline option for TPM emulation 2023-08-17 08:17:59 +02:00
tpm_device.h bhyve: add cmdline option for TPM emulation 2023-08-17 08:17:59 +02:00
tpm_emul.h bhyve/tpm: create crb thread for sending tpm commands 2023-06-20 10:59:00 +02:00
tpm_emul_passthru.c bhyve: emulate TPM passthru by accessing /dev/tpmX 2023-08-10 09:23:42 +02:00
tpm_emul_swtpm.c bhyve: TPM 2.0 emulation with swtpm 2024-11-12 08:54:22 +01:00
tpm_intf.h bhyve: add emulation for CRB register of TPM devices 2023-08-10 09:23:33 +02:00
tpm_intf_crb.c bhyve: TPM CRB: pass actual TPM request length to backend execute_cmd() 2024-11-12 08:54:22 +01:00
tpm_ppi.h bhyve: add Qemu PPI emulation for TPM devices 2023-08-14 10:17:36 +02:00
tpm_ppi_qemu.c bhyve: fix Out-Of-Bounds read/write heap in tpm_ppi_mem_handler 2024-09-04 14:59:23 +00:00
uart_backend.c bhyve: Move device model-independent UART code into a separate file 2024-03-29 09:53:28 -04:00
uart_backend.h bhyve: Move device model-independent UART code into a separate file 2024-03-29 09:53:28 -04:00
uart_emul.c bhyve: Move device model-independent UART code into a separate file 2024-03-29 09:53:28 -04:00
uart_emul.h bhyve: Move device model-independent UART code into a separate file 2024-03-29 09:53:28 -04:00
usb_emul.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
usb_emul.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
usb_mouse.c Fix issue with Linux guest XHCI tablet probing. 2024-01-28 19:01:49 +10:00
virtio.c bhyve: avoid TOCTOU on iov_len in virtio_vq_recordon() 2024-10-02 16:37:09 -04:00
virtio.h bhyve: Move legacy PCI interrupt handling under amd64/ 2023-10-11 09:22:05 -04:00
vmexit.h bhyve: Split vmexit handling into a separate file 2023-10-11 09:21:55 -04:00
vmgenc.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
vmgenc.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00