git: 451941677aba - stable/14 - Hyper_V: add a boot parameter to tlb flush hypercall
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 01 Jul 2024 13:42:21 UTC
The branch stable/14 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=451941677aba763db6f4410517960a45f2128f90 commit 451941677aba763db6f4410517960a45f2128f90 Author: Wei Hu <whu@FreeBSD.org> AuthorDate: 2024-06-11 10:05:21 +0000 Commit: Wei Hu <whu@FreeBSD.org> CommitDate: 2024-07-01 13:32:37 +0000 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 (cherry picked from commit e02d20ddff7f9f9509b28095459327bc183dab8a) --- sys/dev/hyperv/vmbus/vmbus.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index 51f9cfa05138..786b2611dcd7 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 /*