From nobody Mon Jul 01 13:42:21 2024 X-Original-To: dev-commits-src-all@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 4WCRzx6GMtz5Nhq4; Mon, 01 Jul 2024 13:42:21 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WCRzx5Wt3z4ny3; Mon, 1 Jul 2024 13:42:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1719841341; 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=UpUZfAHSCts0Nyd3yVoLGl0dGrYaNJHIumuUz3g+w/E=; b=UI5vCj7qVwntMbOffNBbsOwQWR+aX7H7YkuWvfXhXq79JOYfjm2DMEIq7Gc1GMA0uG3WQe FOFD33NGJ4qL8TzwLkzki2iH12bM3pEeT/x4KEcOhgZ793CfKUZ3E464yQpqZDb+2glOtI rflEBYAm1DO1Zwatj4prp1Bz0J2a2tcU5SU3SRmS2sRotb0TkpQ3gav2bqPJorXj7ooeQr wuVkrc36BpNvACHW375rgFzyfok31fut7s6GUYexo8pab4etJIkunQgMfMWVRnse/jvKl3 IpYeDjIUBKizZwF+HopBKYkOPyCTSt4TjWHt9R/6UmQpg1xaxqo8D3K+XG9oUg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1719841341; a=rsa-sha256; cv=none; b=C+f4lprfrHqHNbgkhYJdq1ieo+/zK/ndeLxAjTqqUnE1KqgcJfnH+FV1ybWgef29rEH0FJ GS08N1DmfqYNwkAAE0e9nhmfJ3TCqmS7D+OHmZUfu4BgwcZ+BUISwIcs81Lah8wtsfrg0r 4y+5VtNiGBxaSJnJqd0/F5FgzLq5zc/whhPl5jNXegCR8le+HAMpn1SHUUlrnGZ7n9iqsh gpp6Joz18F7Yns8IJA2tWqdi0nANubCcevavdyzbwUkVakTlVG1NqxlE3RRDnyxJwDDYre s6X+lFDlmk7KozDVJyHLsOLyBvCya7QJXaThLoF9YJQddxZfqxLvpXXizgBL4Q== 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=1719841341; 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=UpUZfAHSCts0Nyd3yVoLGl0dGrYaNJHIumuUz3g+w/E=; b=U8xL/NWGF0J152QBBcegvwoHVAMOUl4EcUzmYe5+IBqY0ibH+6KM9MOcQxna1050wE5LSr u4shKiQZqRYn19yikwMx0SX04dKcsgxpicf8V+mvOT47rfGS9NsOKroEYeJhi/aoIP7LDY AKeMqFisXMnHToyl5NJsF6tlM4InZOG2h4qa+GtADp04KhCzRFz6TtsHNoX9J4G93JXBeT /6zrAFbOvmClkivE25VEhu18lwv3Oxin2ez735ZnERiUf3g9KyIpv2w9HeRAZd3QQehPiJ hhWMgi5tTpzZfdcfk2x2+ju2UqvhuU+IKnItVOyh4ai7FWUdF+FNT/fxBnYzAQ== 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 4WCRzx57QDz16Bs; Mon, 1 Jul 2024 13:42:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 461DgL84027015; Mon, 1 Jul 2024 13:42:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 461DgLnB027012; Mon, 1 Jul 2024 13:42:21 GMT (envelope-from git) Date: Mon, 1 Jul 2024 13:42:21 GMT Message-Id: <202407011342.461DgLnB027012@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Wei Hu Subject: git: 451941677aba - stable/14 - Hyper_V: add a boot parameter to tlb flush hypercall List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 451941677aba763db6f4410517960a45f2128f90 Auto-Submitted: auto-generated The branch stable/14 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=451941677aba763db6f4410517960a45f2128f90 commit 451941677aba763db6f4410517960a45f2128f90 Author: Wei Hu AuthorDate: 2024-06-11 10:05:21 +0000 Commit: Wei Hu 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 /*