From nobody Thu Oct 30 23:09:19 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1753336262; cv=pass; d=zohomail.com; s=zohoarc; b=S9fvmBtAprVsrE/JuCzdBzco69mv9O+8iJm9fZEHP7DaetqtvHtsnd4BUfFMIxKekD0uStCZ6OYUio/rddbnGgEhkYcIKoDN2k9sOo4+oatmJ9ZmNEKT+guDud21nFTQHyeMOVTxBPmlQe51O41diWgu9uQsnFLWf+xPvhSg1ds= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753336262; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FsUNJ7a4FB2K+Y/WH3LrXbvNnHtpf9eqxl3+5xeuxYA=; b=GPIuc0hpd5Kaa+tWYOPqYMqaLBtdRun4p0jkQff5gal9deoVKCfvfsdjgwChU3uaernoPxxwL2pESL3pIHV3vo+78VlF5RzSJ/LNEfzsnBN1yW/L06xVOEOtKYAFHCyNei41ibfJ/GRCEsebcqoF5Ep3tvPuEH+PgFEga67dez0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753336262407131.7265605990923; Wed, 23 Jul 2025 22:51:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1055184.1423673 (Exim 4.92) (envelope-from ) id 1ueoqt-0006G8-2a; Thu, 24 Jul 2025 05:50:47 +0000 Received: by outflank-mailman (output) from mailman id 1055184.1423673; Thu, 24 Jul 2025 05:50:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ueoqs-0006Fu-Vf; Thu, 24 Jul 2025 05:50:46 +0000 Received: by outflank-mailman (input) for mailman id 1055184; Thu, 24 Jul 2025 05:50:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ueoqr-0005TY-DK for xen-devel@lists.xenproject.org; Thu, 24 Jul 2025 05:50:45 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20609.outbound.protection.outlook.com [2a01:111:f403:2413::609]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 230b44ec-6852-11f0-b895-0df219b8e170; Thu, 24 Jul 2025 07:50:43 +0200 (CEST) Received: from SJ0PR03CA0142.namprd03.prod.outlook.com (2603:10b6:a03:33c::27) by IA0PR12MB7580.namprd12.prod.outlook.com (2603:10b6:208:43b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8943.29; Thu, 24 Jul 2025 05:50:36 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:a03:33c:cafe::ac) by SJ0PR03CA0142.outlook.office365.com (2603:10b6:a03:33c::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.21 via Frontend Transport; Thu, 24 Jul 2025 05:50:36 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Thu, 24 Jul 2025 05:50:35 +0000 Received: from cjq-desktop.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 24 Jul 2025 00:50:32 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 230b44ec-6852-11f0-b895-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XDrEm/4PdG8OkhjgAOdK0JIinRTJ1dcpwL4GgrNGW3B9SNQ3y0BT47UdCc6w/B+FWUrn/M74PCNFiPAa2zfW/E35xSJ2ISYgdjHLIkEiR4VrPEXKhIz2F/HievdBdwX9tBMnrjuMQjUlMa+mXUYkQIebolf4vISFx6rxJygq1I88ZMkNSZ4eCGGl5cW+Cnb5Wb2t9mifuSl/xvoCzXof+cJ+3nhK5h1veOre+VeXXmUk4u1GMCQrzXFtNYlwuGZkma25fPZhH67j5uKEubaRxYZLguYqai/7HBm7f58MjEWKS4ln/iuuYEJFCCRp56VvHcRkfdd84oFC+f9TRTVt3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FsUNJ7a4FB2K+Y/WH3LrXbvNnHtpf9eqxl3+5xeuxYA=; b=VyEqCj9VnkynqyU8dHkuHbzGgfhuKXqT6At7Z7m3o4lWmK/EBoRWG7m/nyAj4g5twVRgNmpsftIOLasZqp0CKoW39i/EtSzed6thgcVKP05voSYfYD4Cja2c20MjaR5oWu3FLCLRZw0SYeW9yPHC4py+ID5p9W68IO+jxEWLlR2LwB3r6gxZ0jj4TCgGEJ+/xp768FG8HxwLsZN6umdthhMNFL+K5gMtuVlMSdoX6yGTm6s+NDDuuBQKhqI0582GXzNFQh9KhXXo3GyoEfDUACIf4+ZaPRTSC9733OVgYAgwKgLozT01qiAEXdqnHtVTUn5vLw9Cd4RJGau2pq8AJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FsUNJ7a4FB2K+Y/WH3LrXbvNnHtpf9eqxl3+5xeuxYA=; b=Yc/teFE+i8yGZT/hyibNINOUFD2OXi98/nLSGiZIyuu1S7+Qz4YgpXmAk9JCHfenEYXwqmhkgnq8RXXm0JxTSN6mkESCbOyyaiewJMOUn2zgJYn4sOyiSC6hYtrd/EzjONW8p+UxS0OPwyrrHJFV6g8QV529/AaNFgfvzC5iTvE= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Jiqian Chen To: CC: Huang Rui , Jiqian Chen , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , "Julien Grall" , Stefano Stabellini Subject: [PATCH v8 4/8] vpci: Hide extended capability when it fails to initialize Date: Thu, 24 Jul 2025 13:50:02 +0800 Message-ID: <20250724055006.29843-5-Jiqian.Chen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250724055006.29843-1-Jiqian.Chen@amd.com> References: <20250724055006.29843-1-Jiqian.Chen@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CC:EE_|IA0PR12MB7580:EE_ X-MS-Office365-Filtering-Correlation-Id: 2abf00b4-1a21-428b-859d-08ddca7602f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Ymd2bWxCZWRtbWo4U1lmS3VGang0eVVCbU1kamJxekk4aHV0bGpTL0l4Q3J5?= =?utf-8?B?YTB6RFdROU5COGgyeWNEYmFnTm5BQm44T0IxTHdNMGJZUk05QStPUFpCQjBz?= =?utf-8?B?aE4ycTNvYWxQRDZDZ2p4eU8wOG5YSWdXeEFPd0gzVWpZSldnUm1mcG5sZnBH?= =?utf-8?B?V3pJVkg0aXZHcFpNTk1ISW9tNDZZOXJBdlZRem5zYXJCQmJHUmJ4Ny85Mkda?= =?utf-8?B?WHNheWJQQkhYV0J4ZWFVZWo0ZWhpR2NTdGZhbnowUjQyK0FaUlRPcDJmREF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TRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2025 05:50:35.9400 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2abf00b4-1a21-428b-859d-08ddca7602f0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7580 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1753336263192116600 When vpci fails to initialize an extended capability of device, it just returns an error and vPCI gets disabled for the whole device. So, add function to hide extended capability when initialization fails. And remove the failed extended capability handler from vpci extended capability list. Signed-off-by: Jiqian Chen Reviewed-by: Roger Pau Monn=C3=A9 --- cc: "Roger Pau Monn=C3=A9" cc: Andrew Cooper cc: Anthony PERARD cc: Michal Orzel cc: Jan Beulich cc: Julien Grall cc: Stefano Stabellini --- v7->v8 changes: * s/and force/hopefully forcing/ in vpci_ext_capability_hide(). * Add Roger's Reviewed-by. v6->v7 changes: * Change the pointer parameter of vpci_get_previous_ext_cap_register() and vpci_ext_capability_hide() to be const. v5->v6 changes: * Change to use for loop to compact code of vpci_get_previous_ext_cap_regis= ter(). * Rename parameter rm to r in vpci_ext_capability_hide(). * Change comment to describ the case that hide capability of position 0x100U. v4->v5 changes: * Modify the hex digits of PCI_EXT_CAP_NEXT_MASK and PCI_EXT_CAP_NEXT to be= low case. * Rename vpci_ext_capability_mask to vpci_ext_capability_hide. v3->v4 changes: * Change definition of PCI_EXT_CAP_NEXT to be "#define PCI_EXT_CAP_NEXT(hea= der) (MASK_EXTR(header, PCI_EXT_CAP_NEXT_MASK) & 0xFFCU)" to avoid redundancy. * Modify the commit message. * Change vpci_ext_capability_mask() to return error instead of using ASSERT. * Set the capability ID part to be zero when we need to hide the capability= of position 0x100U. * Add check "if ( !offset )" in vpci_ext_capability_mask(). v2->v3 changes: * Separated from the last version patch "vpci: Hide capability when it fail= s to initialize". * Whole implementation changed because last version is wrong. This version gets target handler and previous handler from vpci->handlers= , then remove the target. * Note: a case in function vpci_ext_capability_mask() needs to be discussed, because it may change the offset of next capability when the offset of ta= rget capability is 0x100U(the first extended capability), my implementation is= just to ignore and let hardware to handle the target capability. v1->v2 changes: * Removed the "priorities" of initializing capabilities since it isn't used= anymore. * Added new function vpci_capability_mask() and vpci_ext_capability_mask() = to remove failed capability from list. * Called vpci_make_msix_hole() in the end of init_msix(). Best regards, Jiqian Chen. --- xen/drivers/vpci/vpci.c | 88 ++++++++++++++++++++++++++++++++++++++ xen/include/xen/pci_regs.h | 5 ++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index 9960b11cf2c9..26cda5b3262a 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -165,6 +165,92 @@ static int vpci_capability_hide(const struct pci_dev *= pdev, unsigned int cap) return 0; } =20 +static struct vpci_register *vpci_get_previous_ext_cap_register( + const struct vpci *vpci, unsigned int offset) +{ + unsigned int pos =3D PCI_CFG_SPACE_SIZE; + struct vpci_register *r; + + if ( offset <=3D PCI_CFG_SPACE_SIZE ) + { + ASSERT_UNREACHABLE(); + return NULL; + } + + for ( r =3D vpci_get_register(vpci, pos, 4); r; + r =3D pos > PCI_CFG_SPACE_SIZE ? vpci_get_register(vpci, pos, 4) + : NULL ) + { + uint32_t header =3D (uint32_t)(uintptr_t)r->private; + + ASSERT(header =3D=3D (uintptr_t)r->private); + + pos =3D PCI_EXT_CAP_NEXT(header); + if ( pos =3D=3D offset ) + break; + } + + return r; +} + +static int vpci_ext_capability_hide( + const struct pci_dev *pdev, unsigned int cap) +{ + const unsigned int offset =3D pci_find_ext_capability(pdev->sbdf, cap); + struct vpci_register *r, *prev_r; + struct vpci *vpci =3D pdev->vpci; + uint32_t header, pre_header; + + if ( offset < PCI_CFG_SPACE_SIZE ) + { + ASSERT_UNREACHABLE(); + return 0; + } + + spin_lock(&vpci->lock); + r =3D vpci_get_register(vpci, offset, 4); + if ( !r ) + { + spin_unlock(&vpci->lock); + return -ENODEV; + } + + header =3D (uint32_t)(uintptr_t)r->private; + if ( offset =3D=3D PCI_CFG_SPACE_SIZE ) + { + if ( PCI_EXT_CAP_NEXT(header) <=3D PCI_CFG_SPACE_SIZE ) + r->private =3D (void *)(uintptr_t)0; + else + /* + * The first extended capability (0x100) can not be removed fr= om + * the linked list, so instead mask its capability ID to retur= n 0 + * hopefully forcing OSes to skip it. + */ + r->private =3D (void *)(uintptr_t)(header & ~PCI_EXT_CAP_ID(he= ader)); + + spin_unlock(&vpci->lock); + return 0; + } + + prev_r =3D vpci_get_previous_ext_cap_register(vpci, offset); + if ( !prev_r ) + { + spin_unlock(&vpci->lock); + return -ENODEV; + } + + pre_header =3D (uint32_t)(uintptr_t)prev_r->private; + pre_header &=3D ~PCI_EXT_CAP_NEXT_MASK; + pre_header |=3D header & PCI_EXT_CAP_NEXT_MASK; + prev_r->private =3D (void *)(uintptr_t)pre_header; + + list_del(&r->node); + spin_unlock(&vpci->lock); + xfree(r); + + return 0; +} + static int vpci_init_capabilities(struct pci_dev *pdev) { for ( unsigned int i =3D 0; i < NUM_VPCI_INIT; i++ ) @@ -206,6 +292,8 @@ static int vpci_init_capabilities(struct pci_dev *pdev) =20 if ( !is_ext ) rc =3D vpci_capability_hide(pdev, cap); + else + rc =3D vpci_ext_capability_hide(pdev, cap); if ( rc ) { printk(XENLOG_ERR "%pd %pp: hide %s cap %u fail rc=3D%d\n", diff --git a/xen/include/xen/pci_regs.h b/xen/include/xen/pci_regs.h index 27b4f44eedf3..3b6963133dbd 100644 --- a/xen/include/xen/pci_regs.h +++ b/xen/include/xen/pci_regs.h @@ -448,7 +448,10 @@ /* Extended Capabilities (PCI-X 2.0 and Express) */ #define PCI_EXT_CAP_ID(header) ((header) & 0x0000ffff) #define PCI_EXT_CAP_VER(header) (((header) >> 16) & 0xf) -#define PCI_EXT_CAP_NEXT(header) (((header) >> 20) & 0xffc) +#define PCI_EXT_CAP_NEXT_MASK 0xfff00000U +/* Bottom two bits of next capability position are reserved. */ +#define PCI_EXT_CAP_NEXT(header) \ + (MASK_EXTR(header, PCI_EXT_CAP_NEXT_MASK) & 0xffcU) =20 #define PCI_EXT_CAP_ID_ERR 1 #define PCI_EXT_CAP_ID_VC 2 --=20 2.34.1