From nobody Wed Feb 01 15:40:57 2023 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 4P6R2x3mZwz3cWMG; Wed, 1 Feb 2023 15:40:57 +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 4P6R2x3Lyqz4NyB; Wed, 1 Feb 2023 15:40:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675266057; 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=bP5jSjHHasDoeFqaEBsFQJJ8RmCwPTPUQ4h+Q9uhPag=; b=qi8AOGi3YB8DuY2ehuCuzpvJVU6oXZ0HsIwEuclPDPJYdhtZDJpbJbEkVTRYvMZqa2Pbe+ 1b6iKuNmwcomTx3pVOnG/sDUFP3FJuQoLeuKld71+1eBgM/8546ykPe7P/n7vzVrIw2o/U z46ZghRQ+sP56X0fyCWT4Y6P3Rkg982qkczus1RhUnrXs42/lEDKGc95bm29vs/8rrtWUy ZFWWasSZGwusziKTAMJ7hzQU+j78JGr+KgWRtuJW5QtFwgtgdTj4PwV2it+mijgNVVAZ5d 1PqDhYQD88YOuezsuRwsiFfHZwzFHqXzuUhhsk20YiGA1asUaIa5qYvEhvmn0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675266057; 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=bP5jSjHHasDoeFqaEBsFQJJ8RmCwPTPUQ4h+Q9uhPag=; b=Lq88YzzrXY4Encroe0Dc9UxypQPKPmVFoB5/kH6xf6b26gLeqWkheqXGyFm6tonxucSeSG bG9Ib+NVIrjevKnVZsvPo+q/oR8TRNbP3rUstbAMlp5w5x1QS9CyA5i9OZGaXR2GpIDDpq ItMo/1iDqiVRR81j8MQq4czIarQQ98QS/PeOH8FM3njvyFuBv081TMyDNOTz8hHGxvPRrv CpNc25bbroW8A/RPTqhi34gp8aNPUIIdv4mMFpgPPozL56NQeu6n76kvvhmE3LeRfyI3FI 4m7a8csIjMauTmeohogKnZ1PKLKtfWFdvZHcoyRit8oX+ZpCyjfTNFhG1nJKhw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675266057; a=rsa-sha256; cv=none; b=LhvAHqIimxyknjo1ae14wnoJcG7nCboAd9dpKBsjk/qT/OGvpbdoFglrcTEw2zpvcKpx+s rF6hwTN8etEHR70fbki24cdlu7SxhmrbAQhUGiMRI1/sFbNicXBLZzAcyHRFdygfzE1VBQ 2zKdSrh3NnlgEQLSyMW7p+4Es1yVWO5MIoOcmoOC0Qm7Wdvmox1ZqbT/V0xsviHCWdeC96 0Bb3MQDhulI7zpEvir2BmbFz78wLdTXpX0UXoroTCOo7MkUslXGK+RdhjwvzGw8tyBlH3h kF6ZLKbFc599M7OvcqTGF+Q1DXEWI+v6FYNEdSmfX8mTT8eBiy671qhWRIQYXA== 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 4P6R2x2PBKzKD8; Wed, 1 Feb 2023 15:40:57 +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 311Fevpn099591; Wed, 1 Feb 2023 15:40:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 311FevoJ099590; Wed, 1 Feb 2023 15:40:57 GMT (envelope-from git) Date: Wed, 1 Feb 2023 15:40:57 GMT Message-Id: <202302011540.311FevoJ099590@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: db247798c564 - main - arm64: Hyper-V: vPCI: SPI MSI mapping for gic v3 acpi in arm64 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: db247798c564021f216803296c07360ddbf2d5e8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=db247798c564021f216803296c07360ddbf2d5e8 commit db247798c564021f216803296c07360ddbf2d5e8 Author: Wei Hu AuthorDate: 2023-02-01 15:00:18 +0000 Commit: Wei Hu CommitDate: 2023-02-01 15:40:08 +0000 arm64: Hyper-V: vPCI: SPI MSI mapping for gic v3 acpi in arm64 Microsoft Azure Hyper-V uses SPI to map MSI in ARM64, instead of using LPI IDS. To enable that we need to have gic registered with ACPI_MSI_XREF and gic acpi to map SPI for MSI. This is the 1st of the three patchs to enable Hyper-V vPCI support in arm64. Reviewed by: andrew, emaste, whu Tested by: Souradeep Chakrabarti Obtained from: Souradeep Chakrabarti Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D37763 --- sys/arm64/arm64/gic_v3.c | 7 +++++++ sys/arm64/arm64/gic_v3_acpi.c | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/gic_v3.c b/sys/arm64/arm64/gic_v3.c index c26158e4035c..07ef8454afcf 100644 --- a/sys/arm64/arm64/gic_v3.c +++ b/sys/arm64/arm64/gic_v3.c @@ -382,6 +382,13 @@ gic_v3_attach(device_t dev) mtx_init(&sc->gic_mbi_mtx, "GICv3 mbi lock", NULL, MTX_DEF); if (sc->gic_mbi_start > 0) { + if (!sc->gic_mbi_end) { + /* + * This is to address SPI based msi ranges, where + * SPI range is not specified in ACPI + */ + sc->gic_mbi_end = sc->gic_nirqs - 1; + } gic_v3_reserve_msi_range(dev, sc->gic_mbi_start, sc->gic_mbi_end - sc->gic_mbi_start); diff --git a/sys/arm64/arm64/gic_v3_acpi.c b/sys/arm64/arm64/gic_v3_acpi.c index d6d5640f9daa..e4a48ea32ca2 100644 --- a/sys/arm64/arm64/gic_v3_acpi.c +++ b/sys/arm64/arm64/gic_v3_acpi.c @@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$"); #define GICV3_PRIV_VGIC 0x80000000 #define GICV3_PRIV_FLAGS 0x80000000 +#define HV_MSI_SPI_START 64 +#define HV_MSI_SPI_LAST 0 struct gic_v3_acpi_devinfo { struct gic_v3_devinfo di_gic_dinfo; @@ -319,7 +321,10 @@ gic_v3_acpi_attach(device_t dev) err = gic_v3_acpi_count_regions(dev); if (err != 0) goto count_error; - + if (vm_guest == VM_GUEST_HV) { + sc->gic_mbi_start = HV_MSI_SPI_START; + sc->gic_mbi_end = HV_MSI_SPI_LAST; + } err = gic_v3_attach(dev); if (err != 0) goto error; @@ -330,6 +335,17 @@ gic_v3_acpi_attach(device_t dev) err = ENXIO; goto error; } + /* + * Registering for MSI with SPI rnage, as this is + * required for Hyper-V GIC to work in ARM64. + */ + if (vm_guest == VM_GUEST_HV) { + err = intr_msi_register(dev, ACPI_MSI_XREF); + if (err) { + device_printf(dev, "could not register MSI\n"); + goto error; + } + } if (intr_pic_claim_root(dev, ACPI_INTR_XREF, arm_gic_v3_intr, sc, GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) {