From owner-dev-commits-src-branches@freebsd.org Tue Jun 22 01:09:45 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 8698B653696; Tue, 22 Jun 2021 01:09:45 +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 4G87bY3D21z3mWX; Tue, 22 Jun 2021 01:09:45 +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 56D2727895; Tue, 22 Jun 2021 01:09:45 +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 15M19jsB013409; Tue, 22 Jun 2021 01:09:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15M19jxB013408; Tue, 22 Jun 2021 01:09:45 GMT (envelope-from git) Date: Tue, 22 Jun 2021 01:09:45 GMT Message-Id: <202106220109.15M19jxB013408@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: df57775d7a80 - stable/13 - hyperv: Fix vmbus after the i386 4/4 split MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: df57775d7a806ace688822dbc272e3672628163d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2021 01:09:45 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=df57775d7a806ace688822dbc272e3672628163d commit df57775d7a806ace688822dbc272e3672628163d Author: Mark Johnston AuthorDate: 2021-06-08 13:40:30 +0000 Commit: Mark Johnston CommitDate: 2021-06-22 01:09:17 +0000 hyperv: Fix vmbus after the i386 4/4 split The vmbus ISR needs to live in a trampoline. Dynamically allocating a trampoline at driver initialization time poses some difficulties due to the fact that the KENTER macro assumes that the offset relative to tramp_idleptd is fixed at static link time. Another problem is that native_lapic_ipi_alloc() uses setidt(), which assumes a fixed trampoline offset. Rather than fight this, move the Hyper-V ISR to i386/exception.s. Add a new HYPERV kernel option to make this optional, and configure it by default on i386. This is sufficient to make use of vmbus(4) after the 4/4 split. Note that vmbus cannot be loaded dynamically and both the HYPERV option and device must be configured together. I think this is not too onerous a requirement, since vmbus(4) was previously non-functional. Reported by: Harry Schmalzbauer Tested by: Harry Schmalzbauer Reviewed by: whu, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 97993d1ebf592ac6689a498d5d0d2afb46758680) --- sys/conf/files.i386 | 1 - sys/conf/options.i386 | 3 +++ sys/dev/hyperv/vmbus/i386/vmbus_vector.S | 6 +++++- sys/i386/conf/GENERIC | 4 +++- sys/i386/i386/exception.s | 9 +++++++++ sys/modules/hyperv/vmbus/Makefile | 5 ++++- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index de759a9f7c83..4bbd584cb831 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -101,7 +101,6 @@ dev/glxiic/glxiic.c optional glxiic dev/glxsb/glxsb.c optional glxsb dev/glxsb/glxsb_hash.c optional glxsb dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv -dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/le/if_le_isa.c optional le isa dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci diff --git a/sys/conf/options.i386 b/sys/conf/options.i386 index 73957449413f..fea6efdb991d 100644 --- a/sys/conf/options.i386 +++ b/sys/conf/options.i386 @@ -110,6 +110,9 @@ NPX_DEBUG opt_npx.h # BPF just-in-time compiler BPF_JITTER opt_bpf.h +# Hyper-V support +HYPERV opt_hyperv.h + XENHVM opt_global.h # options for the Intel C600 SAS driver (isci) diff --git a/sys/dev/hyperv/vmbus/i386/vmbus_vector.S b/sys/dev/hyperv/vmbus/i386/vmbus_vector.S index f503e3d81203..4bb51be2623d 100644 --- a/sys/dev/hyperv/vmbus/i386/vmbus_vector.S +++ b/sys/dev/hyperv/vmbus/i386/vmbus_vector.S @@ -35,6 +35,9 @@ /* * This is the Hyper-V vmbus channel direct callback interrupt. * Only used when it is running on Hyper-V. + * + * Note that this file is not compiled directly, it is included into + * i386/exception.s. */ .text SUPERALIGN_TEXT @@ -46,7 +49,8 @@ IDTVEC(vmbus_isr) KENTER FAKE_MCOUNT(TF_EIP(%esp)) pushl %esp - call vmbus_handle_intr + mov $vmbus_handle_intr, %eax + call *%eax add $4, %esp MEXITCOUNT jmp doreti diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index 702f6d64223c..fd8290a56929 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -328,7 +328,9 @@ device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device # HyperV drivers and enhancement support -device hyperv # HyperV drivers +# NOTE: HYPERV depends on hyperv. They must be added or removed together. +options HYPERV # Kernel support for HyperV drivers +device hyperv # HyperV drivers # Xen HVM Guest Optimizations # NOTE: XENHVM depends on xenpci. They must be added or removed together. diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index b288543dafe1..4e806e8b3bd9 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -39,6 +39,7 @@ #include "opt_apic.h" #include "opt_atpic.h" #include "opt_hwpmc_hooks.h" +#include "opt_hyperv.h" #include "assym.inc" @@ -428,6 +429,14 @@ MCOUNT_LABEL(bintr) #ifdef DEV_APIC #include +#endif + +#ifdef HYPERV + .data + .p2align 4 + .text + SUPERALIGN_TEXT +#include #endif .data diff --git a/sys/modules/hyperv/vmbus/Makefile b/sys/modules/hyperv/vmbus/Makefile index 435106c7e9bd..47a83e76204a 100644 --- a/sys/modules/hyperv/vmbus/Makefile +++ b/sys/modules/hyperv/vmbus/Makefile @@ -13,8 +13,11 @@ SRCS= hyperv.c \ vmbus_et.c \ vmbus_if.c \ vmbus_res.c \ - vmbus_vector.S \ vmbus_xact.c + +.if ${MACHINE_CPUARCH} != "i386" +SRCS+= vmbus_vector.S +.endif SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h pci_if.h pcib_if.h vmbus_if.h # XXX: for assym.inc