From patchwork Mon Oct 30 23:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13440935 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 A281BC4167D for ; Mon, 30 Oct 2023 23:53:33 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.625423.974678 (Exim 4.92) (envelope-from ) id 1qxc4M-0000Qh-Aq; Mon, 30 Oct 2023 23:53:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 625423.974678; Mon, 30 Oct 2023 23:53:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qxc4M-0000QX-8I; Mon, 30 Oct 2023 23:53:18 +0000 Received: by outflank-mailman (input) for mailman id 625423; Mon, 30 Oct 2023 23:53:16 +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 1qxc4K-00009Y-J9 for xen-devel@lists.xenproject.org; Mon, 30 Oct 2023 23:53:16 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20602.outbound.protection.outlook.com [2a01:111:f400:7eaa::602]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7d065591-777f-11ee-9b0e-b553b5be7939; Tue, 31 Oct 2023 00:53:14 +0100 (CET) Received: from BL1PR13CA0401.namprd13.prod.outlook.com (2603:10b6:208:2c2::16) by DM6PR12MB4483.namprd12.prod.outlook.com (2603:10b6:5:2a2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28; Mon, 30 Oct 2023 23:53:11 +0000 Received: from BL6PEPF0001AB74.namprd02.prod.outlook.com (2603:10b6:208:2c2:cafe::a9) by BL1PR13CA0401.outlook.office365.com (2603:10b6:208:2c2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.15 via Frontend Transport; Mon, 30 Oct 2023 23:53:10 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB74.mail.protection.outlook.com (10.167.242.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Mon, 30 Oct 2023 23:53:10 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.32; Mon, 30 Oct 2023 18:53:10 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Mon, 30 Oct 2023 18:53:09 -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.32 via Frontend Transport; Mon, 30 Oct 2023 18:53: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: 7d065591-777f-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=imHzs3GwAC+6ZjMUHbnb9YtsaRrtOaDVo8eICOfstejg1hldY8MNNgJDdM5atYTz3cuv94+KdgAPw3kF5GKhZsfk7/hMVg2fGkOOv2cLiMWK8FrQmAOhLZ8fqcaQTRACksSsTO7q5rcrOdIa6taO64eLWW0WIu0mIXwMrLLGfGOuY58OuC4VGvDlumFvEvuoT5OXmk685BVYRe1Jw/5QU2bI1/6GbzTt6fJ4PZzOrLeK9UHGKA8r5zK+8WIRU1bVjahvRX8sW5f+xrwGuNq8vEyxwEQXGRgTUra78cpBaF8qfu0Brj9Ovb6s2p9/l/ZSkCq4BGPNBKdehLqg7k2NtQ== 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=6vJBkkc7Wu6DjPvhvL3fqXdEasGwxXnYZMqwvjI9HKg=; b=EZSptB4ftEeXaVOUuvIlif8+C1KVV+FjR97dN3EViCeY7DLmVPxbTZDRh5V7pYCvcptMYIAC8dNlcjsDnxy5gpFE9fNN9dqgmE4EvgeHI0DWmCUdSJoITbdw5mU/XcvFMuDVWfhdnz0wKK46nLDTTYLpxqk61L41MrirQk3c0yGNdIhi/xrBxlrSX+cyWXLy8kYDPsiNdcpEqBIctgYBDWwQ8RZ3Cmo91BYL6H/mL93AfoomUBqYVzpwNIbVsZdzrnnXIGxk4jNeFxFjYgtxWjSev6225YCVoHnI4yT0AjNFTx6EhEKzkK6B9zkXVqSbrnr4PVaxBRtN5fisjForiQ== 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=6vJBkkc7Wu6DjPvhvL3fqXdEasGwxXnYZMqwvjI9HKg=; b=wsLPPBJjzMYhYqHrweR0kOMumGB9hVaOyx1xrs+lrTWHnChRtCcmVm4RHo95UFTsbMb7Kn/QOSgo8Ck+kO6KZrJbgy2L8DaDn1hM9IzBSL4o/N7D402VSS3gnkWzFekVpsId47AT4939Zaa3rYR53gpV63bec/ylBU1DJ/+RkHs= 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: Rahul Singh , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Stefano Stabellini , Stewart Hildebrand , Julien Grall Subject: [PATCH v4 1/5] xen/arm: pci: introduce PCI_PASSTHROUGH Kconfig option Date: Mon, 30 Oct 2023 19:52:32 -0400 Message-ID: <20231030235240.106998-2-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030235240.106998-1-stewart.hildebrand@amd.com> References: <20231030235240.106998-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB74:EE_|DM6PR12MB4483:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f1b210c-ea2b-48c3-3b0b-08dbd9a35f41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5sog9IrAxzKul9ACe9euLhJMrMc+fdnjOJzAroWmZT/xrVokzEerYjDLZ8hrOWT3VCjq8+pRYXtjWfo8QoaYR3SxrEfn+KCEfw98XQS9T/QJWBHAt1/kvumwFmpFTtlHupIt8ZmCEd3PHNSqARj3rWIXdmWQZJtyMbCUPrZTnpGdhZS+qvWrbmNn6hhnWoqCaeJt97mEwr4I4DeWayjbfaa9lf08WhtIXTymM26Ja0UelQZpispveiJ5Qf+HDKLXDRLqJEqtW8jqMjXui2RPaLlopfUegj4X/FbesYbwKkzvfc/cJrK3dDxox5ZdTCyfNH+jXBS/gQpA45z2gr5498KJnRPMArRsvnGF+b1VhERHdni8vZURM4uB90sneT18g+hyllw4jSVrYt2cyceWTclvVJa8Gk1rnfOfiJjaMJ1/9UciygDGIkbLvR94cQCV0AoRg42HHrJA0GZsnCvbXGQn8CObmJjCHNsgMmVWht4NUIDMdaxX1X+MOfQRY5YldiS653xfd1EXQ8bZxXyB0PtwVxMuq35qUeysBrKbtPPOi9D4uiRMejmmxap7B5UADpm2FMnMjMPjdaRzB/Q8rJ9bD1wHTjBIIQmr1vxKhqGncgKa3WjOrN6kwVCSGbsVIA7A7mc0TTkhGhEz8PfJ8D2xTwkeO86FvU+3RQ2pQ9QeOPqvibTAP+fjVeFRAsaSl8fb+2JRB22Ys9XojSWKk9xaYN+nvOfiLTueJRiIW2cFNGbpMJWvwrK434baaph9vjrXVu7+W8iPwTec9jEPGQ== 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:(13230031)(4636009)(136003)(376002)(39860400002)(396003)(346002)(230922051799003)(82310400011)(186009)(1800799009)(451199024)(64100799003)(40470700004)(46966006)(36840700001)(40460700003)(2906002)(5660300002)(44832011)(41300700001)(4326008)(8676002)(8936002)(86362001)(40480700001)(36756003)(82740400003)(316002)(6666004)(54906003)(36860700001)(47076005)(356005)(81166007)(70586007)(70206006)(426003)(26005)(1076003)(2616005)(336012)(478600001)(966005)(6916009)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 23:53:10.3751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f1b210c-ea2b-48c3-3b0b-08dbd9a35f41 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: BL6PEPF0001AB74.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4483 From: Rahul Singh Setting CONFIG_PCI_PASSTHROUGH=y will enable PCI passthrough on ARM, even though the feature is not yet complete in the current upstream codebase. The purpose of this is to make it easier to enable the necessary configs (HAS_PCI, HAS_VPCI) for testing and development of PCI passthrough on ARM. Since PCI passthrough on ARM is still work in progress at this time, make it depend on EXPERT. Signed-off-by: Rahul Singh Signed-off-by: Stefano Stabellini Signed-off-by: Stewart Hildebrand Acked-by: Julien Grall --- (cherry picked from commit 9a08f1f7ce28ec619640ba9ce11018bf443e9a0e from the downstream branch [1]) v3->v4: * no change v2->v3: * add Julien's A-b v1->v2: * drop "ARM" naming since it is already in an ARM category * depend on EXPERT instead of UNSUPPORTED Changes from downstream to v1: * depends on ARM_64 (Stefano) * Don't select HAS_VPCI_GUEST_SUPPORT since this config option is not currently used in the upstream codebase. This will want to be re-added here once the vpci series [2] is merged. * Don't select ARM_SMMU_V3 since this option can already be selected independently. While PCI passthrough on ARM depends on an SMMU, it does not depend on a particular version or variant of an SMMU. * Don't select HAS_ITS since this option can already be selected independently. HAS_ITS may want to be added here once the MSI series [1] is merged. * Don't select LATE_HWDOM since this option is unrelated to PCI passthrough. [1] https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc/-/commits/poc/pci-passthrough [2] https://lists.xenproject.org/archives/html/xen-devel/2023-08/msg02361.html --- xen/arch/arm/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 2939db429b78..5ff68e5d5979 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -190,6 +190,15 @@ config STATIC_SHM help This option enables statically shared memory on a dom0less system. +config PCI_PASSTHROUGH + bool "PCI passthrough" if EXPERT + depends on ARM_64 + select HAS_PCI + select HAS_VPCI + default n + help + This option enables PCI device passthrough + endmenu menu "ARM errata workaround via the alternative framework" From patchwork Mon Oct 30 23:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13440936 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 6DBC4C4332F for ; Mon, 30 Oct 2023 23:53:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.625424.974688 (Exim 4.92) (envelope-from ) id 1qxc4c-0000x3-Pn; Mon, 30 Oct 2023 23:53:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 625424.974688; Mon, 30 Oct 2023 23:53:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qxc4c-0000ww-Ma; Mon, 30 Oct 2023 23:53:34 +0000 Received: by outflank-mailman (input) for mailman id 625424; Mon, 30 Oct 2023 23:53:33 +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 1qxc4b-00009Y-GR for xen-devel@lists.xenproject.org; Mon, 30 Oct 2023 23:53:33 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20625.outbound.protection.outlook.com [2a01:111:f400:7eaa::625]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 86f32cfb-777f-11ee-9b0e-b553b5be7939; Tue, 31 Oct 2023 00:53:31 +0100 (CET) Received: from MW4PR04CA0232.namprd04.prod.outlook.com (2603:10b6:303:87::27) by SA1PR12MB8598.namprd12.prod.outlook.com (2603:10b6:806:253::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Mon, 30 Oct 2023 23:53:27 +0000 Received: from CO1PEPF000042A7.namprd03.prod.outlook.com (2603:10b6:303:87:cafe::61) by MW4PR04CA0232.outlook.office365.com (2603:10b6:303:87::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28 via Frontend Transport; Mon, 30 Oct 2023 23:53:26 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042A7.mail.protection.outlook.com (10.167.243.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Mon, 30 Oct 2023 23:53:25 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.32; Mon, 30 Oct 2023 18:53:24 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Mon, 30 Oct 2023 18:53:24 -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.32 via Frontend Transport; Mon, 30 Oct 2023 18:53:22 -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: 86f32cfb-777f-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Syl6E7adKLrCkaXTpZwiWcqo7Hvzwujth3y3qPj07F6f9+pHDK7frIGV/EFv+u5RbTb+4XmpUtTcDu1Dco5cpPRphsoKNXMvrnTUSCitBg1xtELZtoOuWpCXcuGYkMdZDE/Cxw+7QzeIP/tNYOIsww1wiMXSpr3QmVk89LrSgoRwnLkU1TJrfcMVcaEaJjCIfFAM8ndla6TbbpoxXRZ72ysxOdM/JK5LBhPn3+HZTORqwrqpSZaBqO0TbvG4Icz0nWjcZXkQWadFQXAaGjswnI1wvFJVQ6fPle5wsXXGN3DxUfRE3+ZzF7G6Q8J24S8ZDf6S1iA+h0sASDrLgeTsMg== 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=paYgyYFEvCqtRNrRgLjdy+iDeJ6pBAXS6AUnevvjTBg=; b=RdV0SJHio93Nw/QhGQtWeF9jV3OXg3SuuDkc41C/ZOZgJQietHMjKdxqDwgHy5SU18nTGDYORV499T24yQhm4XSqEXlNUmnC8YEIJ/FHMotHjkHTmxdtmpWxdd5DHsZTReLXeHbO3RYNTvsDrn14Ie6cOT3eU7tP4gUiFUlHVoJkvAGC9Nh0YcxV3GWVr1KU+7T5SgLgLbo1DicBOpBO1KySIQwZiV+U6ovnCXBcnQWmZSmiDjNWTyQ3EZVd9v8Z2C8oFdF8sPcLhIU0zzCQaEqK4s+POUnXgPrg4uBzPBPDrh5AAGJDUACfsQufD5/OEj8PtOLwADA3nPPyeAOnpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=temperror 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=paYgyYFEvCqtRNrRgLjdy+iDeJ6pBAXS6AUnevvjTBg=; b=0rfVWQWX5KpJZK9hqQC8c2wrX4KZ70E4U/mNDrLYus2ykdZj5rXpmCZbP5dFHnAmN4PISS+KDxRkjypoQP7G8WOeMIYjfFJvh9iTfyZMEx5uhgOezRfINxDLZLkbz5k4ISwpxE2x3QNTJahJEHv1PkN1tPh+Ecn1KwaJJ88uy8Q= X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) From: Stewart Hildebrand To: CC: Stewart Hildebrand , Wei Liu , Anthony PERARD , Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , "Christian Lindig" , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= , Bertrand Marquis , Volodymyr Babchuk , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , "Oleksandr Andrushchenko" , Rahul Singh Subject: [PATCH v4 2/5] xen/vpci: move xen_domctl_createdomain vPCI flag to common Date: Mon, 30 Oct 2023 19:52:33 -0400 Message-ID: <20231030235240.106998-3-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030235240.106998-1-stewart.hildebrand@amd.com> References: <20231030235240.106998-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A7:EE_|SA1PR12MB8598:EE_ X-MS-Office365-Filtering-Correlation-Id: c21365b0-9592-446f-7593-08dbd9a36825 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cwdLkffRS536UIlrt7RHdgjqgvSZJMJ92QSXpEC9oBaJtN7ibmchGYqiHRGPA/Y+e70w3u20S/KaSJSBxvo+kNgXc05IOhgEx4Bctr6hKDzLnzASV/hlagnGY2ynepHXg0jRAzuCcgSTGQQ5WskDvOyb57dUIFSt2M9dqjJ0v6N0nu/99VOuQl+7FY6NCGWhf5mBoi8JNr3O8KyI0oxHZ3ZGbnOO6euYp2lDAY9B8ZQ52t/6LqBOXQ43jrFkHDyXNBJXc89bQdIak7brCbszM6VEp23K3PmXoSFoCzkSrFAQVd2/BLJOGHnMvPoLWKRRCAGc367GoPpuJLiU8nCF8O+VAt4HbliBmNrnVMwWPp/4yyAU+l7t9LPE/UhiePxcXZk2GUR5gIZTxSTKoYmmFZqflSdrcajJV3NQdoVtc9BZCwWXQCp9aXzS7WHIwAKqugD9902QSacuIhKIOBG97rknw4tu4/dG0g9+NsYXod6NQKSGmcanffASiQcAyMipylPIOBVZyJXZpaIxqQCVlC707TMWhVM4gLw15adHw9ddSkTSgZQcjlETot/dsZg2qchMdWs0MtTpkrPDwI3la0bu7t6LBE9M+Nql+b0EilDUn0v6HTdYdcQqqeCcAxM/3HPnu4S46QZ7za8qn4BhpP7M4YUGibH2t2OCdedpX91RJU3gkIFmHMPemtgHA7wTcGFkGHHIOc5KaHdhhSLVl+vKXJ1k9EIOl+Z+iEnD2Q6wuM964ce56gSDVm/YCVinYknsNQKiQhIHD8UhP7I4K2s634rAxroLkwMY0YwsaNY= 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:(13230031)(4636009)(376002)(396003)(346002)(39860400002)(136003)(230922051799003)(64100799003)(82310400011)(186009)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(26005)(1076003)(2616005)(40480700001)(7416002)(40460700003)(86362001)(82740400003)(81166007)(356005)(36756003)(426003)(336012)(2906002)(30864003)(83380400001)(63370400001)(63350400001)(478600001)(36860700001)(47076005)(6666004)(4326008)(8676002)(8936002)(6916009)(54906003)(316002)(966005)(5660300002)(44832011)(70586007)(70206006)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 23:53:25.1832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c21365b0-9592-446f-7593-08dbd9a36825 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: CO1PEPF000042A7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8598 Both x86 and ARM need a way at domain creation time to specify whether the domain needs vPCI emulation. Move the vPCI flag from x86 xen_domctl_createdomain.arch.emulation_flags to the common xen_domctl_createdomain.flags. Move has_vpci() macro to common header. Bump XEN_DOMCTL_INTERFACE_VERSION since we're modifying flags inside struct xen_domctl_createdomain and xen_arch_domainconfig. Signed-off-by: Oleksandr Andrushchenko Signed-off-by: Rahul Singh Signed-off-by: Stewart Hildebrand --- v3->v4: * renamed, was: ("xen/arm: pci: plumb xen_arch_domainconfig with pci info") * reworked: move x86 vPCI flag to common instead of adding another arch specific vPCI flag * folded ("xen/arm: make has_vpci() depend on d->arch.has_vpci") into this patch (retain Signed-off-by's from [1] and [2]) v2->v3: * new patch [1] https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc/-/commit/27be1729ce8128dbe37275ce7946b2fbd2e5a382 [2] https://github.com/xen-troops/xen/commit/bf12185e6fb2e31db0d8e6ea9ccd8a02abadec17 --- tools/libs/light/libxl_x86.c | 5 ++++- tools/ocaml/libs/xc/xenctrl.ml | 2 +- tools/ocaml/libs/xc/xenctrl.mli | 2 +- tools/python/xen/lowlevel/xc/xc.c | 5 ++++- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/include/asm/domain.h | 3 --- xen/arch/x86/domain.c | 16 ++++++++++------ xen/arch/x86/include/asm/domain.h | 6 +----- xen/arch/x86/setup.c | 5 +++-- xen/common/domain.c | 10 +++++++++- xen/include/public/arch-x86/xen.h | 5 +---- xen/include/public/domctl.h | 7 +++++-- xen/include/xen/domain.h | 2 ++ 13 files changed, 43 insertions(+), 28 deletions(-) diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index d16573e72cd4..ebce1552accd 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -8,13 +8,16 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { switch(d_config->c_info.type) { case LIBXL_DOMAIN_TYPE_HVM: - config->arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI); + config->arch.emulation_flags = XEN_X86_EMU_ALL; + config->flags &= ~XEN_DOMCTL_CDF_vpci; break; case LIBXL_DOMAIN_TYPE_PVH: config->arch.emulation_flags = XEN_X86_EMU_LAPIC; + config->flags &= ~XEN_DOMCTL_CDF_vpci; break; case LIBXL_DOMAIN_TYPE_PV: config->arch.emulation_flags = 0; + config->flags &= ~XEN_DOMCTL_CDF_vpci; break; default: abort(); diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index d6c6eb73db44..6f3da9c6e064 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -46,7 +46,6 @@ type x86_arch_emulation_flags = | X86_EMU_IOMMU | X86_EMU_PIT | X86_EMU_USE_PIRQ - | X86_EMU_VPCI type x86_arch_misc_flags = | X86_MSR_RELAXED @@ -70,6 +69,7 @@ type domain_create_flag = | CDF_IOMMU | CDF_NESTED_VIRT | CDF_VPMU + | CDF_VPCI type domain_create_iommu_opts = | IOMMU_NO_SHAREPT diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index 3bfc16edba96..e2dd02bec962 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -40,7 +40,6 @@ type x86_arch_emulation_flags = | X86_EMU_IOMMU | X86_EMU_PIT | X86_EMU_USE_PIRQ - | X86_EMU_VPCI type x86_arch_misc_flags = | X86_MSR_RELAXED @@ -63,6 +62,7 @@ type domain_create_flag = | CDF_IOMMU | CDF_NESTED_VIRT | CDF_VPMU + | CDF_VPCI type domain_create_iommu_opts = | IOMMU_NO_SHAREPT diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index d3ea350e07b9..e3623cdcb90d 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -159,7 +159,10 @@ static PyObject *pyxc_domain_create(XcObject *self, #if defined (__i386) || defined(__x86_64__) if ( config.flags & XEN_DOMCTL_CDF_hvm ) - config.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI); + { + config.arch.emulation_flags = XEN_X86_EMU_ALL; + config.flags &= ~XEN_DOMCTL_CDF_vpci; + } #elif defined (__arm__) || defined(__aarch64__) config.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE; #else diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 28e3aaa5e482..1409a4235e13 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -607,7 +607,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) { unsigned int max_vcpus; unsigned int flags_required = (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap); - unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu); + unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpmu | + XEN_DOMCTL_CDF_vpci); unsigned int sve_vl_bits = sve_decode_vl(config->arch.sve_vl); if ( (config->flags & ~flags_optional) != flags_required ) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index 99e798ffff68..be9ed39c9d42 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -298,9 +298,6 @@ static inline void arch_vcpu_block(struct vcpu *v) {} #define arch_vm_assist_valid_mask(d) (1UL << VMASST_TYPE_runstate_update_flag) -/* vPCI is not available on Arm */ -#define has_vpci(d) ({ (void)(d); false; }) - struct arch_vcpu_io { struct instr_details dabt_instr; /* when the instruction is decoded */ }; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 3712e36df930..2882fc1081c1 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -712,7 +712,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return 0; } -static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) +static bool emulation_flags_ok(const struct domain *d, uint32_t emflags, + uint32_t cdf) { #ifdef CONFIG_HVM /* This doesn't catch !CONFIG_HVM case but it is better than nothing */ @@ -722,14 +723,17 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) if ( is_hvm_domain(d) ) { if ( is_hardware_domain(d) && - emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) ) + (!( cdf & XEN_DOMCTL_CDF_vpci ) || + emflags != (X86_EMU_LAPIC | X86_EMU_IOAPIC)) ) return false; if ( !is_hardware_domain(d) && - emflags != (X86_EMU_ALL & ~X86_EMU_VPCI) && - emflags != X86_EMU_LAPIC ) + ((cdf & XEN_DOMCTL_CDF_vpci) || + (emflags != X86_EMU_ALL && + emflags != X86_EMU_LAPIC)) ) return false; } - else if ( emflags != 0 && emflags != X86_EMU_PIT ) + else if ( (cdf & XEN_DOMCTL_CDF_vpci) || + (emflags != 0 && emflags != X86_EMU_PIT) ) { /* PV or classic PVH. */ return false; @@ -798,7 +802,7 @@ int arch_domain_create(struct domain *d, return -EINVAL; } - if ( !emulation_flags_ok(d, emflags) ) + if ( !emulation_flags_ok(d, emflags, config->flags) ) { printk(XENLOG_G_ERR "d%d: Xen does not allow %s domain creation " "with the current selection of emulators: %#x\n", diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index 619e667938ed..cb02a4d1ebb2 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -471,7 +471,6 @@ struct arch_domain #define X86_EMU_VGA XEN_X86_EMU_VGA #define X86_EMU_IOMMU XEN_X86_EMU_IOMMU #define X86_EMU_USE_PIRQ XEN_X86_EMU_USE_PIRQ -#define X86_EMU_VPCI XEN_X86_EMU_VPCI #else #define X86_EMU_LAPIC 0 #define X86_EMU_HPET 0 @@ -482,7 +481,6 @@ struct arch_domain #define X86_EMU_VGA 0 #define X86_EMU_IOMMU 0 #define X86_EMU_USE_PIRQ 0 -#define X86_EMU_VPCI 0 #endif #define X86_EMU_PIT XEN_X86_EMU_PIT @@ -492,8 +490,7 @@ struct arch_domain X86_EMU_PM | X86_EMU_RTC | \ X86_EMU_IOAPIC | X86_EMU_PIC | \ X86_EMU_VGA | X86_EMU_IOMMU | \ - X86_EMU_PIT | X86_EMU_USE_PIRQ | \ - X86_EMU_VPCI) + X86_EMU_PIT | X86_EMU_USE_PIRQ) #define has_vlapic(d) (!!((d)->arch.emulation_flags & X86_EMU_LAPIC)) #define has_vhpet(d) (!!((d)->arch.emulation_flags & X86_EMU_HPET)) @@ -505,7 +502,6 @@ struct arch_domain #define has_viommu(d) (!!((d)->arch.emulation_flags & X86_EMU_IOMMU)) #define has_vpit(d) (!!((d)->arch.emulation_flags & X86_EMU_PIT)) #define has_pirq(d) (!!((d)->arch.emulation_flags & X86_EMU_USE_PIRQ)) -#define has_vpci(d) (!!((d)->arch.emulation_flags & X86_EMU_VPCI)) #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a3d3f797bb1e..58a98acfb1ee 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -892,10 +892,11 @@ static struct domain *__init create_dom0(const module_t *image, { dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | ((hvm_hap_supported() && !opt_dom0_shadow) ? - XEN_DOMCTL_CDF_hap : 0)); + XEN_DOMCTL_CDF_hap : 0) | + XEN_DOMCTL_CDF_vpci); dom0_cfg.arch.emulation_flags |= - XEN_X86_EMU_LAPIC | XEN_X86_EMU_IOAPIC | XEN_X86_EMU_VPCI; + XEN_X86_EMU_LAPIC | XEN_X86_EMU_IOAPIC; } if ( iommu_enabled ) diff --git a/xen/common/domain.c b/xen/common/domain.c index 8f9ab01c0cb7..12dc27428972 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -509,12 +509,14 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) bool hap = config->flags & XEN_DOMCTL_CDF_hap; bool iommu = config->flags & XEN_DOMCTL_CDF_iommu; bool vpmu = config->flags & XEN_DOMCTL_CDF_vpmu; + bool vpci = config->flags & XEN_DOMCTL_CDF_vpci; if ( config->flags & ~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap | XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off | XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu | - XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu) ) + XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpmu | + XEN_DOMCTL_CDF_vpci) ) { dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags); return -EINVAL; @@ -575,6 +577,12 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( vpci && !IS_ENABLED(CONFIG_HAS_VPCI) ) + { + dprintk(XENLOG_INFO, "vPCI requested but not enabled\n"); + return -EINVAL; + } + return arch_sanitise_domain_config(config); } diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index c0f4551247f4..4cf066761c6b 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -283,15 +283,12 @@ struct xen_arch_domainconfig { #define XEN_X86_EMU_PIT (1U<<_XEN_X86_EMU_PIT) #define _XEN_X86_EMU_USE_PIRQ 9 #define XEN_X86_EMU_USE_PIRQ (1U<<_XEN_X86_EMU_USE_PIRQ) -#define _XEN_X86_EMU_VPCI 10 -#define XEN_X86_EMU_VPCI (1U<<_XEN_X86_EMU_VPCI) #define XEN_X86_EMU_ALL (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPET | \ XEN_X86_EMU_PM | XEN_X86_EMU_RTC | \ XEN_X86_EMU_IOAPIC | XEN_X86_EMU_PIC | \ XEN_X86_EMU_VGA | XEN_X86_EMU_IOMMU | \ - XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIRQ |\ - XEN_X86_EMU_VPCI) + XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIRQ) uint32_t emulation_flags; /* diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index a33f9ec32b08..5f3b5579c377 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -21,7 +21,7 @@ #include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000016 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000017 /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -55,9 +55,12 @@ struct xen_domctl_createdomain { #define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt) /* Should we expose the vPMU to the guest? */ #define XEN_DOMCTL_CDF_vpmu (1U << 7) +/* Should vPCI be enabled for the guest? */ +#define _XEN_DOMCTL_CDF_vpci 8 +#define XEN_DOMCTL_CDF_vpci (1U<<_XEN_DOMCTL_CDF_vpci) /* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */ -#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_vpmu +#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_vpci uint32_t flags; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 54d88bf5e34b..17b3429240f3 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -51,6 +51,8 @@ void arch_get_domain_info(const struct domain *d, #define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) +#define has_vpci(d) (!!((d)->options & XEN_DOMCTL_CDF_vpci)) + /* * Arch-specifics. */ From patchwork Mon Oct 30 23:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13440937 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 D5249C4332F for ; Mon, 30 Oct 2023 23:54:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.625428.974699 (Exim 4.92) (envelope-from ) id 1qxc4r-0001Z0-2Z; Mon, 30 Oct 2023 23:53:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 625428.974699; Mon, 30 Oct 2023 23:53:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qxc4q-0001Yr-Vt; Mon, 30 Oct 2023 23:53:48 +0000 Received: by outflank-mailman (input) for mailman id 625428; Mon, 30 Oct 2023 23:53:47 +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 1qxc4p-0001Gf-D0 for xen-devel@lists.xenproject.org; Mon, 30 Oct 2023 23:53:47 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 903caa6b-777f-11ee-98d6-6d05b1d4d9a1; Tue, 31 Oct 2023 00:53:46 +0100 (CET) Received: from BL1P223CA0005.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::10) by IA1PR12MB7688.namprd12.prod.outlook.com (2603:10b6:208:420::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28; Mon, 30 Oct 2023 23:53:41 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:2c4:cafe::ce) by BL1P223CA0005.outlook.office365.com (2603:10b6:208:2c4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29 via Frontend Transport; Mon, 30 Oct 2023 23:53:41 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB75.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Mon, 30 Oct 2023 23:53:41 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.32; Mon, 30 Oct 2023 18:53:40 -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.32 via Frontend Transport; Mon, 30 Oct 2023 18:53:39 -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: 903caa6b-777f-11ee-98d6-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FfYlW3dKpfNqMfqFT/lNoRDOa4zyyc+zZowpmbUUGeU8siHtazH9q+7v0tab2lJILihcPCnNVcpv6gRtF6gI7FBN235ZTR0rtm2O8SvGApxlpkRki8nTDTwoneMYT/6CKR2J65zKLpYE0MctKS6dAfw6AbNR0Rk9xGH6/QuMjyj1Db5mF1PsEDkgw8f4/W5dCrLzu8hyfhtV3wX4gcBAjjAQO2EODpnKiBVXpp5TrUrfZUbMtcIHde9myOrF5wfrXTrtrkJyoxSmVfeQ7OP65wquWLS5Agu0YWou+Os7ur9xR2ZiZfd76L0gd7o7HHco0f0M2nScoCMm7y1prnG5tg== 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=w6TYM1i0vSlru/rDee01ixHg5fuu2TI7QkbjK5Jwo0o=; b=glECe+uh0nFNduqzPxNwdBjm6NKrH0sZAN+b1X7GXoLdPYeZyI+EP7CkcDH89GoN4hqrMlxigt6boNy33J12oeavwmsG/CmfKBA+VUjKHuJ8/KLu3hKzM39YU6rqQBMQZ52jgNFi9OIE+N7VyU32hv/NGODWJ/WStYaQfekJ7O7gvquQylnd2nn6CJPE+qyw414uIRAOB2GK168y2dya3lI+KJQDhrGQRq/2p34OqGjtFjsGhi58yO2L4mJSu3wnhgw/U1wvIkqI/n+t3ucLVxtO/5oMPQf3An8SA8bnQV7Ig5YsxwtaNjvo6WAdOlAepKFCwsC0eWeE6z+yUAX6hw== 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=w6TYM1i0vSlru/rDee01ixHg5fuu2TI7QkbjK5Jwo0o=; b=nJmGigQPcZNox4UaUlW3erapo6tzyxAA4vdCV+juMTnLRRxgZMgYStqOKtzc36WGdQl+bDwmddzbWNi6367F6h1qAqiZJXU3dJvkc2lhNBlPAZeT6cT1Hxskye8UVoNueRjI6odyKZt6mbRRW9Cu2EqfXdLh3UVy0ryRJFaWhAM= 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 , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v4 3/5] xen/arm: enable vPCI for dom0 Date: Mon, 30 Oct 2023 19:52:34 -0400 Message-ID: <20231030235240.106998-4-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030235240.106998-1-stewart.hildebrand@amd.com> References: <20231030235240.106998-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|IA1PR12MB7688:EE_ X-MS-Office365-Filtering-Correlation-Id: 290db4b6-73e7-4705-16b7-08dbd9a37184 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kZOZCypkYDeNxBSIX6C4ZGLkt0oYJBpFqGjiLOKx8AJEKTVUQPGk4CdRWNSh2zDfpYyu1uV0SFjg4yxz1qx3WEnwBvgAgf4f0AXb+Dw03sBvgSYbXd+EI0QUFNYTGhy/ubD5QSrfKQjL8dWW3U+YRTMTcr/S/XtfhnJyOmwyB0dp2++NCerzm3bokeJLsz6NPwC9rxLVlhBHdZ3aKKkbHlYNX9ot/WsC8icOv8s9ZvD7xZnhGeLYsM7LYsaTvORMfnG68irrhC1co4a3i4vh31GrZymFnNxFfpHJj6ex3YzIvHpqyUYtHqfDr5Xs37cCqVRSpg9Bzj2M8IAyXW3aDsRl91OPQReyhPmdod1ilD//KpIkLcEM2JtQXrRXxFa+Dkm3i5XaeyCrRvH46tA2DEKYL6VWPeYqtit0IOBDFwYd114rFejDyK8CVcOZaOab8kK9O5yBVkzmflLao54Au0j89dX/d31MRviNZwQS+uy8diBeN/mNJMD72mYqjmBx1tJYuRWcAM/Dd3kXzKImfG2IbxGfZ5jwoR3H5bVwvTnEap/7742tE/qGMRFfxbBomaEHjkoYl0FMNe4USKpcowEF/NlpP1Jgf03D6siKggaEZiQZ0Ae92Rf4CckoY1M4VztOGxqCTg6LIYxaMCFXJwCUAVRE6et3eOc9RUoN91g1k1M/l1xgploT+mZIEk2jxmqvQzhTXIb3HW8O/iDj72VupxpBKwdF90pVBhLI4EdOntH7e2hHbkdRvBeP0DwAoWKerWDK/SKEVRyJEi4YnQ== 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:(13230031)(4636009)(136003)(346002)(39860400002)(376002)(396003)(230922051799003)(451199024)(1800799009)(186009)(64100799003)(82310400011)(36840700001)(40470700004)(46966006)(5660300002)(6666004)(336012)(426003)(26005)(2616005)(47076005)(83380400001)(1076003)(8936002)(8676002)(44832011)(81166007)(356005)(86362001)(478600001)(40480700001)(40460700003)(36860700001)(54906003)(2906002)(70206006)(70586007)(316002)(6916009)(82740400003)(41300700001)(36756003)(966005)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 23:53:41.0123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 290db4b6-73e7-4705-16b7-08dbd9a37184 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: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7688 Set the vPCI flag in xen_domctl_createdomain to enable vPCI for dom0 if iommu and PCI passthrough are enabled and there exists a PCI host bridge in the system. Adjust pci_host_iterate_bridges_and_count() to count the number of host bridges if no callback is provided. Signed-off-by: Stewart Hildebrand --- v3->v4: * depend on iommu_enabled, pci_passthrough_enabled, and whether there is a pci host bridge v2->v3: * new patch [1] https://lists.xenproject.org/archives/html/xen-devel/2023-10/msg00475.html [2] https://lists.xenproject.org/archives/html/xen-devel/2023-10/msg00210.html --- xen/arch/arm/domain_build.c | 6 ++++++ xen/arch/arm/include/asm/pci.h | 9 +++++++++ xen/arch/arm/pci/pci-host-common.c | 11 ++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 49792dd590ee..4750f5c6ad31 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3915,6 +3915,12 @@ void __init create_dom0(void) panic("SVE vector length error\n"); } + if ( IS_ENABLED(CONFIG_HAS_VPCI) && + iommu_enabled && + is_pci_passthrough_enabled() && + (pci_host_iterate_bridges_and_count(NULL, NULL) > 0) ) + dom0_cfg.flags |= XEN_DOMCTL_CDF_vpci; + dom0 = domain_create(0, &dom0_cfg, CDF_privileged | CDF_directmap); if ( IS_ERR(dom0) ) panic("Error creating domain 0 (rc = %ld)\n", PTR_ERR(dom0)); diff --git a/xen/arch/arm/include/asm/pci.h b/xen/arch/arm/include/asm/pci.h index 8cb46f6b7185..4ae4d8cff8bf 100644 --- a/xen/arch/arm/include/asm/pci.h +++ b/xen/arch/arm/include/asm/pci.h @@ -154,5 +154,14 @@ static inline int pci_get_new_domain_nr(void) return -1; } +struct pci_host_bridge; + +static inline int pci_host_iterate_bridges_and_count( + struct domain *d, + int (*cb)(struct domain *d, struct pci_host_bridge *bridge)) +{ + return 0; +} + #endif /*!CONFIG_HAS_PCI*/ #endif /* __ARM_PCI_H__ */ diff --git a/xen/arch/arm/pci/pci-host-common.c b/xen/arch/arm/pci/pci-host-common.c index c0faf0f43675..e6a03ae668f8 100644 --- a/xen/arch/arm/pci/pci-host-common.c +++ b/xen/arch/arm/pci/pci-host-common.c @@ -319,9 +319,14 @@ int pci_host_iterate_bridges_and_count(struct domain *d, { int ret; - ret = cb(d, bridge); - if ( ret < 0 ) - return ret; + if ( cb ) + { + ret = cb(d, bridge); + if ( ret < 0 ) + return ret; + } + else + ret = 1; count += ret; } return count; From patchwork Mon Oct 30 23:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13440938 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 AEA3AC4332F for ; Mon, 30 Oct 2023 23:54:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.625431.974709 (Exim 4.92) (envelope-from ) id 1qxc56-0002BA-H5; Mon, 30 Oct 2023 23:54:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 625431.974709; Mon, 30 Oct 2023 23:54:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qxc56-0002B3-Cr; Mon, 30 Oct 2023 23:54:04 +0000 Received: by outflank-mailman (input) for mailman id 625431; Mon, 30 Oct 2023 23:54:03 +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 1qxc55-00009Y-A7 for xen-devel@lists.xenproject.org; Mon, 30 Oct 2023 23:54:03 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20617.outbound.protection.outlook.com [2a01:111:f400:7e8b::617]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 98ec147e-777f-11ee-9b0e-b553b5be7939; Tue, 31 Oct 2023 00:54:00 +0100 (CET) Received: from BL0PR01CA0001.prod.exchangelabs.com (2603:10b6:208:71::14) by SA1PR12MB7319.namprd12.prod.outlook.com (2603:10b6:806:2b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.24; Mon, 30 Oct 2023 23:53:57 +0000 Received: from BL6PEPF0001AB71.namprd02.prod.outlook.com (2603:10b6:208:71:cafe::e) by BL0PR01CA0001.outlook.office365.com (2603:10b6:208:71::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28 via Frontend Transport; Mon, 30 Oct 2023 23:53:56 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB71.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.22 via Frontend Transport; Mon, 30 Oct 2023 23:53:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.32; Mon, 30 Oct 2023 18:53:55 -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.32 via Frontend Transport; Mon, 30 Oct 2023 18:53:54 -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: 98ec147e-777f-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DfpWf7l70nhSaMpg85PxIlTl5R0YEKaPntc0JtUjLlnj/IBgF0Um8YSKVGbjMIoCEzgnlWNRAaDEDRgNTnf/BAReeiRJBr61bMjiwBMZSX8+zhECPmzlNfEhoffkeL5748onj7GLWLz8a+pv72Hj6dW+1A54AutVsR4ShPz4XRGsvLC5Jc9mR5CFAOXnerrn/uvnVq1nLnPtlCgcNJDp3/YHiG4beGlYoKbZ4jlC8v/L6VJ5rfGyHrNNjrZ8ERop5jn9bt8B3Xa23f9SVLD+7pIK4tA4/Qk6F4A12TNI2ksvgyyzg/8HSkFsem59Fkw2aaadDDeS+nuRdV2zSBTepg== 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=jS463M7ybXNAP2udLjwYqu5FXR0JgJvPA4yJkwmqw18=; b=kt0O3QHGST8XQ+CKYeCZqLvGDs3nSnvJ/XG36k5CgWshkzcdIgnF/hKx8PVX7ebbXcWMSU2b7cTde1fUrYe3HzRfVMzXTlP1ZgxjhySg8tybaUE1Sn2xYtEW5LZGFi2RKd2Bfff+xKCJT9x5B55QFKbsrCblp7RTkYJ/GbKIf+oX1EDstbC3zdxbnN/ExhevL8aiky8fEq5bOj2mFK1/IBATr3Cp8mp3AZUq2hlF5CWp4auiG8AogQh/SDh7tJd4SuiSkQvqc9jDR2PYA919TzTBik4oubmslFMOQhHMeyeRd5vdVCeaxKxYnQT6UONiU6/qikFURFI1LuCRr8/m5Q== 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=jS463M7ybXNAP2udLjwYqu5FXR0JgJvPA4yJkwmqw18=; b=5NyQVFjKeYFR2+lKxiaO+KR8pj8vj4CiLfUoL4CqyOS/iOLr/RPD3umF3wGrkLdjNVt/mPl3qPqI/KfuHd2JuQNneGQ+opXds3oLsF+gU+OQXHPDNprRnWPTKVjf4L/7I2grwUhNpflmmYV5iBMdJFS82CEBxCnCAlGcMFXs0R0= 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 , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Jan Beulich , Paul Durrant , =?utf-8?q?Rog?= =?utf-8?q?er_Pau_Monn=C3=A9?= Subject: [PATCH v4 4/5] [FUTURE] xen/arm: enable vPCI for domUs Date: Mon, 30 Oct 2023 19:52:35 -0400 Message-ID: <20231030235240.106998-5-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030235240.106998-1-stewart.hildebrand@amd.com> References: <20231030235240.106998-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB71:EE_|SA1PR12MB7319:EE_ X-MS-Office365-Filtering-Correlation-Id: c601a318-4e04-47ca-b523-08dbd9a37a7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MGCSPsk9Z40HOTa+fbrIlVXoH1aaDfpA2DLrnsnS6K+5ItVGwlRwFssVrHxQQ/8t0XJs/0VLLWZotSZu1GgwUpxGvR7tvFecKOSpCCIaDiG6Hs7o4dRPGat7f3xrJeJPRcTJa+yZtVv3kleDhrAmVnEc/7co7PViVthfTq+ZdMdKY8PIkL/gi02qpfwa9go0/KZnCKvETEXdHn/WcWI9ZPR6hfRLzvvHpr1sxeXIMI9U9AHBAj8CXpEMuEujEsYuXZ9U8h0lRlnw1CRPZzGzDD5+t6Y/ph4dwCrHjAWInf11juNWnO2g92BFrevkNpmAWhI5HkhBMqncP04cvGNrE7owU21hbif2BBVk4O4uO2gxgXEbQ3vDyCqiSVcZ/VyGikxvVIc7ibBr0QvPFQJBWddhuwdiCDJbqwcIudYrFNF8SWKyKyFET1T3qjlCCEqw5btQRtriVMzzIpbskulC9ArrvJHPe2znnV+GCGrUIyJut2qC7W/lyyulQLwh0f5JlXOjUIq6xNumGS7ITxt9zMcPvIPnxXcTwLDVS48d5XRssMtbRMiFugGOEnZFSEs6tmMlcWVUJTK4b/A0CzliMEyoDlNOaD5R0NXsVUJV4SMLDQ8tRiE5MpyEKirc999Gg+oKuQAu6kyDgTgWZbzNeQT0k2Y2QyA0Lfbam2HZTxKr4SXS75OrfPPvE9GsgklKvbPIOqxoZK3NMuMsL2sbsL4fDOVpODnTnoB/y1+iKtWUnMk6NyVj3D7pMafuHPcVQy4Pwjb+HyAOwCqIUYwv3/CtR8YxLK33qv/0JtAwfhM= 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:(13230031)(4636009)(376002)(396003)(39860400002)(136003)(346002)(230173577357003)(230273577357003)(230922051799003)(451199024)(64100799003)(186009)(82310400011)(1800799009)(46966006)(40470700004)(36840700001)(336012)(40480700001)(40460700003)(8676002)(36756003)(86362001)(8936002)(4326008)(356005)(47076005)(82740400003)(44832011)(81166007)(36860700001)(83380400001)(966005)(2616005)(478600001)(54906003)(6916009)(5660300002)(6666004)(70206006)(1076003)(316002)(41300700001)(26005)(2906002)(70586007)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 23:53:56.0478 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c601a318-4e04-47ca-b523-08dbd9a37a7c 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: BL6PEPF0001AB71.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7319 Select HAS_VPCI_GUEST_SUPPORT in Kconfig for enabling vPCI support for domUs. Add checks to fail guest creation if the configuration is invalid. Signed-off-by: Stewart Hildebrand --- As the tag implies, this patch is not intended to be merged (yet). Note that CONFIG_HAS_VPCI_GUEST_SUPPORT is not currently used in the upstream code base. It will be used by the vPCI series [1]. This patch is intended to be merged as part of the vPCI series. I'll coordinate with Volodymyr to include this in the vPCI series or resend afterwards. Meanwhile, I'll include it here until the Kconfig and xen_arch_domainconfig prerequisites have been committed. v3->v4: * refuse to create domain if configuration is invalid * split toolstack change into separate patch v2->v3: * set pci flags in toolstack v1->v2: * new patch [1] https://lists.xenproject.org/archives/html/xen-devel/2023-08/msg02361.html --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/vpci.c | 8 ++++++++ xen/drivers/passthrough/pci.c | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 5ff68e5d5979..3845b238a33f 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -195,6 +195,7 @@ config PCI_PASSTHROUGH depends on ARM_64 select HAS_PCI select HAS_VPCI + select HAS_VPCI_GUEST_SUPPORT default n help This option enables PCI device passthrough diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c index 3bc4bb55082a..61e0edcedea9 100644 --- a/xen/arch/arm/vpci.c +++ b/xen/arch/arm/vpci.c @@ -2,6 +2,7 @@ /* * xen/arch/arm/vpci.c */ +#include #include #include @@ -90,8 +91,15 @@ int domain_vpci_init(struct domain *d) return ret; } else + { + if ( !IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) ) + { + gdprintk(XENLOG_ERR, "vPCI requested but guest support not enabled\n"); + return -EINVAL; + } register_mmio_handler(d, &vpci_mmio_handler, GUEST_VPCI_ECAM_BASE, GUEST_VPCI_ECAM_SIZE, NULL); + } return 0; } diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 04d00c7c37df..bbdc926eda2c 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1618,6 +1618,16 @@ int iommu_do_pci_domctl( bus = PCI_BUS(machine_sbdf); devfn = PCI_DEVFN(machine_sbdf); + if ( IS_ENABLED(CONFIG_ARM) && + !is_hardware_domain(d) && + !is_system_domain(d) && + (!IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) || !has_vpci(d)) ) + { + printk(XENLOG_G_WARNING "Cannot assign %pp to %pd: vPCI support not enabled\n", + &PCI_SBDF(seg, bus, devfn), d); + break; + } + pcidevs_lock(); ret = device_assigned(seg, bus, devfn); if ( domctl->cmd == XEN_DOMCTL_test_assign_device ) From patchwork Mon Oct 30 23:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13440939 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 2CE48C4332F for ; Mon, 30 Oct 2023 23:54:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.625433.974719 (Exim 4.92) (envelope-from ) id 1qxc5M-0002kU-PE; Mon, 30 Oct 2023 23:54:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 625433.974719; Mon, 30 Oct 2023 23:54: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 1qxc5M-0002kN-Lk; Mon, 30 Oct 2023 23:54:20 +0000 Received: by outflank-mailman (input) for mailman id 625433; Mon, 30 Oct 2023 23:54: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 1qxc5L-0001Gf-3k for xen-devel@lists.xenproject.org; Mon, 30 Oct 2023 23:54:19 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20631.outbound.protection.outlook.com [2a01:111:f400:7e83::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a2da9b7d-777f-11ee-98d6-6d05b1d4d9a1; Tue, 31 Oct 2023 00:54:18 +0100 (CET) Received: from MW4P221CA0002.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::7) by PH0PR12MB7887.namprd12.prod.outlook.com (2603:10b6:510:26d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19; Mon, 30 Oct 2023 23:54:13 +0000 Received: from CO1PEPF000042AC.namprd03.prod.outlook.com (2603:10b6:303:8b:cafe::3d) by MW4P221CA0002.outlook.office365.com (2603:10b6:303:8b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28 via Frontend Transport; Mon, 30 Oct 2023 23:54:13 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AC.mail.protection.outlook.com (10.167.243.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Mon, 30 Oct 2023 23:54:12 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.32; Mon, 30 Oct 2023 18:54:10 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Mon, 30 Oct 2023 16:54:10 -0700 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.32 via Frontend Transport; Mon, 30 Oct 2023 18:54:09 -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: a2da9b7d-777f-11ee-98d6-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EmPH1HjQu9DWY2+R6Iu8JyGqJ1ZOErfrlHwbgCN0omGgGrTsDlHT1JxwEPOlPX+nQQSdP5c+PY9/Ih/zPucjH99eqHeqcdpmHRpcE/iHfuSvWFVOq3fHt6QEMBCT+Rl4yL094AfoVdOigjZgI9bTk077opBwyVD3b9022EaqJRoEeCAkRzdUrreAAKX5KD0bA0qQxaoDN7zUK9Ip4Gx3OSltBmFoGlze0lN0V9uOIAC1/mQ+JUESwhq2G9URViKnZj5qxBzvQr5APA7vSt9n6fFx4FeAkBzQKfj8DMLZ0yNEmc7pzV0HU3fs9g4kmDQm1lIPWVQDFiaeKiUGvzs5oA== 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=ZcqRDhU+U2f04Uf/nmVGrqD/iilRRWwf9OkeqXO/Q44=; b=dUR3FT098V9T/lBZP/xYLTfdF9AAXiKXyELoWkJsfQUHcIRGRRFItijFy4Z+M3lBYbvSz6uNTqBRm2LtSp8qJirBnB83SJUnDrHGNDkVZeoJ51YAFpz17TG4tqcu01+lkJwTH4yBK9s3T6r8EAcVK/NeObN+jmqPZlb6wPReWmv09ywt9W32ZYMmjRhWPVnXilSBsHuGStnXSseL4kpbgWMzR3wXxbRwrqHdzqMyQcDVhNhOPpXfrF+ArlTfmLQYYL/Krz/OjDuB9T5CTmKz3VKvDbT+F7a9SuE+kqkPQmwf10O+Z3BUCFdW2hGkVsyQPmDIu/Dp/Zg6SX6mJHpG7Q== 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=ZcqRDhU+U2f04Uf/nmVGrqD/iilRRWwf9OkeqXO/Q44=; b=GAMseXUtWsCo6i52VOL2Y1SqoQmUalQunsVWlfX1oxL9y6QF+6SQgYX0G0fBnafaBth9MxkvN4k3f+NwsEIUEGfrcloc5vxL3fTAvAhV4f05NfLq/qBmmaPHr841nCYgY2UYyQjFh6Vvt1Q6NIwzCnlLjNF9aeg4p/NJIhJ/hn4= 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 , Wei Liu , Anthony PERARD , Juergen Gross Subject: [PATCH v4 5/5] [FUTURE] tools/arm: enable vPCI for domUs Date: Mon, 30 Oct 2023 19:52:36 -0400 Message-ID: <20231030235240.106998-6-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030235240.106998-1-stewart.hildebrand@amd.com> References: <20231030235240.106998-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AC:EE_|PH0PR12MB7887:EE_ X-MS-Office365-Filtering-Correlation-Id: 465df51c-59f6-458c-953b-08dbd9a38476 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +JrTeFOuuuJmq9HbpuZLojEPc0+AAIhTiNHBkMl2/LGg6MFioOBWO4mbtrnrtgiT41mvSiibqwScfBX6jmt/CviehCPeJS3I0qGjc0VybcAMGwDXXPdv97QcL8dPSrJL95JbDybvtLHZyCRPb7FVBLBoU9fPyZ1QWet+a0yRHrgGZ1E1gb/cYjH2ZX4Krwhy4m4Tc2W1zuurqp1NWjXX62LEcLfT/Js4vjgrtwA6DPX10ls6HTfxdHYiHIx62yy5Q2blj3LVRfxEEdBLNtjVXTVkh3FSdDzivVMqWvyxN310bSZeBjGb6tuni10KuCFPxcivgYK0or+R2mgUV32YQUKFpl8eZyLgUJ8RGq+W+2j5Z7mvLeVaO/6rXbz+m1lQXqsoEApQ7VtRQ9Gy00xNJgSNSUxJ47juQAFfxadVdocqs/eGrp/dSVOXbKpelgre0L+BBZStJdigP6CAzQrMF3RkIfUQrtQgM/G0BwHn6tc6Z4tVqtKuhp1bw86dPGbAJmPQpD/A+WbHr5NdPPq2EJ2GBB4TI1HHvE1sp5ZUzyraisLZinmqBGnRKL7bmlAlT8qu+92kmnj9Eu6rCaVUvdvzx+48HN6+F93ZOZGoKc2rXkm34bDFSATBnRSDwkAWUGXwtaYK6Z9OFMSECho24nZu+X8L0lxvA2rng4xEyob5M49CVKyEiOTYuPeZA5bs31Q7+5hi8yIQC3eGBEjWR6TYSdIsi5NeaFhhxQYrnbFSY9QSSS6m9k97hPGViTyr0mCZrQ8IOb04Z72+n9WQNA== 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:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(186009)(1800799009)(64100799003)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(40460700003)(44832011)(40480700001)(2616005)(478600001)(1076003)(6666004)(36756003)(36860700001)(426003)(336012)(86362001)(47076005)(54906003)(26005)(356005)(81166007)(70586007)(8936002)(70206006)(4326008)(8676002)(41300700001)(82740400003)(5660300002)(6916009)(2906002)(316002)(4744005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 23:54:12.6755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 465df51c-59f6-458c-953b-08dbd9a38476 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: CO1PEPF000042AC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7887 Set the vPCI flag in xen_domctl_createdomain to enable vPCI if a pci device has been specified in the xl domain config file. Signed-off-by: Stewart Hildebrand --- Same story as the patch before this regarding the [FUTURE] tag. v3->v4: * split from ("xen/arm: enable vPCI for domUs") --- tools/libs/light/libxl_arm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 15391917748c..6daed958e598 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -222,6 +222,9 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, config->arch.sve_vl = d_config->b_info.arch_arm.sve_vl / 128U; } + if (d_config->num_pcidevs) + config->flags |= XEN_DOMCTL_CDF_vpci; + return 0; }