From patchwork Thu Aug 10 19:12:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13349839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84AD3C001E0 for ; Thu, 10 Aug 2023 19:14:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.582174.911794 (Exim 4.92) (envelope-from ) id 1qUB6Z-0003vI-V8; Thu, 10 Aug 2023 19:13:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 582174.911794; Thu, 10 Aug 2023 19:13:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUB6Z-0003vB-QG; Thu, 10 Aug 2023 19:13:55 +0000 Received: by outflank-mailman (input) for mailman id 582174; Thu, 10 Aug 2023 19:13:54 +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 1qUB6Y-0003Ze-Ey for xen-devel@lists.xenproject.org; Thu, 10 Aug 2023 19:13:54 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062b.outbound.protection.outlook.com [2a01:111:f400:7eab::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0a50274b-37b2-11ee-8613-37d641c3527e; Thu, 10 Aug 2023 21:13:52 +0200 (CEST) Received: from MWH0EPF00056D05.namprd21.prod.outlook.com (2603:10b6:30f:fff2:0:1:0:e) by PH7PR12MB6933.namprd12.prod.outlook.com (2603:10b6:510:1b7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Thu, 10 Aug 2023 19:13:47 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2a01:111:f403:c903::) by MWH0EPF00056D05.outlook.office365.com (2603:1036:d20::b) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.7 via Frontend Transport; Thu, 10 Aug 2023 19:13:46 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 19:13:45 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 10 Aug 2023 14:13:45 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 10 Aug 2023 12:13:44 -0700 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 10 Aug 2023 14:13:44 -0500 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: 0a50274b-37b2-11ee-8613-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZuR4tI8Nijs/tOE+ybOzOjq2TcLMt5dFyufMIaVDsqT+vhoFl9FOUy5rOXmgOmnqMmmBb7QHEIujizcWaLkUaSKRLy48WaV7O9XpoO9W4+zCvtQrWLovql/igKbBzlnjpwZbwt24D9ccnctd7FAbz2TzlcSh+IaP//H+hxJAs3gy3m7fDK8ZWbiyTym1ljBgOee6C+Axv2FQkqIPMG5vAUThzD5yT76B1mqU2bVMWzWm9kPEBFiP6Ok4VEBfxsJaHwCK1otCWttOvqh6HUnr3SdJnGHoCVh10vd6HqirdVgnOrge2oLdGZZB6OS4rP6d3aHBO81FLa1xEaCnbNxag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=J4yLLAlz56YDsP4hB+WtRJV0qGSq8/4CwsqKhUFrp3Q=; b=YNGAuAnQrULH4FTTRGU61MilkXcsE04SQ6Gn4xeeftIWWDvTgSJZdshV+VdQKnJzfWtT+r6cxGNVkDYeyXFAiu1Zss5GcDUl4rc56+E41MxbL65KJ/sgcDBO+YMzr2qsK6YawM9gTqXiDkTbXoCPPSUvWgRD37ESvJhWE1r2jmqbGyKtIABpbwrfc7/eZldLn9cQuzmo1sT1mabAeSjgnuRy5o2ONOwzzohfMjRxtDw0aHaZ4NRP/QWUFj58J2TKW5iMmTbzeUquW8bG0GsEZ+xgSuz/sICq3b19Hj2ZWYd/oZzoYhjgd6WXGN13/Kriw6IAuCikgj7lUeI42F+C/A== 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 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=J4yLLAlz56YDsP4hB+WtRJV0qGSq8/4CwsqKhUFrp3Q=; b=NCZSOCDOT/dBQme0CHOfIY+P/+e/SQbKYbJUA76uG72KOLDguMt4/BlkXu5cmflp9iX+OUi6YZJ3RyJzb13G6b9Hp5DnE7wLz4jYKq1D8QD1z9n3EZRAriIYnlzsWSIrQvuC3nX0jR5TYYNYEm1M0GL/Xfq5Tl4259YSvF77AXA= 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 (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=SATLEXMB03.amd.com; pr=C From: Stewart Hildebrand To: CC: Stewart Hildebrand , =?utf-8?q?Roger_Pau_Mon?= =?utf-8?q?n=C3=A9?= Subject: [PATCH v1 1/3] xen/vpci: add vpci_hw_read8 helper Date: Thu, 10 Aug 2023 15:12:57 -0400 Message-ID: <20230810191312.644235-2-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810191312.644235-1-stewart.hildebrand@amd.com> References: <20230810191312.644235-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A9:EE_|PH7PR12MB6933:EE_ X-MS-Office365-Filtering-Correlation-Id: c7c12e43-9aae-4bfa-61f6-08db99d5eb82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L+oMc+vEZQZaVHMNCp8Ql0UGWG4HGD5K/l47rqOXiiJbDRlbolOIiHVJwpPyPMS+1jtk2kjiwvJnW/GYGkCAxrg7cDTe/dhH9LrgGmO4RPat04bY61lJtDfGdEoG9Ss7OWUL0fJfkphve9WfBPv/LBLpNAy3w3N9sl2Q1ZyZ9VazSSvSuBUU44nJqBQoz0ChS83L31HRQubQt2tq+qN16ZUfQj4LrtSrPJOwXgYhX6rEeyV9HGT/zYwTJVTc+lVrFJnTl5aDyEXLWaB6bfsOvqtnQG+VqodV0GlSvxlXXwiyQsPPD5ZoqqvAJd91ATx3PjNalCH1OEXfHAd2CFTe0sruBi2ocO1i1GIVDIZPWwbkuJQEKsMb0hKVx6RJEQ5Yz6pFE27eGabHE72nruln8GKQDwRMLzHcl9BZWFXGTqYylcAStnnblbnBHBHqFTQmyJ23OxOGjJ2Kl6T5M7DPZlF+/sLTOXg/7a3Lb7eaI2LSc0fdq1E2MWSzHE7i7tMg4lIO/z6ed7hz+tkfPjD1vF4zdVxwkBKo3S6qALsJnHjq9j8Dw9Yn5bLZRCcArQzFiA2MaMuoLCvvk0pCvQogqglDcVwlqsyo7b993CVsS/qPtRsP52omN8/j2Kt9nS4CVaNjKijwFYjajDrXjtUrGIRUjsHrbY43um44EbR56SQpYkkexVMwgIdWBu/fb/TbfNg1Y+p5F88op3wPJ5ak1ZzU/7eedp6nO9NQUuIGanuchxcIcJt70fouYssgRAsWIBVNB3s+xKdi+QzqFmilvQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(396003)(376002)(346002)(186006)(82310400008)(451199021)(1800799006)(40470700004)(36840700001)(46966006)(1076003)(36756003)(2616005)(336012)(26005)(6666004)(81166007)(82740400003)(478600001)(356005)(70206006)(70586007)(4326008)(316002)(41300700001)(54906003)(86362001)(8676002)(8936002)(5660300002)(44832011)(426003)(40460700003)(2906002)(6916009)(36860700001)(47076005)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 19:13:45.9769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7c12e43-9aae-4bfa-61f6-08db99d5eb82 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6933 This will be used in a subsequent patch. Signed-off-by: Stewart Hildebrand --- xen/drivers/vpci/vpci.c | 6 ++++++ xen/include/xen/vpci.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index d73fa7630237..acadba1fd6c5 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -133,6 +133,12 @@ static void cf_check vpci_ignored_write( { } +uint32_t cf_check vpci_hw_read8( + const struct pci_dev *pdev, unsigned int reg, void *data) +{ + return pci_conf_read8(pdev->sbdf, reg); +} + uint32_t cf_check vpci_hw_read16( const struct pci_dev *pdev, unsigned int reg, void *data) { diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index 0b8a2a3c745b..ee7a8fcdee83 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -46,6 +46,8 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, uint32_t data); /* Passthrough handlers. */ +uint32_t cf_check vpci_hw_read8( + const struct pci_dev *pdev, unsigned int reg, void *data); uint32_t cf_check vpci_hw_read16( const struct pci_dev *pdev, unsigned int reg, void *data); uint32_t cf_check vpci_hw_read32( From patchwork Thu Aug 10 19:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13349840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8597AC001B0 for ; Thu, 10 Aug 2023 19:14:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.582175.911803 (Exim 4.92) (envelope-from ) id 1qUB6k-0004K7-9w; Thu, 10 Aug 2023 19:14:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 582175.911803; Thu, 10 Aug 2023 19:14:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUB6k-0004Jv-6x; Thu, 10 Aug 2023 19:14:06 +0000 Received: by outflank-mailman (input) for mailman id 582175; Thu, 10 Aug 2023 19:14:04 +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 1qUB6i-0003Ze-Rx for xen-devel@lists.xenproject.org; Thu, 10 Aug 2023 19:14:04 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [2a01:111:f400:7eae::601]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 10c000ca-37b2-11ee-8613-37d641c3527e; Thu, 10 Aug 2023 21:14:03 +0200 (CEST) Received: from CY5PR14CA0014.namprd14.prod.outlook.com (2603:10b6:930:2::27) by SJ0PR12MB6829.namprd12.prod.outlook.com (2603:10b6:a03:47b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 19:13:59 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:930:2:cafe::72) by CY5PR14CA0014.outlook.office365.com (2603:10b6:930:2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 19:13:59 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Thu, 10 Aug 2023 19:13:58 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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.27; Thu, 10 Aug 2023 14:13:58 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 10 Aug 2023 14:13:57 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 10 Aug 2023 14:13:57 -0500 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: 10c000ca-37b2-11ee-8613-37d641c3527e ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Frt7eqpDRVjpO63Xw4tuM2/DRqg33XW+xaMuVkGL4wIGH0FwxTqK2DpEA8ezB+PABXWn6LxcrO9WGOxUXIOgEVt7Vo5MkdS8lSM+XLtrBKCOWAGIo3iyN5eM0NrV3LmG/TYYceXrK+qCXOXPfggcozy5uWWnB8uM+m8dO5+XiPCyWyfCgNjl3upVBOuk9kKkTn0/wA/VmmnkouMfu4aF2c3H0n8gAsBage2pHJmQRBqMDfxmpeF/WEkufuZ/QDlnO+Azu0s6l23QRa2o+YM8+2B8gxvOyQzjb1HcPDGf1ogY8THYfgl3/3+tWkrF/xlIXzQdDtDDBh1LSYCAQHEcAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=PlSGpBPqcY633oL1I0uwX+30drJWk9gY6gx+J9uhOBw=; b=j0m5y0FLl5ctbfLv1bfq8Wz/6DONkZNTmlQe1QdIoSPvv+0Mg0lfAjayXo6XZc0JVGGwUSXRnw9qKVekI2I0/cuViQgx4YnAOhSAG2/uIxs+kDZvtTIxOUgKF68aR+c/BZ4uJKWx3vN/CYAQ2837ox+36eg4Y3ism95RK7ahJsIeQ3M2vkag8NMlJi93q1YUKfKuNZTrBPb4MA/raadasyEbu/vlYhByOuig58+Q3VS2Pr1mXQnmc9Ws2GZbUt1q2ZsQbr3Qao1NT7ubkfkhaYdoiHUkSryFlLe/STO7pXJjyy/+Td8e4l2nf8G4m17STlgFUczBIy0GBOZX8Rq+Iw== 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 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=PlSGpBPqcY633oL1I0uwX+30drJWk9gY6gx+J9uhOBw=; b=IWW7Yh/Qe+/0zo5VxuQER+eBriR0XXoqvVgS39BwI3uqmAPP/AIDYR0p376mK8zCPSzcrpMPRq+Vx9nEeuX91CWsQCYJSWZbAyMANCQujgoeQkxxz5chnvjRsiIN61M+mnxyl6CP0p+SwmWOGBIIMMGKysqTOEOLBUJW/wsYEpg= 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 (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_Pau_Mon?= =?utf-8?q?n=C3=A9?= Subject: [PATCH v1 2/3] xen/vpci: add vpci_read_val helper Date: Thu, 10 Aug 2023 15:12:58 -0400 Message-ID: <20230810191312.644235-3-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810191312.644235-1-stewart.hildebrand@amd.com> References: <20230810191312.644235-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|SJ0PR12MB6829:EE_ X-MS-Office365-Filtering-Correlation-Id: e91fbfb2-1328-4f37-134a-08db99d5f323 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UX7+T/dui+uch7n0WnTb5dxfauOWobY1HESlu+E6usctLE2fSkOqh2t1YbSyUkhfx9EdITwo2OwsbqJ11a1i8RJMAkTIv15ywTEwtICxioCKY1/6aDm2T79MSi6SvzfjDu1ATlMF0XTzkj4T3h2kI4z3MukUX2Mft0UrK7MjVlY+iOKl47UJ7DK0lcQotU/38nZR2Cr+d60IgIaXE8thxtQf/IHua3nk95qzTHOdeG3jowR+3azzH5XAzpxboBC3WcqBqYXO2XKLJ8lpUKnphzefHsgC4zdzfcb30buY1MK41VOeRhEPDODw1psPIWRs7LAwwcuoO6jZjvjnlI6ekCIZ6v6YE/ZjFYtDWqaq0BIQujrq1jteFkcGbNZdDVfUeuOb0NAb3rfHJUrfAGEzNdzCN2X3oZGwaYUbVqso9ZbEcgokSlesZTFDIh0F9/OfzGb0mRWbw0JESsIVcG6IOnhHAvRk2TYyWZI6yfcT5lHsTV/OzZO106VW7L0AqSSDFARbR9zE1MtcCyrNUa993kgsfE9cuJ4AtaDC/MUF8f/Ra9Ae6vIagE4taISxkTsBrlENE2oEOB9EdylQt/U6tKBhFLuIi8UUDy/kMWGNfzQQ4n/fL/ANlxlqFbRt0Tm/KkVlPUVJGgTmaPUhIf1X5n0/c8AcLpu2i2TrtqKe/I2p+KOeO9D3llc5jpFFJKBkLwJxFAzIFFGJJ8H/4UEBbSFqurYj5mU8hNiif3Au70Txrqcr2oUNY7Vd3iujWecsyUBvd8gWOpu8UGfW5EFSpA== 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:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(186006)(82310400008)(1800799006)(451199021)(36840700001)(46966006)(40470700004)(478600001)(70206006)(70586007)(4326008)(6916009)(5660300002)(316002)(54906003)(41300700001)(40460700003)(8936002)(8676002)(26005)(1076003)(86362001)(82740400003)(336012)(40480700001)(44832011)(36756003)(47076005)(36860700001)(81166007)(356005)(2906002)(2616005)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 19:13:58.8209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e91fbfb2-1328-4f37-134a-08db99d5f323 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6829 Introduce a vPCI read helper function that returns a fixed value. This may be used for RAZ registers, or registers whose value doesn't change. This helper will be used in a subsequent patch. Signed-off-by: Stewart Hildebrand --- RFC: I'm not a fan of the (uintptr_t) cast, but without it I wasn't sure how to pass a value without allocating more memory (either with an xalloc function of sorts, or by adding a new element in struct vpci_register and changing the interface). Plus, in the current state, to pass a value to vpci_add_register(), it may be necessary to cast twice: (void *)(uintptr_t)myval. See next patch. Perhaps a new allocation is worth it to avoid the casts? Or maybe I'm being overly pedantic and the casts are okay? --- xen/drivers/vpci/vpci.c | 6 ++++++ xen/include/xen/vpci.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c index acadba1fd6c5..4a96aa50494d 100644 --- a/xen/drivers/vpci/vpci.c +++ b/xen/drivers/vpci/vpci.c @@ -133,6 +133,12 @@ static void cf_check vpci_ignored_write( { } +uint32_t cf_check vpci_read_val( + const struct pci_dev *pdev, unsigned int reg, void *data) +{ + return (uintptr_t)data; +} + uint32_t cf_check vpci_hw_read8( const struct pci_dev *pdev, unsigned int reg, void *data) { diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h index ee7a8fcdee83..17fd252746ec 100644 --- a/xen/include/xen/vpci.h +++ b/xen/include/xen/vpci.h @@ -45,6 +45,9 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size); void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size, uint32_t data); +uint32_t cf_check vpci_read_val( + const struct pci_dev *pdev, unsigned int reg, void *data); + /* Passthrough handlers. */ uint32_t cf_check vpci_hw_read8( const struct pci_dev *pdev, unsigned int reg, void *data); From patchwork Thu Aug 10 19:12:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13349841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0112CC001B0 for ; Thu, 10 Aug 2023 19:14:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.582180.911813 (Exim 4.92) (envelope-from ) id 1qUB6y-0004v4-JA; Thu, 10 Aug 2023 19:14:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 582180.911813; Thu, 10 Aug 2023 19:14:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qUB6y-0004ux-G7; Thu, 10 Aug 2023 19:14:20 +0000 Received: by outflank-mailman (input) for mailman id 582180; Thu, 10 Aug 2023 19:14:19 +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 1qUB6x-0004qN-5X for xen-devel@lists.xenproject.org; Thu, 10 Aug 2023 19:14:19 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20606.outbound.protection.outlook.com [2a01:111:f400:fe5b::606]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1987dcad-37b2-11ee-b284-6b7b168915f2; Thu, 10 Aug 2023 21:14:17 +0200 (CEST) Received: from CH0PR03CA0209.namprd03.prod.outlook.com (2603:10b6:610:e4::34) by CH3PR12MB9021.namprd12.prod.outlook.com (2603:10b6:610:173::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 19:14:10 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:610:e4:cafe::79) by CH0PR03CA0209.outlook.office365.com (2603:10b6:610:e4::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30 via Frontend Transport; Thu, 10 Aug 2023 19:14:10 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Thu, 10 Aug 2023 19:14:09 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 10 Aug 2023 14:14:09 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 10 Aug 2023 14:14:08 -0500 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: 1987dcad-37b2-11ee-b284-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EuvnqIb/Lo+1HHUQsz+GLNW7b3fYKuThTtzLoi6MSmleFvcriK5cc769dD2rY+Q563RvdXO6tjpeU1A7pdwWnzCiSNtGxJnSqGO0I5lMJpA3JV/0lNYxIVQ2yFZ147s8wb/t4rhFs9SdoaYG64+ddPoUZeTb71IuAZtLzpTtkroWGXi31ygJkB3YqP3YJaIpF2XJ/G8YqrDk2yZdrtsrIJlq0S3piPu+mO6NxyDf/J70tAu5lrxxVM8nQy8jkZ5TUbMxMjE/NlLlcaygtTZSkxCnocoQ+tCgS2Nx5fFCLF5hneINw49KPReBus1k4UL0b9avK2GX86+CcST2b0TCHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lytXEfn42x+yZhPe84LRwE9cDWxa0qd6RBGQUU59Ly0=; b=g4dRTSGvgsMDqTRw0FGBQGlxzce8Gje880i5DUj/oLLOH64+LurECP3u6ebezPzuKcHur5jeRYV7+HF7qrtqa6fB4dyzO2Iiz+W2U8l5C14iQN1bBP57rqrWBbqTWShoGtuUJ40eCWT02xUFrIiTQZKcxSREDuuR7FzqhjGaa/P0yMwvX5xA0rwJcJGGSTG8PRYB4cIl82d3YmVC3/PvbK0Tr5mKludxyTjUVxpT+HTuF5nb7QfmXzghxqq9/NTCGvPD2dejm22AHynmPPeUVdKHG1A7q+8nYLIg9cnHpJvgwKUGRHooTH4jJsd0mH05/3N5LZqOUGelgWCHcF7aVw== 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 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=lytXEfn42x+yZhPe84LRwE9cDWxa0qd6RBGQUU59Ly0=; b=zCkQI4fKYKW9VVsFhh/GW4nMeSgOjMrP28lZArTepRyxoYYT4vE0rWunevw8vwlLesMuLdY7PmdADbNAUd6viT9PAwyMk3fbDTjDX1vo05wTaIWOYZvzkqNFhzCXynwKScvuvvWXAys3Y08zxbP8cbTfU8o1/Oco2l9XuaRkueM= 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 (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=SATLEXMB03.amd.com; pr=C From: Stewart Hildebrand To: CC: Stewart Hildebrand , =?utf-8?q?Roger_Pau_Mon?= =?utf-8?q?n=C3=A9?= Subject: [PATCH v1 3/3] xen/vpci: header: filter PCI capabilities Date: Thu, 10 Aug 2023 15:12:59 -0400 Message-ID: <20230810191312.644235-4-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810191312.644235-1-stewart.hildebrand@amd.com> References: <20230810191312.644235-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AB:EE_|CH3PR12MB9021:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e943005-87f0-423d-d03a-08db99d5f9cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EwROm0Lbzsr56+VaUvR7rQPESxbMiOqRULxVl7GoRBE2pD61dGhhYSAeUNKWjN7WH7qDndzcU0Sm/RakmAYVW4ox3rndqLs39STuYsxwT4BpIAkaHPqNaVY8wjEgS7RK/vWzEBBuETb/HZAVMayeE/M0VsnC/GX7+j/xXf0m6BxkGHWb+iLgOzdBDx2uFSzBevvA6PbMuBDteOkrzecANCs4z7eOdWgvtjSfPcHFds9yRK59oRjga8EowIwlWU/Gz+HU/IEtwAitjuWLXaTuh4t1vsrZndSQeYRRKXmqSE9LmHOgMQkZ8on/b6xLX5kHEiIvgIAdRm0ic6FCvDHlOz2005D0Lyx/exP0qnlSQI7LhBUPYlkAwuWpLAvmSK/C/TjbqlsXgYpLK0/JgO6/oA18C3rbzJtkZfE+NG9n1bcnP8jwnWUODJfvqwplaCd2cBXaJHFBvAppW/9XsU2Y/ACD4q8r5pyRlaOcAOSWGxvfuiih/141XXsTvUemFM/ZLpaFpcOHM+yoXWLPKF89wJ5INJtyfJ5IVhYPplMdvPrkiUAa+YERi/wces660K4GYNy9VB5Pd0aL6KR6GBtt0biqiTQLtm6HFQ1ZlQnRJzpwMBireaV+SZbj6DObeDguBSG9RZisHy2iMbbgmzUW9PyLdS+qf/FqFsIfvee+TSqh3j2l34gmDTM17Gy16jYpClLsxHfswcvmxShyvX1ud0H2Kf+dxv/zR5e0lLZvCmOesSbb7X3XvJSVv1AFluHpovcmwfajrMMTX/33XJQXow== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(1800799006)(451199021)(82310400008)(186006)(36840700001)(40470700004)(46966006)(8676002)(8936002)(1076003)(26005)(41300700001)(40460700003)(36860700001)(36756003)(47076005)(426003)(2906002)(356005)(2616005)(81166007)(86362001)(82740400003)(44832011)(336012)(6916009)(70206006)(70586007)(4326008)(54906003)(478600001)(5660300002)(40480700001)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2023 19:14:09.9684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e943005-87f0-423d-d03a-08db99d5f9cc 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9021 Xen vPCI only supports virtualizing the MSI and MSI-X capabilities, so all other PCI capabilities should be hidden from a domU for now. We parse the physical PCI capabilities linked list and add vPCI register handlers for the next elements, inserting our own next value, thus presenting a modified linked list to the domU. Signed-off-by: Stewart Hildebrand --- If there are no capabilities to be exposed to the guest, a future status register handler likely would want to mask the PCI_STATUS_CAP_LIST bit. I'm thinking we could track this in struct vpci_header as follows: vpci.h: struct vpci_header { ... + bool mask_cap_list : 1; } header; header.c:init_bars(): rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL, PCI_CAPABILITY_LIST, 1, (void *)(uintptr_t)next); if ( rc ) return rc; + if ( !next ) + header->mask_cap_list = true; + for ( ttl = 48; ttl > 0; ttl-- ) { uint8_t pos; --- xen/drivers/vpci/header.c | 78 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c index 60f7049e3498..cb1304fa1eed 100644 --- a/xen/drivers/vpci/header.c +++ b/xen/drivers/vpci/header.c @@ -513,6 +513,36 @@ static void cf_check rom_write( rom->addr = val & PCI_ROM_ADDRESS_MASK; } +static uint8_t vpci_find_next_cap(pci_sbdf_t sbdf, uint8_t pos) +{ + uint8_t id; + int ttl; + + if ( pos < 0x40 ) + pos = pci_conf_read8(sbdf, PCI_CAPABILITY_LIST); + else + pos = pci_conf_read8(sbdf, pos + PCI_CAP_LIST_NEXT); + + for ( ttl = 48; ttl > 0; ttl-- ) + { + if ( pos < 0x40 ) + break; + + pos &= ~3; + id = pci_conf_read8(sbdf, pos + PCI_CAP_LIST_ID); + + if ( id == 0xff ) + break; + + if ( id == PCI_CAP_ID_MSI || + id == PCI_CAP_ID_MSIX ) + return pos; + + pos = pci_conf_read8(sbdf, pos + PCI_CAP_LIST_NEXT); + } + return 0; +} + static int cf_check init_bars(struct pci_dev *pdev) { uint16_t cmd; @@ -544,6 +574,54 @@ static int cf_check init_bars(struct pci_dev *pdev) if ( rc ) return rc; + if ( !is_hardware_domain(pdev->domain) ) + { + if ( (pci_conf_read16(pdev->sbdf, PCI_STATUS) & PCI_STATUS_CAP_LIST) + == 0 ) + { + /* RAZ/WI */ + rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL, + PCI_CAPABILITY_LIST, 1, NULL); + if ( rc ) + return rc; + } + else + { + /* Only expose capabilities to the guest that vPCI can handle. */ + uint8_t next, ttl; + + next = vpci_find_next_cap(pdev->sbdf, PCI_CAPABILITY_LIST); + + rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL, + PCI_CAPABILITY_LIST, 1, + (void *)(uintptr_t)next); + if ( rc ) + return rc; + + for ( ttl = 48; ttl > 0; ttl-- ) + { + uint8_t pos; + + if ( !next ) + break; + + pos = next; + next = vpci_find_next_cap(pdev->sbdf, pos); + + rc = vpci_add_register(pdev->vpci, vpci_hw_read8, NULL, + pos + PCI_CAP_LIST_ID, 1, NULL); + if ( rc ) + return rc; + + rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL, + pos + PCI_CAP_LIST_NEXT, 1, + (void *)(uintptr_t)next); + if ( rc ) + return rc; + } + } + } + if ( pdev->ignore_bars ) return 0;