Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jun 2024 10:12:36 GMT
From:      Wei Hu <whu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e02d20ddff7f - main - Hyper_V: add a boot parameter to tlb flush hypercall
Message-ID:  <202406111012.45BACaFw049925@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by whu:

URL: https://cgit.FreeBSD.org/src/commit/?id=e02d20ddff7f9f9509b28095459327bc183dab8a

commit e02d20ddff7f9f9509b28095459327bc183dab8a
Author:     Wei Hu <whu@FreeBSD.org>
AuthorDate: 2024-06-11 10:05:21 +0000
Commit:     Wei Hu <whu@FreeBSD.org>
CommitDate: 2024-06-11 10:05:21 +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
---
 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 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
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202406111012.45BACaFw049925>