From nobody Fri Mar 08 10:25:44 2024 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 4Trj485qxJz5CrPb; Fri, 8 Mar 2024 10:25:44 +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 4Trj484SRxz47tg; Fri, 8 Mar 2024 10:25:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709893544; 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=tqsc9/fSYWJYWcngw5qgVcKbOn1XyPcExz43gRQmfs4=; b=cLQPBQ5wLMNGIo/N6nPo4i8WqSG9B/YShZ5qxscbAJh+G4/Y1nfr4nNTZUaZ27ZV1pdDKL tjfmdhqnY/SZV98veMijH2E8thlVD7hgnqtuyA7HSoF+6DtohuIj1owJrUI5jCR9PJVnf/ 49xkHJvc+UsvSoxORTy6AalZAD3V5ga/O1YRA05l9LT4sjYRIrCaHYIOkp4KqscBUawQ4c NaK03Qbba5IDgh3ofTST91BL2tZDZpjxBP3+6Ts5FDrskT020R3coc5pGD6cIaWJVu9xbH MDh+gzaMfa7R6ON8GoTEa4L19LlcQ1LSuWwy4rdOEE7zer+6mpRCdkjM3fXFxg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709893544; a=rsa-sha256; cv=none; b=VfIqalUOPttY3mIdVs35pwSG2TAz6R7IkvuQptv9HTY5rgibvTg1HhQabiqbbcATJ+klje hOLR0T7XDZfaNpuwx3tIf48UgtXx43+Jv49hqutBd9SdQlN5YZrd6iqri0tW+nmvYmnxSJ NiDSuTf3j5o+oioMOGp2KNXtH1Sqa2jm1FYwPlXzH7QbKHWWhTYnkpIhLSgO2GHq+tQ7RG s25K9wOT7P/8cWycYVFnO8Qr/G5Ha1Y+YFtnw7qR9cXLGrMjibLK7JKKziDaHm9FBVBcDW tHpce5jsQgOvX39L9sQcwCpqxDimkNm19Ldgu8xRJxfp/w1xWTfZk0FZ7DRb+w== 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=1709893544; 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=tqsc9/fSYWJYWcngw5qgVcKbOn1XyPcExz43gRQmfs4=; b=IGy5sK8FLmWGo/3oQrN2H1i6SXTEtPPJyZ/H4y0dPCGu3AdsHzjmrugzsDGXOOlrmjY2HF qZL9qoGMy00psZUxVZUGJpmnJuqZ9GXRbmw5PLpgHbbdJVqTSAIpgd5Ys7rvXf64iXRHEE ScgetYlLv/xSr1gD4K4U6pim2ArhIpg8sJa6Aw+KqS83M2HyLKqD6CwnIdJ4zVHkH36BIA 0q8FTYud6+xqPRhsS9FRaBKC75BEXpGn4CRLqztl+enUkyEVjN3iJ3mIYMZyzypiRaqZdB FWdAWRm+XpRvaj9oSnLWvEGC23aTQeTfXK5wEriO6b4pWaEdJcjaFUlkDxqxLQ== 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 4Trj4844FDzFBb; Fri, 8 Mar 2024 10:25:44 +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 428APisG081413; Fri, 8 Mar 2024 10:25:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 428APiau081410; Fri, 8 Mar 2024 10:25:44 GMT (envelope-from git) Date: Fri, 8 Mar 2024 10:25:44 GMT Message-Id: <202403081025.428APiau081410@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: 999174ba0364 - main - Hyper-V: vPCI: fix cpu id mis-mapping in vmbus_pcib_map_msi() 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: 999174ba03642fa63c9654752993a62db461afc9 Auto-Submitted: auto-generated The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=999174ba03642fa63c9654752993a62db461afc9 commit 999174ba03642fa63c9654752993a62db461afc9 Author: Wei Hu AuthorDate: 2024-03-08 10:00:25 +0000 Commit: Wei Hu CommitDate: 2024-03-08 10:16:10 +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 MFC after: 1 week --- 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 f7c825d1bcf9..3fa349b0c0c5 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 @@ -1927,11 +1928,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));