diff options
author | Zhenlei Huang <zlei@FreeBSD.org> | 2023-11-02 09:07:11 +0000 |
---|---|---|
committer | Zhenlei Huang <zlei@FreeBSD.org> | 2023-11-02 09:10:03 +0000 |
commit | 1969d82fcf62f80c2047a53b42f501680b140b0d (patch) | |
tree | 4359be99fc5b84be44a348d784b6d407d3f3122a | |
parent | fb288d493989d9df4c4f9c8eb3d7e28af61f8302 (diff) | |
download | src-1969d82fcf62f80c2047a53b42f501680b140b0d.tar.gz src-1969d82fcf62f80c2047a53b42f501680b140b0d.zip |
Hyper-V: vmbus: Add NULL check for vmbus_res
QEMU emulates Hyper-V [1] but lacks the emulation for vmbus_res, thus no
coherence information is available. Add NULL check for it and fallback
to no coherence. This will prevent FreeBSD guests from panic on QEMU
with the Hyper-V enlightenment hv-synic enabled.
For real Hyper-V, both gen1 and gen2 have vmbus_res then they are not
affected by this change.
1. https://www.qemu.org/docs/master/system/i386/hyperv.html
PR: 274810
Reviewed by: mhorne, emaste, delphij, whu
Diagnosed by: mhorne
Fixes: e7a9817b8d32 Hyper-V: vmbus: implementat bus_get_dma_tag in vmbus
Insta-MFC approved by: re (delphij) for 14.0-RC4
Differential Revision: https://reviews.freebsd.org/D42414
(cherry picked from commit 63bf943d4af17799cef21e2bb78dd28003ce1ce5)
-rw-r--r-- | sys/dev/hyperv/vmbus/vmbus.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index ee412e643b4f..0ea401507b79 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -1393,7 +1393,7 @@ vmbus_doattach(struct vmbus_softc *sc) int ret; device_t dev_res; ACPI_HANDLE handle; - unsigned int coherent; + unsigned int coherent = 0; if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED) return (0); @@ -1416,10 +1416,12 @@ vmbus_doattach(struct vmbus_softc *sc) /* Coherency attribute */ dev_res = devclass_get_device(devclass_find("vmbus_res"), 0); - handle = acpi_get_handle(dev_res); + if (dev_res != NULL) { + handle = acpi_get_handle(dev_res); - if (ACPI_FAILURE(acpi_GetInteger(handle, "_CCA", &coherent))) - coherent = 0; + if (ACPI_FAILURE(acpi_GetInteger(handle, "_CCA", &coherent))) + coherent = 0; + } if (bootverbose) device_printf(sc->vmbus_dev, "Bus is%s cache-coherent\n", coherent ? "" : " not"); |