From nobody Mon Mar 11 05:30:28 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 4TtQN44JtHz5Dj5q; Mon, 11 Mar 2024 05:30:28 +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 4TtQN43nDRz4NfZ; Mon, 11 Mar 2024 05:30:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710135028; 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=xgwEcBytZ2QSmD4UXdUBKW1FN28r6BBBRxgrwEaBqU4=; b=GVB5Xe4BKzZqDI5FAVF5ojXOK6x9+aDuScmlGb6JTEDJioMWouCDIZhen5bklUHkiMvSRj HQM/5YlH82JM5RPVTWTJ0rvXIg5kijiNMv/TsT7bk/21SxQXmXcpTUqgF59ymWRfwSfaJd O5Dbheco3fhZfyBE5S6KczXmnB8LvYBQwzV00v11zK6EUd/6ku8qxo3zlh8Aw53v60mdxn JKZa2h+qOaDN2JQv63chLJF13wsZdLiNhcNBovnBoNK21jbndiLjf8r2tba3nKgtlXu1N1 XlShp8qvfjIdulGpBcq0IyAff+q9zN6PtZQbCnHEjw1c1+qS7KkIGwYFGc7ObQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710135028; a=rsa-sha256; cv=none; b=qveezlRxSrhuEM3xLsb+qd5TYypFNgkD28V/or+M65avxg/wwfUkd5GN0sRfikUYzJ69wa K5lZdDJ+HHzMtOQwT37gFDiYFxoqEKBL+CWlSJns6WWouGv2WaHKOpEOWmk9peJqCTonmx HxMhzA5DOQDysBcfPDnxioYEa3qoK7Gklk8TvXfVHG7J9+Ytp/aVZ0nSBrGu0v0c//d4r/ 355DJ6mScfB7OZTTSj+PmMHeI8RpPovNoOsZB93pJLWooqeFce+G5HAwg4TWr4gDoGL5J0 AvsUpmXyYOFbQsPqqLHEqXZva6o0HYRXCfWr3bY+gPApNfZ5CKvHUNYQARdwJw== 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=1710135028; 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=xgwEcBytZ2QSmD4UXdUBKW1FN28r6BBBRxgrwEaBqU4=; b=xf+k1y8wvwDNsrQ+UJR2CxEvGcBKquHFgx3tL1k9In7cAdq5gIa/y8UsTm05w2ASPKRkWg pPLEsh+vm8WD6dw8zFtvMxuyTbBRJh/9abIL59/HvvpIqI4tNjANbyGTNdPEr4Nwbl4apD OE21H/6UNUv86c9s3fLwpSzHBPJzLQWsF+hO1A/QUgYrwoWvh/kBqEDoivABjlbB93BLRY jyDFcdIxxIWBKKiT+WiUuEHfFW72drjn59ebi500scQKxLfdNdJ8/zF7Q48eCcf6xPG26O a1NKa7GNh8GUHs7DtvGCoGNqLob5zpZImfSnootlnttS2g9/AnHoI8YeW457RQ== 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 4TtQN43NZpzHJ0; Mon, 11 Mar 2024 05:30:28 +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 42B5US3K011264; Mon, 11 Mar 2024 05:30:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42B5US4E011261; Mon, 11 Mar 2024 05:30:28 GMT (envelope-from git) Date: Mon, 11 Mar 2024 05:30:28 GMT Message-Id: <202403110530.42B5US4E011261@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: fa397e50fd88 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: fa397e50fd8820446d44b90cf4017bd31e264c76 Auto-Submitted: auto-generated The branch stable/13 has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=fa397e50fd8820446d44b90cf4017bd31e264c76 commit fa397e50fd8820446d44b90cf4017bd31e264c76 Author: Wei Hu AuthorDate: 2024-03-11 05:24:53 +0000 Commit: Wei Hu CommitDate: 2024-03-11 05:29:52 +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. (cherry picked from commit 999174ba03642fa63c9654752993a62db461afc9) Reported by: NetApp Tested by: whu Sponsored by: Microsoft --- sys/dev/hyperv/pcib/vmbus_pcib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c index 037ea7032184..ec80d97a959f 100644 --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -63,6 +63,7 @@ #include #include +#include #include #include @@ -1804,10 +1805,17 @@ vmbus_pcib_map_msi(device_t pcib, device_t child, int irq, } } - 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; + if (vcpu_id > 63) { + /* We only support vcpu_id < 64 on current vPCI version*/ + device_printf(pcib, + "Error: vcpu_id %u overflowed\n", vcpu_id); + return (ENODEV); + } + init_completion(&comp.comp_pkt.host_event); memset(&ctxt, 0, sizeof(ctxt));