From nobody Mon Mar 11 04:47:12 2024 X-Original-To: dev-commits-src-branches@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 4TtPQ83pj9z5Dddd; Mon, 11 Mar 2024 04:47:12 +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 4TtPQ83JZWz4KTR; Mon, 11 Mar 2024 04:47:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710132432; 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=sur33/r07fjOigoVgwI7K2TQ0VskSGcsp0ttUtyYChw=; b=MVE5lgWWhb7lKcnyepVn3c9BlDOMX39+4RL6gjUvNWb4a2A/68Fa61GgJTalhpyPhUm4SY bwls2satVZAaohyTuKJOstX6Bvsh5G3gUgmBUQEgyWnOU2PA+UnjKjW2tWRSkSEpUAp6qp 6rS1l5NWyWa7YgQ7m1WkFFfKR7A/ZqGO9VzYiMpSayqZVM/ldQNuBhYrdkFPhlyE3q8c1v QelBir/FK71hFsJLtnXvQh/cUzUG3ffWK/LiBcrZxDCo34bIIX8kAoDQOOgRkieNOZhdwB A6zOCq08PHPkXV/hq13MLffHXo4oP3lLEZZoH1Uy47EWtkrOKzR1J+s8WDBOnQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710132432; a=rsa-sha256; cv=none; b=SnYYcA0Hu3Nm8VQ5rEHvRK6BB/TKI5Eq9+OPN/3LET5g1cNqoZx8oAaXh+8+5gqBcFEsVs mErgtFQ47axvvuPD3OO9z5yp0fPL5oqS/OANCiVoSXZzPlXpt3aWWkGpNG4oYLk6W0Gaiq jPOGVq+qKKFSF9Mr+WwWMZdNI2KFErRUaDoe6fIIcF5fNYg8w7aLxW/NvaA+kiAjk8NgVx 2LIykcYboRD2+AruHLPwcpd549WD5PAtqrRmcLFGmItbyduYyze7PGg6Ykpxqvg233Ma+a NXU2ABzdUlDjduusc3Np7ZeJn8Oi390ZT+GPMl1rOu0yBowJ7LJ7LAqkkRAHCg== 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=1710132432; 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=sur33/r07fjOigoVgwI7K2TQ0VskSGcsp0ttUtyYChw=; b=YrJxBLNlaKzNz7hdVI2OYDVCGX22ZrkwCbMhFW+ArV9wCD2kLmdTm/rlzecGB2KcDkzD3v HhqvKCL9Oe+oh/Y0wBowP1LICuR/XHFfG5ebstdByvbwnvRJ3JKtNd0vLjtmfuPybGnThW aoA5dmXqh4BMSBbjt2zmlXCU8lX8u+PcMHnptYfZMoP3LhVg1Lj9TAcHUue+kYCHN7PBTP ae4cEX4rptkQHrarUNvk8ko/ehy2K+MhYpBXi4gweaxeMPX1PCFJqYvO6u4ULT5YY/Mlrn +HxO2YWxurAYW87SLgwUy6R1NmlCaZhSYKvFHurOyiro8xHAvRJ9zWjt+hAZkw== 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 4TtPQ82ngbzFPV; Mon, 11 Mar 2024 04:47:12 +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 42B4lCqd034380; Mon, 11 Mar 2024 04:47:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42B4lCJH034377; Mon, 11 Mar 2024 04:47:12 GMT (envelope-from git) Date: Mon, 11 Mar 2024 04:47:12 GMT Message-Id: <202403110447.42B4lCJH034377@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: 0010132dbd24 - stable/14 - Hyper-V: vPCI: fix cpu id mis-mapping in vmbus_pcib_map_msi() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 0010132dbd24b9d23a1f9c4a9961b7593438fa34 Auto-Submitted: auto-generated The branch stable/14 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=0010132dbd24b9d23a1f9c4a9961b7593438fa34 commit 0010132dbd24b9d23a1f9c4a9961b7593438fa34 Author: Wei Hu AuthorDate: 2024-03-08 10:00:25 +0000 Commit: Wei Hu CommitDate: 2024-03-11 04:23:18 +0000 Hyper-V: vPCI: fix cpu id mis-mapping in vmbus_pcib_map_msi() The msi address contains apic id. The code in vmbus_pcib_map_msi() treats it as cpu id, which could cause mis-configuration of msix IRQs, leading to missing interrupts for SRIOV devices. This happens when apic id is not the same as cpu id on certain large VM sizes with multiple numa domains in Azure. Fix this issue by correctly mapping apic ids to cpu ids. On vPCI version before 1.4, it only supports up to 64 vcpus for msi/msix interrupt. This change also adds a check and returns error if the vcpu_id is greater than 63. Reported by: NetApp Tested by: whu Sponsored by: Microsoft (cherry picked from commit 999174ba03642fa63c9654752993a62db461afc9) --- sys/dev/hyperv/pcib/vmbus_pcib.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c index da722eb0b834..be66393a7ab4 100644 --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -67,6 +67,7 @@ #if defined(__i386__) || defined(__amd64__) #include #include +#include #endif #if defined(__aarch64__) #include @@ -1891,11 +1892,21 @@ vmbus_pcib_map_msi(device_t pcib, device_t child, int irq, vcpu_id = VMBUS_GET_VCPU_ID(device_get_parent(pcib), pcib, cpu); vector = v_data; #else - cpu = (v_addr & MSI_INTEL_ADDR_DEST) >> 12; + cpu = apic_cpuid((v_addr & MSI_INTEL_ADDR_DEST) >> 12); vcpu_id = VMBUS_GET_VCPU_ID(device_get_parent(pcib), pcib, cpu); vector = v_data & MSI_INTEL_DATA_INTVEC; #endif + if (hpdev->hbus->protocol_version < PCI_PROTOCOL_VERSION_1_4 && + vcpu_id > 63) { + /* We only support vcpu_id < 64 before vPCI version 1.4 */ + device_printf(pcib, + "Error: " + "vcpu_id %u overflowed on PCI VMBus version 0x%x\n", + vcpu_id, hpdev->hbus->protocol_version); + return (ENODEV); + } + init_completion(&comp.comp_pkt.host_event); memset(&ctxt, 0, sizeof(ctxt));