diff options
author | Wei Hu <whu@FreeBSD.org> | 2024-06-11 10:05:21 +0000 |
---|---|---|
committer | Wei Hu <whu@FreeBSD.org> | 2024-06-11 10:05:21 +0000 |
commit | e02d20ddff7f9f9509b28095459327bc183dab8a (patch) | |
tree | d05f193414c105e14ca0f205c100f8821cc1c061 | |
parent | f65d0b18d9372b522e247c7bd58422a7ab3d30d8 (diff) | |
download | src-e02d20ddff7f9f9509b28095459327bc183dab8a.tar.gz src-e02d20ddff7f9f9509b28095459327bc183dab8a.zip |
Hyper_V: add a boot parameter to tlb flush hypercall
Add boot parameter hw.vmbus.tlb_hcall for tlb flush hypercall.
By default it is set to 1 to allow hyercall tlb flush. It can be
set to 0 in loader.conf to turn off hypercall and use system
provided tlb flush routine.
The change also changes flag in the per cpu contiguous memory
allocation to no wait to avoid panic happened some cases which there
are no enough contiguous memery available at boot time.
Reported by: gbe
Tested by: whu
MFC after: 1 week
Fixes: 2b887687edc25bb4553f0d8a1183f454a85d413d
Sponsored by: Microsoft
-rw-r--r-- | sys/dev/hyperv/vmbus/vmbus.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index c1fa9107d3c2..f55f0329b017 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -147,6 +147,13 @@ SYSCTL_NODE(_hw, OID_AUTO, vmbus, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, static int vmbus_pin_evttask = 1; SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN, &vmbus_pin_evttask, 0, "Pin event tasks to their respective CPU"); + +#if defined(__x86_64__) +static int hv_tlb_hcall = 1; +SYSCTL_INT(_hw_vmbus, OID_AUTO, tlb_hcall , CTLFLAG_RDTUN, + &hv_tlb_hcall, 0, "Use Hyper_V hyercall for tlb flush"); +#endif + uint32_t vmbus_current_version; static const uint32_t vmbus_version[] = { @@ -756,8 +763,19 @@ vmbus_synic_setup(void *xsc) if (VMBUS_PCPU_GET(sc, vcpuid, cpu) > hv_max_vp_index) hv_max_vp_index = VMBUS_PCPU_GET(sc, vcpuid, cpu); hv_cpu_mem = DPCPU_ID_PTR(cpu, hv_pcpu_mem); - *hv_cpu_mem = contigmalloc(PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO, + *hv_cpu_mem = contigmalloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO, 0ul, ~0ul, PAGE_SIZE, 0); + +#if defined(__x86_64__) + if (*hv_cpu_mem == NULL && hv_tlb_hcall) { + hv_tlb_hcall = 0; + if (bootverbose && sc) + device_printf(sc->vmbus_dev, + "cannot alloc contig memory for hv_pcpu_mem, " + "use system provided tlb flush call.\n"); + } +#endif + /* * Setup the SynIC message. */ @@ -1502,7 +1520,8 @@ vmbus_doattach(struct vmbus_softc *sc) sc->vmbus_flags |= VMBUS_FLAG_SYNIC; #if defined(__x86_64__) - smp_targeted_tlb_shootdown = &hyperv_vm_tlb_flush; + if (hv_tlb_hcall) + smp_targeted_tlb_shootdown = &hyperv_vm_tlb_flush; #endif /* |