From owner-dev-commits-src-main@freebsd.org Sat Jun 5 15:03:51 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3A37C6445C6; Sat, 5 Jun 2021 15:03:51 +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 4Fy2vq1039z3JlT; Sat, 5 Jun 2021 15:03:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0AA02128B6; Sat, 5 Jun 2021 15:03:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 155F3oGU089167; Sat, 5 Jun 2021 15:03:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 155F3o3R089166; Sat, 5 Jun 2021 15:03:50 GMT (envelope-from git) Date: Sat, 5 Jun 2021 15:03:50 GMT Message-Id: <202106051503.155F3o3R089166@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: fe7d7ac40881 - main - hyperv: register intr handler as usermode-mapped if loaded as module MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe7d7ac40881c9d01a54bf57fff71a3af199f237 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2021 15:03:51 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fe7d7ac40881c9d01a54bf57fff71a3af199f237 commit fe7d7ac40881c9d01a54bf57fff71a3af199f237 Author: Konstantin Belousov AuthorDate: 2021-01-12 16:35:58 +0000 Commit: Konstantin Belousov CommitDate: 2021-06-05 15:03:18 +0000 hyperv: register intr handler as usermode-mapped if loaded as module Normally raw interrupt handler is provided by the kernel text. But vmbus module registers its own handler that needs to be mapped into userspace mapping on PTI kernels. Reported and reviewed by: whu Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30310 --- sys/dev/hyperv/vmbus/vmbus.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index d3568494405e..929eff33e7c9 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include #include @@ -139,6 +143,7 @@ SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN, &vmbus_pin_evttask, 0, "Pin event tasks to their respective CPU"); extern inthand_t IDTVEC(vmbus_isr), IDTVEC(vmbus_isr_pti); +#define VMBUS_ISR_ADDR trunc_page((uintptr_t)IDTVEC(vmbus_isr_pti)) uint32_t vmbus_current_version; @@ -980,6 +985,10 @@ vmbus_intr_setup(struct vmbus_softc *sc) vmbus_msg_task, sc); } +#if defined(__amd64__) && defined(KLD_MODULE) + pmap_pti_add_kva(VMBUS_ISR_ADDR, VMBUS_ISR_ADDR + PAGE_SIZE, true); +#endif + /* * All Hyper-V ISR required resources are setup, now let's find a * free IDT vector for Hyper-V ISR and set it up. @@ -987,6 +996,9 @@ vmbus_intr_setup(struct vmbus_softc *sc) sc->vmbus_idtvec = lapic_ipi_alloc(pti ? IDTVEC(vmbus_isr_pti) : IDTVEC(vmbus_isr)); if (sc->vmbus_idtvec < 0) { +#if defined(__amd64__) && defined(KLD_MODULE) + pmap_pti_remove_kva(VMBUS_ISR_ADDR, VMBUS_ISR_ADDR + PAGE_SIZE); +#endif device_printf(sc->vmbus_dev, "cannot find free IDT vector\n"); return ENXIO; } @@ -1007,6 +1019,10 @@ vmbus_intr_teardown(struct vmbus_softc *sc) sc->vmbus_idtvec = -1; } +#if defined(__amd64__) && defined(KLD_MODULE) + pmap_pti_remove_kva(VMBUS_ISR_ADDR, VMBUS_ISR_ADDR + PAGE_SIZE); +#endif + CPU_FOREACH(cpu) { if (VMBUS_PCPU_GET(sc, event_tq, cpu) != NULL) { taskqueue_free(VMBUS_PCPU_GET(sc, event_tq, cpu));