From nobody Fri Oct 31 18:20:55 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=1748696090; cv=pass; d=zohomail.com; s=zohoarc; b=UjyEZTa6bfv2lnQbXxnd8Cv3dohqH0WUTgcI3YEh3/BjpOokOSh1o0fFB+Do9X7M3qAkODS7H+8hzc1cUUF4PezvJYJiYSJ6xgonpvie+sHTOBCY+IOmmHyRZMjmIhJSF4eCjW9BjxX7sh/7ogm2nGceqrlzpeBMf9dnUAZO5wo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748696090; 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=b8T8GqrveNE1OlycZlEksUxncr6lhVzWwzvdzZ1VRls=; b=gkqJB3OpTJObB4Y6HN8Dzp9vORY6qvE4BcaVvhuVfuTQsc2h40cHM5Xyj8tgcwQ6CRXbFXu52VTaR7krQM/au+mYByy0jPJQ/YzS5twzT63xWhanY5ZU58USVYuIlOEmrgBspCwYdhUxYpkKJBAjvRy/qy8EGDrtnuLJR18KRe8= 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 1748696090250207.5455780545126; Sat, 31 May 2025 05:54:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1002021.1382052 (Exim 4.92) (envelope-from ) id 1uLLjG-00006T-4q; Sat, 31 May 2025 12:54:26 +0000 Received: by outflank-mailman (output) from mailman id 1002021.1382052; Sat, 31 May 2025 12:54:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uLLjG-00006K-2A; Sat, 31 May 2025 12:54:26 +0000 Received: by outflank-mailman (input) for mailman id 1002021; Sat, 31 May 2025 12:54:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uLLjF-0008IU-Hf for xen-devel@lists.xenproject.org; Sat, 31 May 2025 12:54:25 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20605.outbound.protection.outlook.com [2a01:111:f403:2409::605]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 604ca8b1-3e1e-11f0-a300-13f23c93f187; Sat, 31 May 2025 14:54:24 +0200 (CEST) Received: from IA4P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:558::16) by SA1PR12MB8163.namprd12.prod.outlook.com (2603:10b6:806:332::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8769.29; Sat, 31 May 2025 12:54:18 +0000 Received: from BN2PEPF0000449D.namprd02.prod.outlook.com (2603:10b6:208:558:cafe::7b) by IA4P220CA0007.outlook.office365.com (2603:10b6:208:558::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8792.24 via Frontend Transport; Sat, 31 May 2025 12:54:18 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF0000449D.mail.protection.outlook.com (10.167.243.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8792.29 via Frontend Transport; Sat, 31 May 2025 12:54:17 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Sat, 31 May 2025 07:54:17 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sat, 31 May 2025 07:54:16 -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: 604ca8b1-3e1e-11f0-a300-13f23c93f187 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vjVMj59ue9T0HRhKhQPy//JQjNo64M8o5RSIJWXi/m/j2ii+XeWv3gB4QIKrd7pUL/FbqD7A5u+/Yf8HAJKbVSnI+AQ2vM1F7a45tEViCjEHIA4+oe+PqX9Qw/4NcvLUu7zDq8zYM7Ui7UF+VX+E0ZnuMyyTOymk6QWOe8xpiFUH+si78B9xwfxCEBu27eNllOy0loqgHFf/FOx5mT5aCdTYCPY28oPLYkx9nnXFZ+J06aWkJZMcV1E2SZDiCvgepCGgYlWSUjMzZtOvbtwINp5IqVNfdVPg5NSC6sRvN6VKZCSMHd5q1zF5ELzna29kQyNk35RaLOrqlbtGYnUUkg== 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=b8T8GqrveNE1OlycZlEksUxncr6lhVzWwzvdzZ1VRls=; b=V6pcRJ3l3fFJvG1rK7kr8zpDi6MuK2QxvwtiWLOygi9SyE+EXXV91R6OLWgoP+le8xH3CmH1yV6KTQbSNFubIm8w8r+6a85AV0Mhnn6ikwCAuW10noatIXiwLgYE+alPXvyXuB3FXNU4KJ4lZowXEyvrN+UqpxWA5LBupeUM19zvXr2yh3ukPFjDVjtjG8Dwdh+2URoVneitLEncqrDC2DiOtf+mbE5jyq0/ocWodv4FVKUhX78W/9CprgMlmXHZWqLOx073hKVCGEh0OXKBAo+kE6vXR05d9GAYINFZE8PFEPhZVPb4vMATaH3eUlBWAbEdsjmDMwkQPA6c9QTLoQ== 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=b8T8GqrveNE1OlycZlEksUxncr6lhVzWwzvdzZ1VRls=; b=ApNosnu17zQEKHcoIjgT7xQO2Al7+dYXHPgGE6xqvknje3k+ycpIUMLU1ovANTYvxTCnpfSo/RU5dEOn54GjPQt+a2f+JKTXX3KLok1PnBbYzSGRubGO1RRQ3MbScNvQG322Dzin36qfgD4Ufx9k6MrLtyNggbAWDdpVLal0qT8= 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: Stewart Hildebrand To: CC: Stewart Hildebrand , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v1 1/5] vpci: const-ify some pdev instances Date: Sat, 31 May 2025 08:53:59 -0400 Message-ID: <20250531125405.268984-2-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250531125405.268984-1-stewart.hildebrand@amd.com> References: <20250531125405.268984-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB04.amd.com: stewart.hildebrand@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000449D:EE_|SA1PR12MB8163:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fe736c3-f081-4db0-6e7b-08dda0424128 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?A91mWcmeILaReVai66cqdmuURSesgh0Cs7/pZor5VGqKXSF//kZgHRyzSvcC?= =?us-ascii?Q?sMlINnIKC2mnmB8zgxJ588MvCxO7FzNfE4R3BrkT3tUTd+H6ScmLvAOVUHD1?= =?us-ascii?Q?92w0vnR1Ns4sZDEqUHZMYy7+ypz6qGFNwux9dRmwhMENplASEz90Yx8cJPun?= =?us-ascii?Q?8jH2EZnjuUDlg/FhcttTWWxaakq5RlIeiHhu2OpV0zbJAnMZjMcHygdKiD/D?= =?us-ascii?Q?yuRqrAUTwqCnWt15jZnOHB6nWfkXTRd1svHVmqx5h/0hH+vi6hHxGLjOn38x?= =?us-ascii?Q?cSMVsgbHVOrzjnDJj7O/gfool7696Y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WQVxI1G5j+3MUof0puC7Z72U8wv64C7L/zEJ+7IxRPaZDQ?= =?us-ascii?Q?t0d4GGggkN4WW7QlO5zzukU4v1wp9yIRIiU+Zzv7giszQpfeKH0AzprRzRne?= =?us-ascii?Q?6yvTrwBRfqiUztihQlJ/7w7eSEpsTaidKUb+DowyOBiVYvEL/hNs+gitGpPn?= =?us-ascii?Q?c3zX1HFp2dyxNlsyFNWxH6JuaTQuiC2Rb/CxVfEryQSfGr9kjpgInClhC8Z+?= =?us-ascii?Q?iREh7wEYC0ATvxojAnY+DvayIDflRhn6xv0Ey47GQCDSC8v7+UDMbkCPyhUO?= =?us-ascii?Q?gbru/VYSMvqvlHk0jBbnNVtPSOAHagA7ngDy?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2025 12:54:17.7509 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fe736c3-f081-4db0-6e7b-08dda0424128 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: BN2PEPF0000449D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8163 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1748696091077116600 Content-Type: text/plain; charset="utf-8" Since 622bdd962822 ("vpci/header: handle p2m range sets per BAR"), a non-const pdev is no longer needed for error handling in vpci_process_pending(). Const-ify pdev in vpci_process_pending(), defer_map(), and struct vpci_vcpu. Get rid of const-removal workaround in modify_bars(). Take the opportunity to remove an unused parameter in defer_map(). Signed-off-by: Stewart Hildebrand Reviewed-by: Roger Pau Monn=C3=A9 --- This is prerequisite for ("vpci: use separate rangeset for BAR unmapping") in order to call defer_map() with a const pdev. --- xen/drivers/vpci/header.c | 16 ++++------------ xen/include/xen/vpci.h | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index 1f48f2aac64e..e42c8efa2302 100644 --- a/xen/drivers/vpci/header.c +++ b/xen/drivers/vpci/header.c @@ -175,7 +175,7 @@ static void modify_decoding(const struct pci_dev *pdev,= uint16_t cmd, =20 bool vpci_process_pending(struct vcpu *v) { - struct pci_dev *pdev =3D v->vpci.pdev; + const struct pci_dev *pdev =3D v->vpci.pdev; struct vpci_header *header =3D NULL; unsigned int i; =20 @@ -283,8 +283,7 @@ static int __init apply_map(struct domain *d, const str= uct pci_dev *pdev, return rc; } =20 -static void defer_map(struct domain *d, struct pci_dev *pdev, - uint16_t cmd, bool rom_only) +static void defer_map(const struct pci_dev *pdev, uint16_t cmd, bool rom_o= nly) { struct vcpu *curr =3D current; =20 @@ -308,7 +307,7 @@ static void defer_map(struct domain *d, struct pci_dev = *pdev, static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_= only) { struct vpci_header *header =3D &pdev->vpci->header; - struct pci_dev *tmp, *dev =3D NULL; + struct pci_dev *tmp; const struct domain *d; const struct vpci_msix *msix =3D pdev->vpci->msix; unsigned int i, j; @@ -450,11 +449,6 @@ static int modify_bars(const struct pci_dev *pdev, uin= t16_t cmd, bool rom_only) =20 if ( tmp =3D=3D pdev ) { - /* - * Need to store the device so it's not constified and def= er_map - * can modify it in case of error. - */ - dev =3D tmp; if ( !rom_only ) /* * If memory decoding is toggled avoid checking agains= t the @@ -507,8 +501,6 @@ static int modify_bars(const struct pci_dev *pdev, uint= 16_t cmd, bool rom_only) d =3D dom_xen; } =20 - ASSERT(dev); - if ( system_state < SYS_STATE_active ) { /* @@ -523,7 +515,7 @@ static int modify_bars(const struct pci_dev *pdev, uint= 16_t cmd, bool rom_only) return apply_map(pdev->domain, pdev, cmd); } =20 - defer_map(dev->domain, dev, cmd, rom_only); + defer_map(pdev, cmd, rom_only); =20 return 0; } diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 475981cb8155..27eebdcef170 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -194,7 +194,7 @@ struct vpci { =20 struct vpci_vcpu { /* Per-vcpu structure to store state while {un}mapping of PCI BARs. */ - struct pci_dev *pdev; + const struct pci_dev *pdev; uint16_t cmd; bool rom_only : 1; }; --=20 2.49.0