From patchwork Thu Nov 2 19:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13444167 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 85F05C4332F for ; Thu, 2 Nov 2023 20:01:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626979.977775 (Exim 4.92) (envelope-from ) id 1qydrz-0000by-1R; Thu, 02 Nov 2023 20:00:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626979.977775; Thu, 02 Nov 2023 20:00:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qydry-0000br-Ul; Thu, 02 Nov 2023 20:00:46 +0000 Received: by outflank-mailman (input) for mailman id 626979; Thu, 02 Nov 2023 20:00:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qydrx-0000bG-SX for xen-devel@lists.xenproject.org; Thu, 02 Nov 2023 20:00:45 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20617.outbound.protection.outlook.com [2a01:111:f400:7eaa::617]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 80bf2312-79ba-11ee-9b0e-b553b5be7939; Thu, 02 Nov 2023 21:00:43 +0100 (CET) Received: from PH7PR17CA0028.namprd17.prod.outlook.com (2603:10b6:510:323::8) by CY5PR12MB6251.namprd12.prod.outlook.com (2603:10b6:930:21::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29; Thu, 2 Nov 2023 20:00:38 +0000 Received: from SA2PEPF000015CB.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::78) by PH7PR17CA0028.outlook.office365.com (2603:10b6:510:323::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21 via Frontend Transport; Thu, 2 Nov 2023 20:00:38 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015CB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6954.19 via Frontend Transport; Thu, 2 Nov 2023 20:00:37 +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; Thu, 2 Nov 2023 15:00: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; Thu, 2 Nov 2023 15:00:10 -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; Thu, 2 Nov 2023 15:00: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: 80bf2312-79ba-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DgfxmImPfVTiJMNB0Wpk/VEPP/UHFDr/DJkSEpBHsQ2hBSm+RqBVAqSJE2Rxq3XZU/jV6IY4szhYHJaVHXnTx+5qlAIX7lzo9XFKzTF3g4Vl7dlLv9Gszhv8rEm8hBKxfvzujDgtln8P85b9qDZjyz3pM8tm5Pk2GsIHcivPtPwUEzCywf/Ipy/VEcY9ig2r4a3gcY0DEDNyXIu/fpj2otYwhsnKhDEmczl3cFzXEgJJP9FfjICaSZviDeJbko9RbZNeVmeaJbWG3KkXaFP+LXYK3SOLVf1bI4Da9enRPjy9CnYoX694CE357FBeQw9T2HsgROxWaVM1CU/wJVPFpQ== 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=DLtVJgg2CaFtIR8gaoR2mC1Q7M054B9aA+rGVYOSc/0=; b=G92DrPTk6Dg1D1HvrZiRfGw+qXp7WYednTQrYHPJ5I2hKv37JFYOVHXIvCtClDTlUATvRQzwEE8ktBsA/3Twrxxq7JWou63it0UeZM4drrJzT1vNGRrLwGDjrBDYaefSiSPE2dJ2dWFTIcpAP+lZCIyCkVpjqr1f8ATYDqR0xRh+4nrXSQpQVG15uAMu3x7/FRAi3Y7Rwh5kIbUIUN5soXNY1BORwchaoCDCaRdelirH0SHIRv56E8miyA8Lq/UOtvYZFOeo6hnBeG4ZqGbA92IhT3WYa/892W3YPUtnA868fjZ9MckZ6vDLanSS1j6LvWFtCHYgkb6iruUmMpFxIA== 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=DLtVJgg2CaFtIR8gaoR2mC1Q7M054B9aA+rGVYOSc/0=; b=4QGb89SS48/uUMdBsokD0mPiplAYahIzkT8CcmsTz+vmDIWOyJyQCGz+VXdKUt1igl9vxH5XDQO/npl93h5uhVgGN1Ji4gMUqarFmGw8FimOaqM+CqYlzu1HAeYm9/Mvw6bbDzKqYJEia19pjMVcyrCjYzbCOuRSebprg+HlzVo= 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: Rahul Singh , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Stefano Stabellini , Stewart Hildebrand , Julien Grall Subject: [PATCH v5 1/5] xen/arm: pci: introduce PCI_PASSTHROUGH Kconfig option Date: Thu, 2 Nov 2023 15:59:29 -0400 Message-ID: <20231102195938.1254489-2-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102195938.1254489-1-stewart.hildebrand@amd.com> References: <20231102195938.1254489-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CB:EE_|CY5PR12MB6251:EE_ X-MS-Office365-Filtering-Correlation-Id: 479f0b57-8cdc-45c6-8c0a-08dbdbde61dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KR0jAD2qqUILGTSbEKfoLA2swSVBFTl9OZ0W/t0ik1VJb5fdc7WgZFxyZ3WfI1+8HDkc3QfeUbv2UDBczVPBqJUI6clHBXgct5H6AipIySDgFMb/Jff3VUw7ahdXGud7ulDfQT4oW+6m8twrYIIDdAN1/UZHHs2TIWs6pj3rjepkGNMYMQkpXZfscsvMLcLhjnmXcyp9UIAfQ3UmJymnVT52qLsdNlGY85/LUqS0aL3S/Dw9did5BHQ7QyQNZ4xKKw47fUOfPlXbFzuQEy+9xLGA6GvYVOov9hBfPk80XqDK/vBXPshb031nV1z6oBRvoOP/2eL0CnTvZ1f8e6RcYc0W5ItUTaI34JxYF9X+P8zuNGlo7p1Bo3BgcfLZpo6SkU5BEJDZr/iu0gwSNhg1uV0HDaaUzp2EcHsKogyiLTG/pnhwkbZgcCpgnLFhgRhqekxmn6pvf5Sq90Ac8FYPTdwRiQVDcRx97GxOTOo78locT2ZAKK4EFBplXwKiXaCTRxevuo7a0e4vfvWhP3K/4EPWFT/1SzSDEPqmBjosVXaNyIEWzhujDayi3D//U9RDOMNf9MQZoTW+ht5/TCNL+pcO2+wtiajRIgapVT16PBLtakrSkewZ5W3yeOeg3o5KCmoKjObWTL7/8SzbY7Bpj37IKiwWu6UhbxIki4a60eqQ1x0JdpdPvIskG8dpogMnWFo6Zgwz9BAwGtFKqA0vuwuo7v7u+IOpg5tK55j24fdZVNMylp0gYlUU4h2cD5leg1dFKS/tJk0BjJQAWN5jgQ== 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)(376002)(396003)(136003)(346002)(230922051799003)(1800799009)(186009)(64100799003)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(1076003)(2616005)(26005)(40460700003)(86362001)(82740400003)(36756003)(356005)(47076005)(81166007)(336012)(36860700001)(426003)(8676002)(6916009)(5660300002)(4326008)(2906002)(8936002)(44832011)(54906003)(40480700001)(316002)(478600001)(6666004)(70586007)(41300700001)(70206006)(966005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 20:00:37.1623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 479f0b57-8cdc-45c6-8c0a-08dbdbde61dc 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: SA2PEPF000015CB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6251 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]) v4->v5: * no change 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-10/msg00660.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 Thu Nov 2 19:59:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13444166 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 23B78C4332F for ; Thu, 2 Nov 2023 20:01:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626978.977766 (Exim 4.92) (envelope-from ) id 1qydrp-0000Fk-LM; Thu, 02 Nov 2023 20:00:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626978.977766; Thu, 02 Nov 2023 20:00:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qydrp-0000Fd-IS; Thu, 02 Nov 2023 20:00:37 +0000 Received: by outflank-mailman (input) for mailman id 626978; Thu, 02 Nov 2023 20:00:36 +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 1qydrn-0008L9-SW for xen-devel@lists.xenproject.org; Thu, 02 Nov 2023 20:00:35 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2061c.outbound.protection.outlook.com [2a01:111:f400:7e8c::61c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7b0b667d-79ba-11ee-98d6-6d05b1d4d9a1; Thu, 02 Nov 2023 21:00:34 +0100 (CET) Received: from CH0PR13CA0031.namprd13.prod.outlook.com (2603:10b6:610:b2::6) by DM6PR12MB4236.namprd12.prod.outlook.com (2603:10b6:5:212::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Thu, 2 Nov 2023 20:00:28 +0000 Received: from DS3PEPF000099D9.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::73) by CH0PR13CA0031.outlook.office365.com (2603:10b6:610:b2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.10 via Frontend Transport; Thu, 2 Nov 2023 20:00:28 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by DS3PEPF000099D9.mail.protection.outlook.com (10.167.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6954.19 via Frontend Transport; Thu, 2 Nov 2023 20:00:26 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Thu, 2 Nov 2023 15:00:25 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.32; Thu, 2 Nov 2023 15:00:25 -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; Thu, 2 Nov 2023 15:00:23 -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: 7b0b667d-79ba-11ee-98d6-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DN4Og5+Klkd9Sx4lqt2+f+JCPw/RKx9eVwNoI9HRq74u79pN3aRhOBpYG2DcIGY5ZX9+PJBusR1x2tEJt296LlbIaD37b+wTJpRlVl4s8quubr+EOVJ2rC8BXC23dzEFfVGoJZiRzb/t83BlR1TdwNN6prFOVCm5dgB917m65u4DE2R3p5xQkRm4cBLheINWiSy76Y5xnrA+Fee6Us2Sfhjp8oAA5FzjDss1gyR0vexsbkqqAA1l3RhOz8DLpokD6ws+qTBIXdDjDKp940w+Bar2AIhHGfGFyqKeNWYi0yASXp34+X4Q3BnaazylOuOgQ/n29S5yA9HuO6bC/teWbQ== 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=LjnO2W6+4f0rPNUpLRFrSyi97Jq1KFFGDsynMmfMRLg=; b=E+4d1JqC3f5OOblUHjVXVgRsUNavU8GUaQiTMUBpZEI2rQCQ/9Lx4oq1OQxpqA73MlSMofo2e3oX6lIM6AKa3R6kO4ptK1fSpoRkccXXTbjQ4dx/zVd4gqXozKxVS4AQV4cWtfsQsCBZYeBTkbaXQ2/q+LaqPp3x6Plp2e7bS5x7I6l/uzQT+8xrH3G/+CzZ+pss9GtvPZap5/ivNXE5y7RljaeWO8muJ/Sk6AAwxtGioRjlnLE1HqcqJGZIwOpf8FhvsQ2/gjY0JWC4XU4hZKsdlRsLXzVnBQ6p2zocx8bCPTsJrVDle96j7qg1YiOhjvY5JgIJfIceL3R65Z6jTg== 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=LjnO2W6+4f0rPNUpLRFrSyi97Jq1KFFGDsynMmfMRLg=; b=Sybzzpe8q+VbPEMoL91aphg1T7qenSB8N9S4nzJEYcqU9ow0alSX3ztjDEzqJBxBHrd0Azsa/imOajjUqpORkBr+smPE3jjfmK/7acUj8GleJEn2oElngkpTRGNdZvum8ZKfw9ehweaq6S73fL/bxd4n3au78rXifxQBpwaFWFk= 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 , 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 , Christian Lindig Subject: [PATCH v5 2/5] xen/vpci: move xen_domctl_createdomain vPCI flag to common Date: Thu, 2 Nov 2023 15:59:30 -0400 Message-ID: <20231102195938.1254489-3-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102195938.1254489-1-stewart.hildebrand@amd.com> References: <20231102195938.1254489-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D9:EE_|DM6PR12MB4236:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b6b81a3-bd7f-4906-9bfe-08dbdbde5bc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /GMLFyDDCkvyfY8NEgSD2PtpVYL/Z5N/Wg2gVyam0lBbKiDKG10elLbuu4f+Bh67vXvgCSSducKMmHFDlw4oncQZpRTYlNHCnP/CVcmTrHev8UqYds3PoOrSsFhXvwKLY8Grm8n+F6bFoXQjFffAkItq1F6vNCcQy/eHz9hhikwiQLNJfFx8nydWYeF1LcwDRWKNfdwZaDStpsQXwkuL4dEGFPXmASsP3qUnUlbvWV1xCSPrkMjiIqQGP2kHji16VGUoxbsgiEbCjOEV/uVyCXIL5skFsnKDcdn5/Uijo55xSLgFhYtd5ikI9h5Pvrp/O545kCNZHtMr6oEANXtOGg9fkHXrDWVj89wh95chI0DCdzcvd8DNcY+AGNBns1sfjqNtzdyP6Xc17Uz8lV+zZKuiRPLyykX8GqtGV2NoWjhHk9QMQdyRDlkU+pQlfWnvcsueY8T0YWIuXLZ+ZvY1IBqh0z5CaY/mTh6xabSIZ+J7GNzeLnjrE1UzJhhhFDqey1fmx8bESRTZxbEXxeUYV6MnXCSPCGoBdYLbO6tYEL0MtbcgwHivgRRnrPLfd3KIaFa/UV1/8JkdzHdyGBdd+qu47ZlkO47QnUYljHzbl72/60ctckvFqXdaaj7/VXcRECsN1JEGX2XZ93Tib2K12Fw/789JQsbgw0KBmV9KPZXNvfijs1TbBw6oZ/xPxuoIjanpCriouxJ/ZwYVStu1jIIQUXkyflYSGOWznWQ0uMm5nACB6gytGxyyjyg7Po3q1HQHoOK8UWW7jSMDWk84xveNzqWEAWcf/5LDVx8EmC8= 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)(396003)(346002)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(8676002)(5660300002)(7416002)(4326008)(41300700001)(6916009)(54906003)(70206006)(70586007)(316002)(8936002)(30864003)(44832011)(966005)(2906002)(478600001)(40460700003)(6666004)(40480700001)(36860700001)(47076005)(81166007)(356005)(83380400001)(36756003)(1076003)(26005)(336012)(426003)(2616005)(86362001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 20:00:26.9038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b6b81a3-bd7f-4906-9bfe-08dbdbde5bc1 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: DS3PEPF000099D9.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4236 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 Acked-by: Christian Lindig --- v4->v5: * move flags_optional change in xen/arch/arm/domain.c to next patch * change latter 2 args to emulation_flags_ok() to unsigned int * move vpci && !hvm check to common code * remove stray spaces in emulation_flags_ok(), and a minor style fixup * add CONFIG_HAS_VPCI check into has_vpci() * add Christian's A-b (OCaml) 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/include/asm/domain.h | 3 --- xen/arch/x86/domain.c | 13 ++++++++----- xen/arch/x86/include/asm/domain.h | 6 +----- xen/arch/x86/setup.c | 4 ++-- xen/common/domain.c | 16 +++++++++++++++- xen/include/public/arch-x86/xen.h | 5 +---- xen/include/public/domctl.h | 7 +++++-- xen/include/xen/domain.h | 3 +++ 12 files changed, 45 insertions(+), 26 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/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..98f0397686cf 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, unsigned int emflags, + unsigned int cdf) { #ifdef CONFIG_HVM /* This doesn't catch !CONFIG_HVM case but it is better than nothing */ @@ -722,11 +723,13 @@ 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 ) @@ -798,7 +801,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..00dfcf231e21 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -890,12 +890,12 @@ static struct domain *__init create_dom0(const module_t *image, if ( opt_dom0_pvh ) { - dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | + dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_vpci | ((hvm_hap_supported() && !opt_dom0_shadow) ? XEN_DOMCTL_CDF_hap : 0)); 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..6a42eb6d8c18 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,18 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( vpci && !hvm ) + { + dprintk(XENLOG_INFO, "vPCI requested for non-HVM guest\n"); + 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..ab8f06c5f6a2 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -51,6 +51,9 @@ 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) && \ + IS_ENABLED(CONFIG_HAS_VPCI)) + /* * Arch-specifics. */ From patchwork Thu Nov 2 19:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13444169 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 9F111C4167B for ; Thu, 2 Nov 2023 20:01:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626983.977796 (Exim 4.92) (envelope-from ) id 1qydsI-0001N9-KN; Thu, 02 Nov 2023 20:01:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626983.977796; Thu, 02 Nov 2023 20:01: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 1qydsI-0001N1-HH; Thu, 02 Nov 2023 20:01:06 +0000 Received: by outflank-mailman (input) for mailman id 626983; Thu, 02 Nov 2023 20:01:05 +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 1qydsH-0008L9-9s for xen-devel@lists.xenproject.org; Thu, 02 Nov 2023 20:01:05 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20612.outbound.protection.outlook.com [2a01:111:f400:7e89::612]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8d12e61e-79ba-11ee-98d6-6d05b1d4d9a1; Thu, 02 Nov 2023 21:01:04 +0100 (CET) Received: from BL1PR13CA0332.namprd13.prod.outlook.com (2603:10b6:208:2c6::7) by DS0PR12MB8365.namprd12.prod.outlook.com (2603:10b6:8:f8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Thu, 2 Nov 2023 20:01:00 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:2c6:cafe::5b) by BL1PR13CA0332.outlook.office365.com (2603:10b6:208:2c6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.10 via Frontend Transport; Thu, 2 Nov 2023 20:01:00 +0000 Received: from SATLEXMB04.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.6954.19 via Frontend Transport; Thu, 2 Nov 2023 20:00:59 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Thu, 2 Nov 2023 15:00:41 -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; Thu, 2 Nov 2023 15:00:40 -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: 8d12e61e-79ba-11ee-98d6-6d05b1d4d9a1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OgYGmF5/6R3GWvdk05Z48eK6waBl/dvLOqKrmzpzBJG8vJS8ETXMPVjKYFGQ+wbxWOweCRgFL3S+jOlYXkJCpy6fv+gLuWjUp+P0UmTXRpFuMso7jGufhI9Q9zEIi7vHFMmM5qkBrAGZlEnuSmXLqoaGbT0dkTIVdnNRWOn9jAQTiDhfWE2/zWFH/pWzmKKIa9iMDXqIJ5u2UqfluBNUtXnkw6KljY+glxnAiXjldRG7udxa0DxTjgnzq1bHgfgYC/cob7u+oITeAn9/ooRYQJwIWopwhUIlHEXnrM7Kw+oteAsoxKXI2Hwh9tKhUFkxOa02NuXunU/mVVa3XrLppQ== 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=foc/8FzmXuit5/zyCxOQj1X7zaT4pCrJhL/sb10f1wA=; b=eFxWKvahDoyNDlZaZ74l5hXSOloZp8yFXNyjMuGcEp/lyVMhb3tNhfdDxwcmezH02odGSU6fZj1989NS473GpDXxAY4jDXuSPDzXmShDLJRXliIAu2dIZEJewt7SSx3B6iukEweWxyAjooc8KYqQqgm+2EfQJQwNctaKBplbyQ/mzyttYcoQ970f+CuRlGJxuOvyM1HVNcqSddMYFY/Y/vmBB3ezeujtPgRQnaFdHBI6dplTPwVp0UnR5f2d/WY1QpCyB4EWorBHqwFx2/FRRQ68A00aF4Rrjx52XJIFyLuD0uddMvTMm57lwD2u2/uI4y9rvjzajW0dn4cCWo8xqQ== 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=foc/8FzmXuit5/zyCxOQj1X7zaT4pCrJhL/sb10f1wA=; b=TjwSqwAK+JAARlJ/ajiXMzQMKIbAXk7tK1Bfoom9t0Om3f3ZD5HXTbTZcQ7j5RXjckNdqypBzySud7OnNYp+Vj7f7VbKW+2hZ5g5cylNfCwRlfTLgUEV1hQMO1uZwQyfIWLUk81U3YNtA6tgDW5FOF58gvVQcdIMSkeJKdAxP6E= 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 , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v5 3/5] [FUTURE] xen/arm: enable vPCI for dom0 Date: Thu, 2 Nov 2023 15:59:31 -0400 Message-ID: <20231102195938.1254489-4-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102195938.1254489-1-stewart.hildebrand@amd.com> References: <20231102195938.1254489-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|DS0PR12MB8365:EE_ X-MS-Office365-Filtering-Correlation-Id: 53fc6118-3ab6-4aae-5c23-08dbdbde6f6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s/z+ll5Zdw/O/vqbnqQLPRg55HjsCziILRbiI30BSvtQ/LzexvZFWGb9mJ0hwrk9vqTg5NYC3m56XE/xcC/ZbAxQqg9UShI2YXwr8SF4AQL/VyY0JSBkBYiwW2806TuqDb0EjCihefV0ry+JrDSjXCjrpmQXgBgU+/8xAEC3KM188vfKyDmovccS2fAZah5TIL4KVVcCJdeyyBQMDUjXV867oB/2DlGt018uaF0yL/2orDp7bjxXaqYJ79EzvmXjy9kjK9IhCTf/SPSN1wjfkYZZJ8FAgGS3gCTw6V1rdHWH29LYtcajCdFb5yV39TENbId61IcRvtegJ4OjAyLySvWNXSbRbPKj6Y1GhIyyp0ifxuLWqNDImu7Jiz6FnbOwDgbHTdr0c/lZP5jKF+xKdZmjcPQhHSu9Qhi2DbDUpShuJWqb7jje4EUnwh98fxM9+SqVvE4NYTEfM1Am6uRcznvcjpG5W5yGxH8J0JYzyf0nqBDh2K5/8wduHz+EXp+vYs9/I6HY4WL69busKVVT775AQ5gw/uLUm5++mGoebgwhw3mafQNFxbP9RfoKWZNKKzdVDmzD1DLeOSOIeP9cI5ooyWSpy1DPcZ0ajBl8Tpyu6g7wz6Q2Tk/N2SlqwfzMepjFSeT5DXfCPH2HIoS/OgtAFo0WN2dfhfwzI8c20nfkcpEmGf1NWdHnGdj4nskaYbmJt3eOXOGTbH/6lyQjT/jOK7czrc4CdFVmO4SmGKYziJ8/sb5ffVvAwvhibwr9R4/7FNr41svC4rMxMytsJw== 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)(346002)(396003)(39860400002)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(82310400011)(186009)(46966006)(40470700004)(36840700001)(478600001)(40480700001)(966005)(426003)(356005)(40460700003)(336012)(81166007)(82740400003)(36756003)(70586007)(70206006)(5660300002)(2616005)(47076005)(6666004)(86362001)(6916009)(36860700001)(54906003)(1076003)(41300700001)(44832011)(8936002)(4326008)(2906002)(83380400001)(26005)(8676002)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 20:00:59.9177 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53fc6118-3ab6-4aae-5c23-08dbdbde6f6a 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: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8365 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 --- Allowing/enabling vPCI for dom0 on ARM should follow or be part of the PCI passthrough SMMU series [1]. I'm including it here due to prerequisites in this Kconfig series. Once the prerequisites are committed I'll move this patch to the PCI passthrough SMMU series. v4->v5: * add [FUTURE] tag * move flags_optional change from the previous patch to here 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/msg00210.html --- xen/arch/arm/domain.c | 3 ++- xen/arch/arm/domain_build.c | 6 ++++++ xen/arch/arm/include/asm/pci.h | 9 +++++++++ xen/arch/arm/pci/pci-host-common.c | 11 ++++++++--- 4 files changed, 25 insertions(+), 4 deletions(-) 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/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 Thu Nov 2 19:59: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: 13444168 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 8740EC4332F for ; Thu, 2 Nov 2023 20:01:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626982.977787 (Exim 4.92) (envelope-from ) id 1qydsH-00016Q-Ck; Thu, 02 Nov 2023 20:01:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626982.977787; Thu, 02 Nov 2023 20:01:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qydsH-00016H-7s; Thu, 02 Nov 2023 20:01:05 +0000 Received: by outflank-mailman (input) for mailman id 626982; Thu, 02 Nov 2023 20:01: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 1qydsG-0000bG-4j for xen-devel@lists.xenproject.org; Thu, 02 Nov 2023 20:01:04 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20616.outbound.protection.outlook.com [2a01:111:f400:7eaa::616]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8be6b2d9-79ba-11ee-9b0e-b553b5be7939; Thu, 02 Nov 2023 21:01:02 +0100 (CET) Received: from BL1PR13CA0360.namprd13.prod.outlook.com (2603:10b6:208:2c6::35) by IA1PR12MB7541.namprd12.prod.outlook.com (2603:10b6:208:42f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Thu, 2 Nov 2023 20:00:59 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:208:2c6:cafe::9c) by BL1PR13CA0360.outlook.office365.com (2603:10b6:208:2c6::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.10 via Frontend Transport; Thu, 2 Nov 2023 20:00:59 +0000 Received: from SATLEXMB04.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.6954.19 via Frontend Transport; Thu, 2 Nov 2023 20:00:58 +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; Thu, 2 Nov 2023 15:00:57 -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; Thu, 2 Nov 2023 15:00:57 -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; Thu, 2 Nov 2023 15:00:55 -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: 8be6b2d9-79ba-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JhC1Xqda0VQs9o3OAKU2bam7Lru7yhRI1Q5wJs7bzaO1x//tpVHlfBUGSZAOfqkT0PiQqQs3IY46sVwyTVl2b4cUy330Rcu4VxryPknt0QcpO5vGsx88C2uFFZY5ftvEEn7tOFMtukCJc/59X6Dc8h+cPpDr4yMeh2puLDeh3TPs0tC66xiU0i7z9ZZnMPLWPWtm4AIzpobPNffsPoVpGhOmnn9CD4RuU6QHGec95Fc1Jq4UtH6aLx+v5TTuI9WTP/rp+2jPfyL1idkKhxzqdhSaxoklptUDkNp2uzYqT4jwgMEa/5x+Txqnw99Ljg+ppR+8b4YmViapCCNREPlpOQ== 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=swMECjZS0pFwEUksinFcexGL91Xa93viRgwHU+0cU2I=; b=PwFtVg0uWWlatN90I5bHjua3k6CWJSeCO0Yr96l+WPjdYjKBZkRWJTHeR4y3CQ3ZjoLE09mdWdM2SEpEpyW+SKbr6HnHGgzm8C40JfU+aA76jver3+9nKRzgTdox6Nc8xLiZOXhrIrcPX0NFMVjpsVYxqOTLWLObCFD8cOdlpfwVqG2nh7tWTluSNlcgQ2b5S1jWZ1skMuU48l4rHWhpWqdW1RJWnJKQmxqyfPavJl7R9OZocezuY4+iIyH/5Ip6W3C9kRTMqQylazNyHqlqrLiV0QYHzwutSU9cjZPtStmyW48P3EerUZV5R8kUAQfjfT3c7rIDn9eRk1v2tKlPtQ== 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=swMECjZS0pFwEUksinFcexGL91Xa93viRgwHU+0cU2I=; b=4woCjpPIvNUMn5ksRorRAVlHU+U0VRJkG75R99b4RGHq4dSGxo4Mdm6DYHwvm0+palIhNElQf4qkMPq0Mdd+S/S6I9v48+id7NkOJj/hlqDx+ziXBS74gTRCG+lxGd61lJE4MRBOsWZRkXQGbcl3TtolHoLvymlgpZoa8vMjh1s= 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 , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Paul Durrant Subject: [PATCH v5 4/5] [FUTURE] xen/arm: enable vPCI for domUs Date: Thu, 2 Nov 2023 15:59:32 -0400 Message-ID: <20231102195938.1254489-5-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102195938.1254489-1-stewart.hildebrand@amd.com> References: <20231102195938.1254489-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|IA1PR12MB7541:EE_ X-MS-Office365-Filtering-Correlation-Id: c603b87c-47c4-4e5e-7942-08dbdbde6ea4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gf8JQMyGH+OItyujxTR+aGr4hTXGE/mNB1vGaot8KoZvwt4DxCW1SocRjzhmpgc90xikHJfpecP12ztiZiINxZkh2l+yL0Tt7ij5dfOWDsBxF2X+4ae+5qzXgZNrscn/qwOFRzIrLpHmgE+6iDko5kv/P28NVtvpiEDeEP06toIdB2zdU50ZH3KXvwIxr8fDlUAO3fzhUcvpC8MrHLocZAZDRHSL7tEVdVuaqJFBOjcQix38uP1pzAJCbfmJhZt6HyKn/iXxhQeOapHaGeGQgXulGHDOXWP5VF/R40i6PvzlKVOZukuIKiIyIYfi7Ez77FkjA5jVxuQ+p2/mr4CfrIvEvvOemK8GeGs/yVdftlRVgg3kPBAs+VvySFma+vd/AnmF3L4Gdivqx8XK8LiVuGukZN+rgH6ZN3gm7vsg1Q/CKqVXf57SQRK4l4Nmkol/t+jrtcn/wbkOz07iWEyQlsw8Arz0LvIQkLuuDXiBvN/mb9Nqe6EMPLFL58X/QGig4sbt+lojfSwdiew3VWy8GCHOxIZQxLwQ/1fpDd4/t2PLDzBPRK4puiD7F+mqXXy8kzlFeyB7R1sBcdJUYE43ykaHVkO1KuUCXZ0vWjtGWRbZJ3wFpsQlwgHJNyRVYwSVZC7UXBB2o59E1AryLF/KPb9hsg7X9CzPy1Rx3lOWk9GTg8adRzRHDtmcbXi7JDZ6Gp8hWiizaQ3cJ2T68eepbtts+VMJNsb9CGqaFKwDExZSP6YnPPIwy0E4If2HUkqc3oxNdSBsacE9pt0oN99fWclcDqJ2hpfrLJiQI6b4GmQ= 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)(136003)(376002)(346002)(396003)(39860400002)(230922051799003)(230173577357003)(230273577357003)(64100799003)(82310400011)(186009)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(83380400001)(47076005)(26005)(336012)(1076003)(81166007)(356005)(36860700001)(70206006)(70586007)(426003)(7416002)(5660300002)(54906003)(6916009)(4326008)(8676002)(8936002)(44832011)(316002)(41300700001)(6666004)(2616005)(966005)(2906002)(478600001)(36756003)(86362001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 20:00:58.6365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c603b87c-47c4-4e5e-7942-08dbdbde6ea4 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: BL6PEPF0001AB75.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7541 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_domctl_createdomain prerequisites have been committed. v4->v5: * replace is_system_domain() check with dom_io check * return an error in XEN_DOMCTL_assign_device (thanks Jan!) * remove CONFIG_ARM check * add needs_vpci() and arch_needs_vpci() * add HAS_VPCI_GUEST_SUPPORT check to has_vpci() 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-10/msg00660.html --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/include/asm/domain.h | 2 ++ xen/arch/arm/vpci.c | 8 ++++++++ xen/arch/x86/include/asm/domain.h | 9 +++++++++ xen/drivers/passthrough/pci.c | 20 ++++++++++++++++++++ xen/include/xen/domain.h | 13 +++++++++++-- 6 files changed, 51 insertions(+), 2 deletions(-) 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/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index be9ed39c9d42..e4b4a12233f0 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -31,6 +31,8 @@ enum domain_type { #define is_domain_direct_mapped(d) ((d)->cdf & CDF_directmap) +#define arch_needs_vpci(d) ({ (void)(d); true; }) + /* * Is the domain using the host memory layout? * 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/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index cb02a4d1ebb2..57bbe842e18d 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -503,6 +503,15 @@ struct arch_domain #define has_vpit(d) (!!((d)->arch.emulation_flags & X86_EMU_PIT)) #define has_pirq(d) (!!((d)->arch.emulation_flags & X86_EMU_USE_PIRQ)) +#define is_pvh_domain(d) ({ \ + unsigned int _emflags = (d)->arch.emulation_flags; \ + IS_ENABLED(CONFIG_HVM) && \ + ((_emflags == X86_EMU_LAPIC) || \ + (_emflags == (X86_EMU_LAPIC | X86_EMU_IOAPIC))); }) + +/* PCI passthrough may be backed by qemu for non-PVH domains */ +#define arch_needs_vpci(d) is_pvh_domain(d) + #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) #define pv_gdt_ptes(v) \ diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 04d00c7c37df..2203725a2aa6 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1542,6 +1542,18 @@ void iommu_dev_iotlb_flush_timeout(struct domain *d, struct pci_dev *pdev) pcidevs_unlock(); } +static bool needs_vpci(const struct domain *d) +{ + if ( is_hardware_domain(d) ) + return false; + + if ( d == dom_io ) + /* xl pci-assignable-add assigns PCI devices to domIO */ + return false; + + return arch_needs_vpci(d); +} + int iommu_do_pci_domctl( struct xen_domctl *domctl, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) @@ -1618,6 +1630,14 @@ int iommu_do_pci_domctl( bus = PCI_BUS(machine_sbdf); devfn = PCI_DEVFN(machine_sbdf); + if ( needs_vpci(d) && !has_vpci(d) ) + { + printk(XENLOG_G_WARNING "Cannot assign %pp to %pd: vPCI support not enabled\n", + &PCI_SBDF(seg, bus, devfn), d); + ret = -EPERM; + break; + } + pcidevs_lock(); ret = device_assigned(seg, bus, devfn); if ( domctl->cmd == XEN_DOMCTL_test_assign_device ) diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index ab8f06c5f6a2..c3364d6e2e44 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -51,8 +51,17 @@ 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) && \ - IS_ENABLED(CONFIG_HAS_VPCI)) +#define has_vpci(d) ({ \ + const struct domain *_d = (d); \ + bool _has_vpci = false; \ + if ( (_d->options & XEN_DOMCTL_CDF_vpci) && IS_ENABLED(CONFIG_HAS_VPCI) ) \ + { \ + if ( is_hardware_domain(_d) ) \ + _has_vpci = true; \ + else if ( IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) ) \ + _has_vpci = true; \ + } \ + _has_vpci; }) /* * Arch-specifics. From patchwork Thu Nov 2 19:59: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: 13444170 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 31511C4332F for ; Thu, 2 Nov 2023 20:01:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626988.977806 (Exim 4.92) (envelope-from ) id 1qydsf-00024m-3n; Thu, 02 Nov 2023 20:01:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626988.977806; Thu, 02 Nov 2023 20:01:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qydsf-00024f-0x; Thu, 02 Nov 2023 20:01:29 +0000 Received: by outflank-mailman (input) for mailman id 626988; Thu, 02 Nov 2023 20:01:27 +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 1qydsd-0000bG-DO for xen-devel@lists.xenproject.org; Thu, 02 Nov 2023 20:01:27 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2061d.outbound.protection.outlook.com [2a01:111:f400:7e8c::61d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 99bbd4ea-79ba-11ee-9b0e-b553b5be7939; Thu, 02 Nov 2023 21:01:25 +0100 (CET) Received: from MN2PR08CA0018.namprd08.prod.outlook.com (2603:10b6:208:239::23) by CY5PR12MB6575.namprd12.prod.outlook.com (2603:10b6:930:41::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Thu, 2 Nov 2023 20:01:19 +0000 Received: from BL6PEPF0001AB76.namprd02.prod.outlook.com (2603:10b6:208:239:cafe::13) by MN2PR08CA0018.outlook.office365.com (2603:10b6:208:239::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Thu, 2 Nov 2023 20:01:19 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB76.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6954.19 via Frontend Transport; Thu, 2 Nov 2023 20:01:18 +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.32; Thu, 2 Nov 2023 15:01:16 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.32; Thu, 2 Nov 2023 15:01:13 -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; Thu, 2 Nov 2023 15:01:12 -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: 99bbd4ea-79ba-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XvnvBI1jQc7P3iNgtanvGtELPkJnanpDublf2zbGDTE1ZCg/K8wUtXdV1Qs9pVnuiI20ttcb1v9SDCmnCKeeiJqtR66mZmFKXuGQTfAsp4TIjt3yDtlmWVayfhyLAQXHPxIi6KGcBDgUm+q1zQkkLqOxtSCUtBee3xCsI2UMx00F7DVAUwUF68pxplH4blAfMpTwdJpBJl5t4WDghF1NTuX2YzRs5/rvGCv8ZkQzaJNJFatYNXa+CLJI7EmVgsFj/g9kMQmtLbhCRftSDPjtHqRPz6R6GU2TyZ7rqucwzGe6GK3bFeqAC9dHpPRRX61SORkty2WlbHxRMmho62HbvA== 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=3uwbiWJ1nI3UFBqjsZm4vAYZ3Ae/EpuSxlOkJkStLfA=; b=Mz8atBG0mrNpA6cXey8aPgsRg1Sg6+Pnw71yV+FkSZfGFLS4Yq8AUvlYpdXHO9pZtDO/C5kuztHqomII0lmYd6UYFXEO7Zj7boKpvfWoEvBTMTQEgYD1QbzbniMLhpa/CHzHNvGbWAMCJr31DVdxYK4CPSWOO9899BXVrYbBwbL6mfFE4xLklHcWmP6Qmx/V5UiT5A38X+KeXyjylsZPEK5Xf3rFEcveKlnF+9HSSlq2gNdysRcpoV9zn7weALlKMTxaPnFiHYyitPiZEWVoVvcQcsmLk4E5IcPc8Ca3TOIOKp/TdjxPJBSzLKO6UjP8+IAU3ufAi/HP1lrvuas1xA== 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=3uwbiWJ1nI3UFBqjsZm4vAYZ3Ae/EpuSxlOkJkStLfA=; b=APQcW4kY85/x5xL9U3eZ66BjCHujeV6R/WYZpc6c/2aqoLP369RL3uRoRMxPWbYP/6gCTCLFHKwBiFNBm4fRGDBQy2ZaALtVkU3FqI8hzZjxnTXBpw+EI75KwAuLa7HTd+Wc955drYQw/8ticQT+vkJgwptH0VFJZbZVzevg0zw= 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 v5 5/5] [FUTURE] tools/arm: enable vPCI for domUs Date: Thu, 2 Nov 2023 15:59:33 -0400 Message-ID: <20231102195938.1254489-6-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231102195938.1254489-1-stewart.hildebrand@amd.com> References: <20231102195938.1254489-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB76:EE_|CY5PR12MB6575:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b91149a-b549-4f28-9d87-08dbdbde7a70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Q6LTwBKsV6adbBlnsonGS2aXbksVl1jUaOcNmf0z/rlh7PHlc5untp62E7vXLOVK21EGqfagHz/yNzFNATdiVQRnD1YVl03cdZgMJVfgV+/7jnw7+zynaanb1a6lzxp5Upb4CcYpc9y84YkoF/BrayO1rm+MOYvYbFI2ROAyCSoxENq6jrjLSK9Ff/oN72jhROMi1aQE1XjUDdG7NmumdzTdn/okTLY+Mj+VUTJJ3EWAkgQfPUKxUnh4FfQIghrJULXvCQXOEdptzpJ7Pl5YPLpEMEHsrFpzfT+g2SOeh82B31e9CVPWOKa3Ku4UoM1pbX/bDpQyGxU4wbAHWCLWVZMqF2pUZ2OPedz38cqqSGkxVkCVu1QQAguVYlHrVBmSMtFJcMn1GUjXz/AAEA82I/dO7QbMpnjsKM5r22zBmKDafK4XrB+aYxvtp4hk45fj2PF0ix9uj/LJKAp4sUaicR8kYWZfIWY+5ocrNzouqAwDJKzbLi5mOySVJFOb3ncY5aN3q0jVGzbtzuoTskFJPTa5AixmSi+nebEUAYupLHiUqIC0mCU+xfESVpoEGr11CuaCwjE773IzDIZx5WGReGAb5JQ8tQVp1pHEdb25RhVnpqUvPafj4J4ldleO3yAv/M0Ty7CFqEDjth6/08ScRF/qTHr2e/GC5LbNw8GmVXIBrG3Rf/CDUWcYER+TUQw02ueiWmbfE3gDf7w/IQAAhxUmWA8g2cEU+8p/D763cqVn4JnA8PZwO5sVoWj98ivOLeEGQgv4RTvppu9VMBw4A== 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)(346002)(376002)(39860400002)(136003)(396003)(230922051799003)(64100799003)(1800799009)(82310400011)(186009)(451199024)(36840700001)(40470700004)(46966006)(6916009)(47076005)(316002)(4744005)(86362001)(40460700003)(2616005)(1076003)(2906002)(336012)(81166007)(426003)(54906003)(26005)(70206006)(356005)(478600001)(36756003)(44832011)(41300700001)(8676002)(6666004)(8936002)(70586007)(40480700001)(82740400003)(36860700001)(4326008)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 20:01:18.4136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b91149a-b549-4f28-9d87-08dbdbde7a70 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: BL6PEPF0001AB76.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6575 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. v4->v5: * no change 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; }