From nobody Tue Jun 11 10:12:36 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vz4H847vdz5P50p; Tue, 11 Jun 2024 10:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vz4H83hvRz4NPt; Tue, 11 Jun 2024 10:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718100756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MwCHNiTKYqRpoO8WnuxdwxIuC7NTiYBoQH8yk2WnvoQ=; b=cF7IWw3/9E3VIraGN38/b86XMIp9eG5Sf4wYFgZ8FPd/xYsqLokLIYYqwA3Jeo4ak7Q39s sn6X7JTPRarldmTPh0eFK1StFSDfyPx/EimpS/nZ1z6eBbryj3/q0EC3DCjCO/a/FSps4q Da5QfA8zy1qqwiueMQoKcunfe6YxKzSDUGJrgDPKtAD93nS+O0oi7sI0pf+0UU4wi1Aix6 h0XAykyRoSx5eqavVU3tm3CQO2gOoWSOf7SUQi6JnqOx38sHarHjBNp+tN1ThFOKDx5jcC UN7c9bMS/dxguSxjbtbiyS6NHE7QgwO7EyeZaEi/f7GSXJ2IF0ZziJxhViZizQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718100756; a=rsa-sha256; cv=none; b=rLis9+6+NezpCWB9eMrHCeCWmTvfPC9sLjnV6XunFsG42GVBdWU2IlcltwfYw49dT5/9VS INxQyBRhvh1qDWhYHfGpNsqdagG4YKxF/xRG56gYTKyqTQJS3FmY3xZJySZ2LeaLsziGf3 56hM8ZIHzZUnGoSzGDMv2x3O9jpJEmXpQQkvrMSgpp1P/sY/9FhfSCIgRkCta5SpVlRave dq45oP0YsOBY5n0VtShSgvYLe/Ju1suaICNxMCFUffMIXOknceCMz4OP/sYpOXzaNkqLqW 0bsYBuafLcCYo5VJPFoVf9taDY/MirTaituY062qhT9K30jCJLY+im1VD+KpSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718100756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MwCHNiTKYqRpoO8WnuxdwxIuC7NTiYBoQH8yk2WnvoQ=; b=X/Tj71fcCsD74GmT5FIaX9LHCw+qJs0FT07NIls9jnJogvQ/Xas/OMlZoC1n9B7veAY+FY 9WoNb6PpGri8/tYRFGLq9qm42OCSfk7DM6AZ5FztWBsw6JY/Uc8syPAyBoTFfjZAVtEGyk /2pv24w9cKVeh3489SfD6TDpuIO6zG+uNZwIJgfdaMOpmiMrmylIRf3W++FQV7J8r+j6VI fjkl2hcTG9V7yMYX8TOlU+ehMhnwHvhpzOxY5W/snqSoXnSQ/moZZwYY+rpofpnHI7x4EV HGT4pESrS54Fc91losGgsQ2cd0diKtLqedVvQBi9M1IX5+N6HuYAPIRdtqMj8g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Vz4H82vt4z14Hd; Tue, 11 Jun 2024 10:12:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45BACaAm049928; Tue, 11 Jun 2024 10:12:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45BACaFw049925; Tue, 11 Jun 2024 10:12:36 GMT (envelope-from git) Date: Tue, 11 Jun 2024 10:12:36 GMT Message-Id: <202406111012.45BACaFw049925@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wei Hu Subject: git: e02d20ddff7f - main - Hyper_V: add a boot parameter to tlb flush hypercall List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: whu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e02d20ddff7f9f9509b28095459327bc183dab8a Auto-Submitted: auto-generated The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=e02d20ddff7f9f9509b28095459327bc183dab8a commit e02d20ddff7f9f9509b28095459327bc183dab8a Author: Wei Hu AuthorDate: 2024-06-11 10:05:21 +0000 Commit: Wei Hu 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 /*