Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7652647ECDB; Thu, 4 Jun 2026 13:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780579699; cv=none; b=kQi7WTze/eDhT9kpJFqvXUJV+ug1leKPf1Va5OE76VJehR9bIzRM/3xu+NZwU4y0pJ5JY4elbN/2mEVARL3ey0L6LTSlpech1FJoz5Gbh9uRqqU6QCgSVjzdCMAY+smINEq9aiE4JeXq3s+I15K3LAjQDS7glLvc8J7qqZwQUac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780579699; c=relaxed/simple; bh=1m9IJBOEkL4RpdNJElwl1z0MSdhEs5oA6DFQE9WjFNM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F6KQQERvSpCwaPcjE9fUljThM9c+gLIx7QnyZI3UzDR3odinDf1iQARiqXA352SGlME0pbDR/UjXMKim8YU1kMiqaebrAzcY+y/YzB1JRJ5Y6gHWKSeBn/48XCdTMLmeiITpz6hxsuWohgcKiOZDrZCuPce4PwVQP0+n1e/J6oo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=Dlm7IwTG; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="Dlm7IwTG" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=zFjLYjrqTMGEWs3izGtCqk21jAnJ8+1yVzRezvBlzTs=; b=Dlm7IwTGP1GrUm3mGMZpVDIy/fjmCiF5aRVJ9hDGPAatjqtVoBWK0hquhQOarbnFRiYfzd/O7 7HL2bCapgCkS6lNJDrsMhHnrWAMHOmX3MQYTxUUF0sExYNu0U5MQzFmglP8e6R7RvuYIscZuPr7 hbS4l63xkb6DBuwLBEyuE7s= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4gWQD25jF4z12LJh; Thu, 4 Jun 2026 21:20:18 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id D021140537; Thu, 4 Jun 2026 21:28:13 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 4 Jun 2026 21:28:13 +0800 From: Chengwen Feng To: , CC: , , , , , , , , Subject: [PATCH v16 08/12] vfio/pci: Hide TPH capability when TPH is unsupported Date: Thu, 4 Jun 2026 21:28:00 +0800 Message-ID: <20260604132804.28678-9-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260604132804.28678-1-fengchengwen@huawei.com> References: <20260604132804.28678-1-fengchengwen@huawei.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemk500009.china.huawei.com (7.202.194.94) Check the device negotiated TPH support status before parsing the TPH extended capability. Return zero length to hide the capability from userspace if TPH is disabled during topology negotiation. Signed-off-by: Chengwen Feng --- drivers/vfio/pci/vfio_pci_config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index a10ed733f0e3..5c6ab172df6c 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1450,6 +1451,8 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo byte &= PCI_DPA_CAP_SUBSTATE_MASK; return PCI_DPA_BASE_SIZEOF + byte + 1; case PCI_EXT_CAP_ID_TPH: + if (!pcie_tph_supported(pdev, false)) + return 0; ret = pci_read_config_dword(pdev, epos + PCI_TPH_CAP, &dword); if (ret) return pcibios_err_to_errno(ret); -- 2.17.1