From patchwork Mon Nov 13 22:21:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13454499 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 98EA5C4332F for ; Mon, 13 Nov 2023 22:22:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.632030.985912 (Exim 4.92) (envelope-from ) id 1r2fJd-0003W9-CW; Mon, 13 Nov 2023 22:21:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 632030.985912; Mon, 13 Nov 2023 22:21:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2fJd-0003W2-95; Mon, 13 Nov 2023 22:21:57 +0000 Received: by outflank-mailman (input) for mailman id 632030; Mon, 13 Nov 2023 22:21:55 +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 1r2fJb-0003AY-Nx for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 22:21:55 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060b.outbound.protection.outlook.com [2a01:111:f400:7e88::60b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0c109f1c-8273-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 23:21:54 +0100 (CET) Received: from CH0PR03CA0023.namprd03.prod.outlook.com (2603:10b6:610:b0::28) by LV8PR12MB9261.namprd12.prod.outlook.com (2603:10b6:408:1ed::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Mon, 13 Nov 2023 22:21:50 +0000 Received: from DS2PEPF0000343E.namprd02.prod.outlook.com (2603:10b6:610:b0:cafe::c4) by CH0PR03CA0023.outlook.office365.com (2603:10b6:610:b0::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31 via Frontend Transport; Mon, 13 Nov 2023 22:21:50 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343E.mail.protection.outlook.com (10.167.18.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7002.13 via Frontend Transport; Mon, 13 Nov 2023 22:21:49 +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; Mon, 13 Nov 2023 16:21:49 -0600 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, 13 Nov 2023 16:21:47 -0600 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: 0c109f1c-8273-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hDoBTFG9su1xMJljowgeksOdvzsbvlpzmCp3Bq+WVh1Q2q5AGJjSlNW5ASwCQVccci1g6djoHrOOkpBJmrUHEMGZbq9LG6wBzFp6c4GwF71uo1+cWw7PEZON2MfmRp6Be+dWMmgKOzUOHhdxJZQ9R7kgzpPG3/p1/X8NWer5DNMJmEUpbDqKXH8R/hH7P+nupo8GE5hy29b2Q/RsvVQ/wFlZ6URHsCz878ljHKsO7YXw6JzxMaKo+UXEebWcVs0DNRjkhhhOxBFu1J5Fj/nxnaenVHSLKu4mtce5wDPoicJMGLvHFjNbku7yRQAVc8sJAVC77+ucOaaNLcVZAv3Qng== 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=d01MS5Ue/SUAYQwAAGRFoqPnpwVwUw5LXQKwJJmFc/E=; b=dwYkAE0SgrUdm3ETLqejTdsOhd05SowwKwb6IEVHszPdmenyijlFxhQZKhMT/lrDzHRul1qLk7e1l513Luz8M6F15oerzrMam1cZy99m+a/gDqRFiDWXU1hQ/KPHqvka0+AQtXdpwQAZa+LICjp/+Dt5LdyfoovT42SiEr5a+eCkHRfJ7EANWUa4u1XF50F/QUzQ8KdS+Lv6JmWdPt2tL8oUHiUoBXQzZssVtJ1TgtEZ9IBN8P33UpmEiwhI//W7fXhvHCFHDmnU0d/6WSj0x1repUsht3ppz928eRd5rYec5nti5qp7zY40t3afY90dOjgLep2cO1qScXdf/HFL/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (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=d01MS5Ue/SUAYQwAAGRFoqPnpwVwUw5LXQKwJJmFc/E=; b=IaHH9ZGc/459cCqO6NF70blYqu8+9b3aVjDOu8rGYEKp5v/qCHOqLudVq1/nl/W39HdBiOnojKsnrXohCVjudMqxaOYkSaBzmXK7urbuktjnrz49D8kDMCCyq1PHwSr6aKdh/rcOn7crNGDpxzXerUws+SWc1pePoIw4DpEipFE= 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 , Michal Orzel , "Volodymyr Babchuk" , Stefano Stabellini , Stewart Hildebrand , Julien Grall Subject: [PATCH v6 1/5] xen/arm: pci: introduce PCI_PASSTHROUGH Kconfig option Date: Mon, 13 Nov 2023 17:21:10 -0500 Message-ID: <20231113222118.825758-2-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113222118.825758-1-stewart.hildebrand@amd.com> References: <20231113222118.825758-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343E:EE_|LV8PR12MB9261:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e75b07f-cc98-4ce4-2cea-08dbe496ee5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ppZtBsywqPPf2AklQ5Ct+xIRYbRQDuUroJW6mX5X/lhUWjWdk5PCJBikIGMww3q36LYlcUV9B39hJOU4qbxCGOvYgbazeGQlhuW4zkh2fzlQs/raxUuTbJ1rl2vHf3GeHvkXCmZB1wcx9iDBRveBYztMCWiTYbrEyGsOSooBcVwfdHY5f631HyfKpbtyLvI6C9RSIwvdca2Vmbr9qBChtlB0iemuZhPkuMYcTqMU6Rmy37E0MLiur/UyjPYS8VqGqZ88eK3vqM0PMnbzc/SYWabysl1ADbFV/xDpolqwLRYPSYmlk/40wzPhSueGVavyAjgcbfeOkrGGhelL6ZeULgWcc2dajb3f8i0hWiPupOyxs9UT4wURWHNtz/4ml+HNoR/sD1Og2Sj3POnRYXtKVvG3E55Zngy9YLNrR/CdkTOaU0R3wdk5AwgfODgPeyDbrPUBF9ZYwro/LnExL37Vpl1p1kuyR7hSI7DVIyMq/TL1QP74KsBGXVUGkBec+K6oycAWFsIlrny8Z1GgqQzVXhyLZ4ZGzbOH0nKYMpoDKUkczgfHhgntKQ5lZKXQqShIWwVPyc+Db796JoOjAMccm6k4ejPyyhCNMOEoQfnV0ns2szKs9RHjQSAp9fR9wrt6Cq1RTOlN0mGmSjw2/J2/SpBsGYYwHEQQj6SAs998pBzsbN5RIp2T8He+9NfFB7JbU8Da7Z/J+CmbsTd22fMHEs6TfREkXLlRsuNgw9RqvYhgzHJAHM3AjJVaD3Raplzmn1rUBm7w+uZ38CXIqv2Lxg== 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)(136003)(39860400002)(376002)(396003)(230922051799003)(451199024)(82310400011)(64100799003)(186009)(1800799009)(40470700004)(36840700001)(46966006)(41300700001)(2906002)(4326008)(8936002)(8676002)(44832011)(40460700003)(86362001)(5660300002)(36756003)(2616005)(478600001)(36860700001)(966005)(1076003)(336012)(6666004)(47076005)(426003)(82740400003)(356005)(81166007)(26005)(70206006)(54906003)(40480700001)(6916009)(316002)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 22:21:49.7455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e75b07f-cc98-4ce4-2cea-08dbe496ee5b 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: DS2PEPF0000343E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9261 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]) v5->v6: * no change 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 Mon Nov 13 22:21:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13454500 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 3DBD6C4332F for ; Mon, 13 Nov 2023 22:22:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.632033.985921 (Exim 4.92) (envelope-from ) id 1r2fJy-00044Y-QW; Mon, 13 Nov 2023 22:22:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 632033.985921; Mon, 13 Nov 2023 22:22: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 1r2fJy-00044P-Ns; Mon, 13 Nov 2023 22:22:18 +0000 Received: by outflank-mailman (input) for mailman id 632033; Mon, 13 Nov 2023 22:22:18 +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 1r2fJy-0003AY-5f for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 22:22:18 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20606.outbound.protection.outlook.com [2a01:111:f400:7e88::606]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1957e531-8273-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 23:22:16 +0100 (CET) Received: from BL1PR13CA0274.namprd13.prod.outlook.com (2603:10b6:208:2bc::9) by BL1PR12MB5029.namprd12.prod.outlook.com (2603:10b6:208:31d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 22:22:11 +0000 Received: from BL6PEPF0001AB72.namprd02.prod.outlook.com (2603:10b6:208:2bc:cafe::1b) by BL1PR13CA0274.outlook.office365.com (2603:10b6:208:2bc::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.15 via Frontend Transport; Mon, 13 Nov 2023 22:22:11 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB72.mail.protection.outlook.com (10.167.242.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7002.13 via Frontend Transport; Mon, 13 Nov 2023 22:22: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, 13 Nov 2023 16:22:10 -0600 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, 13 Nov 2023 16:22:10 -0600 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, 13 Nov 2023 16:22:08 -0600 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: 1957e531-8273-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VggPD7AhwUkVALtL09Xdl55REkb+/22vbgytgadPbfrBwdhan+PkHNUxKM+Gy+SEWOD3cxzsLLMZpcnWHQEJzpJz2wl7apiWKbaKpnAKrOPwe3GMnNGx3OvcyUH3U4PIEmeBexHaJyQ7cNiIz1yt+fNiW37vbkNxZesevCrn+Y1A07ZfSJ2ObGQNUxMeTlflUgab3nUhVmB5aB6GDidlcm+m5xVb4hI10yGiQ3vqCjCwAw8s/aV2WLm+eDnzL6J8UOirzz92cMyABXNpi4STBgYCTPkTTaPXNkvQ1yH5H5KlxNX44bo0WcsXEL52SDv21NjeBPZ8nQfTtO/Attv79Q== 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=fNIMjSozE0dwXJVr8jQ3TQDs77gzhEx6bGfEi4dxzAs=; b=D70ht+4F5YlCIq40qX/7I4LqqBXuY7fa6aQLXqIu8NVqbVHf2QHZcZBxelq3cn2+PmbQdRA2VkuTm+FbiGj4N0HV4UDvFaEOiT9pRVH4rPtFNE9n/RL77XgbN1uAVR+RmgbtZSp2yQkpEC15tLEoFq51DrLD6PthoGozKlXDUAMmrU3W2lxag+9Vzj0Y9XOGlYCz7CJCD7nWdhLxT1NtorPB8JZcT/IzRUtoI0p4RDrjjWyY3lt+i/7xOkWuk3d9Dmfdgb7Y3VCPzV4iwBw+oX+fnbzShr2IhCLou97qJJXtkJ2co6zlGU5oF66gy/td5DsikJwKY3KfBbi7Ji6djg== 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=fNIMjSozE0dwXJVr8jQ3TQDs77gzhEx6bGfEi4dxzAs=; b=s6KzZWGj3EQrThHLHyDkvxuS1tOCQsb+3QuQ5JdHOc4SY/bnfcyJ6tC/kH+mDChkLYj5oEjioya7ZigC51tZMkMJA/0CRDRPPKwc5wZmBQy2Trge1ZBEbTyD5i6wH6t17mYW6n2o5sKhW4f5cdl5ng6Ooeg47B05AbEZ3wiPvNA= 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 , Michal Orzel , "Volodymyr Babchuk" , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Oleksandr Andrushchenko , Rahul Singh , Christian Lindig Subject: [PATCH v6 2/5] xen/vpci: move xen_domctl_createdomain vPCI flag to common Date: Mon, 13 Nov 2023 17:21:11 -0500 Message-ID: <20231113222118.825758-3-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113222118.825758-1-stewart.hildebrand@amd.com> References: <20231113222118.825758-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB72:EE_|BL1PR12MB5029:EE_ X-MS-Office365-Filtering-Correlation-Id: 256ccad5-bdb1-49bf-bc26-08dbe496faf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m4FPxN77zElnYqX6THjir1vRLy23Kk71q9SOsstASpchIjS5s0VVaBotScjh6TqR7E/xABLDtP7iNGMirEw7iT/eeo3NxNfkTARsYUiEl/aZ3NwntfwPusxxaFQjbhx2S546Y/VQBfpYLg0P4RlPdUKT2lAQMTcP3A+eDsjQpY1qTkOmggrzgr1o+cGJrcbzITWgEwl1xrg7y7pzWE4zwolDjoOjenyzrhZFUbjgzMuioysXH149cYfuoIkVawcTSIpFWpVCNJe7THglRL1n+bSYhtj2gUubtzcu8IoxkJ0lTd69sLoPRtWZS49b6hgUatCqeagn2MBeYnGzAM1RpdtDmHEz3rANd05JQKBFCfh0b0b8hu+EO1bxUlDYuC6N4jg5sM7QJbIvQ4iisJRDNIel70HPChlgmIz8+pw/MZTtIGL2uHrbfut/VqTPiAgTN5D620IKhZueBPgT0H7CqycLlLOEd/c+S52Kv+WIwmk1oDHGCg+Kc7r63y3jbSd32B+xFyfZAvQlrFs6kKwmNckeGzXuEJxBEKEDB6/NPQVOMYjHlSbAHYL8Eb+OQfu6OCFHhVcaSmyD/dYHIRXU5a8gGnCj7EoVE5fYpD/Ez035ZrXzJlzLRdBt6lfgZj3QEFw1NTTU2i1djIEJNhJUB7Pwa2HNTVIgjwy9H2Qm7gz5z5CmGKAD4JJ2IX4WiHA53R5H76EuF3szSEf0Yf3uPpEqb8GGKFhqKRftTZmzEoaxhKzcEp+6Mfl+nHSpNoP9zRMl8s4Qp/t388gZEukF0S59dqkVWiCGvxYz0/HXKHs= 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)(396003)(376002)(346002)(39860400002)(230922051799003)(1800799009)(451199024)(64100799003)(82310400011)(186009)(40470700004)(36840700001)(46966006)(70586007)(54906003)(6916009)(70206006)(966005)(478600001)(316002)(40460700003)(6666004)(7416002)(86362001)(5660300002)(30864003)(41300700001)(36756003)(2906002)(8676002)(4326008)(8936002)(44832011)(2616005)(1076003)(40480700001)(26005)(356005)(83380400001)(36860700001)(47076005)(82740400003)(81166007)(426003)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 22:22:10.9486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 256ccad5-bdb1-49bf-bc26-08dbe496faf9 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: BL6PEPF0001AB72.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5029 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 --- v5->v6: * don't explicitly clear XEN_DOMCTL_CDF_vpci where unnecessary * add comment about avoiding re-using bit 10 in emulation_flags * don't #define _XEN_DOMCTL_CDF_vpci (underscore-prefixed), only introduce single new flag identifier * move ( vpci && !hvm ) check to xen/arch/x86/domain.c * simplify has_vpci() 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 | 2 +- tools/ocaml/libs/xc/xenctrl.ml | 2 +- tools/ocaml/libs/xc/xenctrl.mli | 2 +- tools/python/xen/lowlevel/xc/xc.c | 2 +- xen/arch/arm/include/asm/domain.h | 3 --- xen/arch/x86/domain.c | 20 +++++++++++++++----- xen/arch/x86/include/asm/domain.h | 6 +----- xen/arch/x86/setup.c | 4 ++-- xen/common/domain.c | 10 +++++++++- xen/include/public/arch-x86/xen.h | 9 +++++---- xen/include/public/domctl.h | 6 ++++-- xen/include/xen/domain.h | 2 ++ 12 files changed, 42 insertions(+), 26 deletions(-) diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index d16573e72cd4..4a42b7231f8b 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -8,7 +8,7 @@ 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; break; case LIBXL_DOMAIN_TYPE_PVH: config->arch.emulation_flags = XEN_X86_EMU_LAPIC; 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..b9f559a8e637 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -159,7 +159,7 @@ 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; #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 5fb8cd79c01a..3614562eaefe 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..bbb73abe88a1 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -636,6 +636,7 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) bool hvm = config->flags & XEN_DOMCTL_CDF_hvm; bool hap = config->flags & XEN_DOMCTL_CDF_hap; bool nested_virt = config->flags & XEN_DOMCTL_CDF_nested_virt; + bool vpci = config->flags & XEN_DOMCTL_CDF_vpci; unsigned int max_vcpus; if ( hvm ? !hvm_enabled : !IS_ENABLED(CONFIG_PV) ) @@ -709,10 +710,17 @@ int arch_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; + } + 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 +730,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 +808,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..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..abb808c9060b 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -283,15 +283,16 @@ 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) +/* + * Note: bit 10 was previously used for a XEN_X86_EMU_VPCI flag. This bit should + * not be re-used without careful consideration. + */ #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..8b3ea62cae06 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,11 @@ 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 (1U << 8) /* 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 Nov 13 22:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13454501 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 5FF32C4332F for ; Mon, 13 Nov 2023 22:22:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.632035.985931 (Exim 4.92) (envelope-from ) id 1r2fKB-0004Y0-3F; Mon, 13 Nov 2023 22:22:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 632035.985931; Mon, 13 Nov 2023 22:22:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2fKB-0004Xt-0a; Mon, 13 Nov 2023 22:22:31 +0000 Received: by outflank-mailman (input) for mailman id 632035; Mon, 13 Nov 2023 22:22:29 +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 1r2fK9-0003AY-MI for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 22:22:29 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060b.outbound.protection.outlook.com [2a01:111:f400:fe59::60b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 20426975-8273-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 23:22:28 +0100 (CET) Received: from BLAPR03CA0054.namprd03.prod.outlook.com (2603:10b6:208:32d::29) by IA1PR12MB7494.namprd12.prod.outlook.com (2603:10b6:208:41a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 22:22:24 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:208:32d:cafe::de) by BLAPR03CA0054.outlook.office365.com (2603:10b6:208:32d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31 via Frontend Transport; Mon, 13 Nov 2023 22:22:24 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7002.14 via Frontend Transport; Mon, 13 Nov 2023 22:22:24 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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, 13 Nov 2023 16:22:23 -0600 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, 13 Nov 2023 14:22:23 -0800 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, 13 Nov 2023 16:22:22 -0600 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: 20426975-8273-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lzq7+w9eeVi0MDNWcd/TbsX0cDbhrqjyF84a3vaHANhNByj6Bmw7hdjkGDmCclZmtto9JT/BmzQud4XuVFCy/yGb1Lfng+sRYeDdS+HVaUomDBmFJlyPnFe10J9CSomI/TYSXRmH7T0G9iIP0azrbkl4091N9eNktMzPqAN3ONKZTrSx+si+K+I0CByWdjLPgmescn95E8YtFDPf5Sy18IdidDAkkfR3/wwfCUk7hqDJF9/BwekZdrdm6HlWk6NzX/1sHEMnuuG7ZxGlkvTLjJy7r+4qcCLzNLIJhjgl6NYTwYUgd5wRqCCUe/qbVlwYAhgH8jgeikwNB8odH/9f+Q== 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=gX7WDh6u+fUULoRtawIbVh/xTm5OKI1iE4k56R1o0i4=; b=IInU/aJ8Bx0VG8XuTwEW/3Hk1rGx8rIfkOZ74han9tTlVJhND8W4tV2pAF+uk7UZ4JLsf5hFRsILmhZ4loAz0t0PNSHPJTWiXkpeL+meSd8SEdjgabotolc6dHEhtDvbmv7GV+OUeTngk0yfagVhugvvq20s6RPUR2zgKDTYkyVNW0WABEGdeC4PuNO6j6DEfVozh6hFMBp1u8s+BcPOBxJurjfuhZYz5/XdFVfkCsjN7cpNMdRcfGMwHYeLYDKCga+hx4TvfY6Q5+uDDi4KYtECNsUfv3xzJ49AcJh2c+dZ884cxhtfS5z/GtTMA9ZLhCW0UEkrEygkvKqxQh3NkA== 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=gX7WDh6u+fUULoRtawIbVh/xTm5OKI1iE4k56R1o0i4=; b=Kxg2vyjmylkNJyQwo0URGMR2qpoljCw9DJJ+/uYcudilAEda1bbUB/Gx8rPf92Gmq3yuERtVFPbSmqGsyvJxekE21HpgaHPK00zACii5woIva10o/ttbIQ5luzlu85oB1n2API+eL9XHlFBJjwh7J5BdR+MuwBdvsoG7S1z86uE= 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 , Michal Orzel , "Volodymyr Babchuk" Subject: [PATCH v6 3/5] [FUTURE] xen/arm: enable vPCI for dom0 Date: Mon, 13 Nov 2023 17:21:12 -0500 Message-ID: <20231113222118.825758-4-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113222118.825758-1-stewart.hildebrand@amd.com> References: <20231113222118.825758-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|IA1PR12MB7494:EE_ X-MS-Office365-Filtering-Correlation-Id: e1e1d82e-cff6-4561-b88f-08dbe4970301 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ArcVTITX0lOv9BuQP/9BFnA1HX7ts/MaOZu9ib4MxwSsxNDCdoXDnR4+mAGOHdjbd3H3p9NPgXB2A9qo17pWZIGqZRkuphHZSNLx69kMIxbB/IKCVUbNEVMelkZ6plmeYSF18Fhyr2ARinCYODGtlLlHwYNwDOXEAeQ55uQqd7ObEy+EhXGuxEdmRBfUt+Qe41/jPVX6eKDyClPdlbDzC7dPHBhijkvb3H+aF+30FsJ7FJVgfEE2Tnr9OqOKW8A/cD8nqk+tKPIfJuAbJKv4y37TqfQV1zpsFFDhenbSlrMhOnjo7wJH/h032lwJGd91zgXqEqn13fQqjXwwVi6F6/u1egzPZb0ha12vPiT5jWBaMROyY2rVZ7gRYEm4TccKUGSbdaGpxVnvhoddX1nGuIhPARsFZc5Id9bz7dMXufb941iW2G51W2M6T1yv1ukRoFGA7Ng2WfeR8OjK77taHtm7dmgFOflh6ybLkcnyZ8XlHrp8++uA/RwkkS6iiAW5V+wlp5NDiMETdIIAZ15AY+/RnxI8CF5zMjseSjVWAX3z8xAbWHe9qg7vOBSKNYnNslIKRMm68JC+9MG3hekHKiGrm6fu8nKzp//4PDSf9s94zmKJbc7kWuIbuQaT/CUJZSfkEArcdpb1mzRyBEpwW5QViATUz+rdiYvxlvbfA78LiayEVKbinlfDTtamxyqAcuRaRhNn1sByHBV/JFo1dkN84F2okZrZtvUBRICmhVgdLLh3N//xcHHxdy1DOK7oVgWlIKdtddGFbS6lgEXVLQ== 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)(39860400002)(346002)(396003)(136003)(376002)(230922051799003)(82310400011)(186009)(1800799009)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(966005)(478600001)(81166007)(6666004)(36756003)(356005)(336012)(426003)(47076005)(6916009)(316002)(70586007)(70206006)(54906003)(41300700001)(40480700001)(83380400001)(44832011)(4326008)(8676002)(8936002)(40460700003)(5660300002)(2616005)(82740400003)(86362001)(2906002)(36860700001)(26005)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 22:22:24.4227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1e1d82e-cff6-4561-b88f-08dbe4970301 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: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7494 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. v5->v6: * no change 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 2dd2926b4144..512b3c4c76e2 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3916,6 +3916,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 7f77226c9bbf..74816a687bbb 100644 --- a/xen/arch/arm/include/asm/pci.h +++ b/xen/arch/arm/include/asm/pci.h @@ -147,5 +147,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 Nov 13 22:21:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13454502 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 93C9AC4167D for ; Mon, 13 Nov 2023 22:22:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.632039.985942 (Exim 4.92) (envelope-from ) id 1r2fKQ-00057m-Ke; Mon, 13 Nov 2023 22:22:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 632039.985942; Mon, 13 Nov 2023 22:22:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2fKQ-00057d-Hu; Mon, 13 Nov 2023 22:22:46 +0000 Received: by outflank-mailman (input) for mailman id 632039; Mon, 13 Nov 2023 22:22: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 1r2fKO-0003AY-V2 for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 22:22:44 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060b.outbound.protection.outlook.com [2a01:111:f400:fe5b::60b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 29e8ae9f-8273-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 23:22:43 +0100 (CET) Received: from DM6PR17CA0032.namprd17.prod.outlook.com (2603:10b6:5:1b3::45) by DM4PR12MB7622.namprd12.prod.outlook.com (2603:10b6:8:109::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31; Mon, 13 Nov 2023 22:22:40 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:5:1b3:cafe::20) by DM6PR17CA0032.outlook.office365.com (2603:10b6:5:1b3::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31 via Frontend Transport; Mon, 13 Nov 2023 22:22:40 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7002.17 via Frontend Transport; Mon, 13 Nov 2023 22:22:40 +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; Mon, 13 Nov 2023 16:22:39 -0600 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, 13 Nov 2023 16:22:37 -0600 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: 29e8ae9f-8273-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWYClh4hTL/FLVAJFTI6oCEu7E7UlbLt2cet+3xz8nAmMh6AFk/+2TH9Pgq9S9xwcMrlnmx9S+mOc28NSQaIvCX8ZJlEprkR9E/2L8Y+5THM6TiqqYbPmQuW+jeSJ46BTdit5NX293Hn5Luo6QF5vc8fcqHB2oRou2QmCPXXJtumW+3b5dY1x4RRuNjhec3i2h57tkNWcI21ULb93RpvH7dxm0CUcAhBoiQA1UhRMwt+Tj1fFEsJuwEIawKjFOUpiIUWFAPM0wwpgKCIxiZMksqCZzu69IonNPhn+AxB4FAcI6h5CYA5sFcCqPE6LdB/pXwrL0HTzNEhYvT9i20yUA== 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=NRtH1sA7/5vWe50OKi+KB9WviVia/tPm/aYWYnTd8Ys=; b=IY0CTHoU61GvM+82obBMnaBPYGYgtycsHqlVgjE4BJ1fPk5gmTJvMYSLVqMltR+BT1XlyHZBXtFAYsMG12EBdBAPGJpYWalmjbLWxiyV6eMSdAn5yLEYCEVnZE2uL7F3Tua7oj+S8fXfVp/XJIQSF0/ix7+CSQ6cU23sijcHtCX9qpse98BM+hrDE8Z6tkNCNiqOdahhRGoPTrPfrchj9y3W9AKsRr8vLKoHWSQuAP5u6+gUOh6XZGW7aVr4Wr8/URBkxiqba4+E+MAIMTxPHIWs+McWBAOIX4LBcQUMcaDeYWhLWv7EFFqhIlwn6VnIXXgw4q5A3rzUc79Tyr/Qfw== 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=NRtH1sA7/5vWe50OKi+KB9WviVia/tPm/aYWYnTd8Ys=; b=kY7DFeCu1bag8WnRffkPNkDR/zU5IbA5Fgv5E2/gvG/vu025rPJ2iG2uh1L2dyH/18LmToY8P92vUM7ZkuDt+iVbDYNHTPh6g5h1z79PxETmYk5sJTF1GxdkcInxdkMDShICOMKk4lvEIOeT/zQ26OjCP2kpaKuYGKeTFfznY0c= 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 , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , George Dunlap , "Jan Beulich" , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Paul Durrant Subject: [PATCH v6 4/5] [FUTURE] xen/arm: enable vPCI for domUs Date: Mon, 13 Nov 2023 17:21:13 -0500 Message-ID: <20231113222118.825758-5-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113222118.825758-1-stewart.hildebrand@amd.com> References: <20231113222118.825758-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|DM4PR12MB7622:EE_ X-MS-Office365-Filtering-Correlation-Id: e78f6172-eba5-44e3-5599-08dbe4970c61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ApdUP6HIEY8XQhQyptHPBHF1ncE6dAnw/+j6FE+I5yBKeGSUaCb6QBffuFTHx4l5eqt9RLYY9SxVrG1JpXL6Yff9dw3YriJZbizIzxF4b7Kd4utKui7Cm0Ci+Nk1UfMKn3t7QqnV4/zqZSyubJMuPccyIuKAckFXjEhT9OAIF/GXqSG9hWCyGwuwVMAyXrLSRlKDHkcgHrqQY5zubW5WhUlIpx1E89+VybGkB6JU+Fyx3NghEkepKcSppuDk54OV3ZM5e+XWnAoS1LGFrh3KXJJ9hklbZOh8Z5mjyZicFDqK/nXYv6GH22fsxWGLA223t+BmkouCNmqIIj5aw01xvb3UOUGtXxLwMqcZD9mzAEimjnBibWhZntaBU9/rMDOqKvQF48+YM4/waf2cvetv3oItoTrLZzoSMbFy6pj1PwjU1wcSViPxuCKs4yTUybwkUKu/JB0RHpzz5IIHZ1kjH3wj+1HtZKUKISODjij1NJr5tQ+885ngEdCCdHkealUWPK8KRBoRxceK/ik4y8+3VC56k7GVb4fSYKwggBV2jh+0jABZP9Yuol4Il+Vhoa8TvtMqQ0BZp+fsIfddCTJMfrhs6LHCByE/XUYLbYg8lJS9nu+gJN2YlnVqO8bGaSN0dFvx+CxiIXtRbidADBz2Hrr/p+Yh6O7wnbj63nkxq95kcf+LRpAXiXls1G3aVC/o329EyoTovEMbB5ZDNJ34sveHlUXEhQ7xRIDCgibqATVPEC7UG2OtFAI1Mv8iZ0l0dPyxxyIQ2RohG4ehfLXJ3CjEta7L5RFRxaZv+Dilckk= 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)(396003)(346002)(376002)(39860400002)(230173577357003)(230922051799003)(230273577357003)(1800799009)(82310400011)(186009)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(81166007)(36860700001)(36756003)(356005)(426003)(41300700001)(83380400001)(336012)(40460700003)(47076005)(7416002)(86362001)(4326008)(1076003)(40480700001)(8936002)(8676002)(5660300002)(2616005)(44832011)(316002)(6666004)(6916009)(82740400003)(26005)(2906002)(966005)(70206006)(54906003)(478600001)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 22:22:40.1175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e78f6172-eba5-44e3-5599-08dbe4970c61 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: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7622 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. v5->v6: * drop is_pvh_domain(), simply make arch_needs_vpci() return false on x86 for now * leave has_vpci() alone, instead, add HAS_VPCI_GUEST_SUPPORT check in domain_create 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 | 2 ++ xen/common/domain.c | 5 +++++ xen/drivers/passthrough/pci.c | 20 ++++++++++++++++++++ 6 files changed, 38 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/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index 3614562eaefe..8e6d5fe9578c 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..d34015391eed 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -503,6 +503,8 @@ 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 arch_needs_vpci(d) ({ (void)(d); false; }) + #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) #define pv_gdt_ptes(v) \ diff --git a/xen/common/domain.c b/xen/common/domain.c index 12dc27428972..47d49c57bf83 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -692,6 +692,11 @@ struct domain *domain_create(domid_t domid, if ( !is_idle_domain(d) ) { + err = -EINVAL; + if ( !is_hardware_domain(d) && (config->flags & XEN_DOMCTL_CDF_vpci) && + !IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) ) + goto fail; + if ( !is_hardware_domain(d) ) d->nr_pirqs = nr_static_irqs + extra_domU_irqs; else 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 ) From patchwork Mon Nov 13 22:21:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 13454503 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 D8096C4332F for ; Mon, 13 Nov 2023 22:23:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.632041.985952 (Exim 4.92) (envelope-from ) id 1r2fKh-0005hI-Vf; Mon, 13 Nov 2023 22:23:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 632041.985952; Mon, 13 Nov 2023 22:23:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2fKh-0005h9-Sn; Mon, 13 Nov 2023 22:23:03 +0000 Received: by outflank-mailman (input) for mailman id 632041; Mon, 13 Nov 2023 22:23: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 1r2fKg-0003AY-Vd for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 22:23:02 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2060f.outbound.protection.outlook.com [2a01:111:f400:7e89::60f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 33f74631-8273-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 23:23:01 +0100 (CET) Received: from BL0PR02CA0070.namprd02.prod.outlook.com (2603:10b6:207:3d::47) by IA1PR12MB6042.namprd12.prod.outlook.com (2603:10b6:208:3d6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 22:22:56 +0000 Received: from BL6PEPF0001AB75.namprd02.prod.outlook.com (2603:10b6:207:3d:cafe::4a) by BL0PR02CA0070.outlook.office365.com (2603:10b6:207:3d::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31 via Frontend Transport; Mon, 13 Nov 2023 22:22:56 +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.7002.13 via Frontend Transport; Mon, 13 Nov 2023 22:22:55 +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, 13 Nov 2023 16:22:53 -0600 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, 13 Nov 2023 16:22:52 -0600 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: 33f74631-8273-11ee-9b0e-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fxjqhUtRdNSsue6WKx5PE+QP0EGEUYU85GIElfpcJsiU+Lgz5GcxruZnexjKdm0sI9CzghpPKYgeJSyQdG13mBai09ll2pM+/ZhUqyZhp/vKeymkmETCls8L//qBRblbUEFIm+fy7HoU0pTxoAzjyr+qfQk20TFLmCGcTUGPSTf9BE0bnvpOMKo7E/uigFuHjDFy9HcjbovaLr+nneGgcF1qAYxKzTf4sFXflYEcgMA6zS0Dsi+5e8onwVt+M1rQ/OiP651qcrOWUxJBcWOnmSk/tKo2kufyZHwYd222uMk++DwgrPfuCXQK+Z5/j4xRc7GTMrZw6mks6hWwRw9MWA== 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=V1ygEMRNlCIyFbC9uBsJtxb9vimpr+FuY6Zv4K74hIw=; b=GT4uKT7Bln/91OJY9+eTYzRqT4zElnQjFNoCQHlZNdpYqM22QX5tywYeVdNyGj6Uy5evBL6IpI3NuLwKdN/fbjEnCnMUt4yVich+EXDrZhftwbqD81s4Ig+CM3hQjRYWko0DL1aBxQFsWHTSOrXkgJfIgZGjWpjJl6pjxBvxivnCu2jUZqDw1PIbYGuKSzEBPCeRkFJW13ESqvmd6VXI9rKhqE7MzsvagG7s53kQO95Yk5jiO33GkINjm4Q2sMAcYTn3SSO1MDsozZw/l14GttLqjvm+6+32jQvrKrNAtGo7hX3ZfV00fhYEA/C8ev5gsAdw0NuQcY1FvPGz6oR3gg== 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=V1ygEMRNlCIyFbC9uBsJtxb9vimpr+FuY6Zv4K74hIw=; b=oLlpepXzkqkkoNms1hpbu1yFgFdUysSPmiOyqRoPSjQKphhbjhWGz5Ix9+Bx5YDyDnWbgG2/rrNpNAxgk+/fGy/mFGQQY1PGWvt6x5LIzOq1EqnWpbSmDCfcIo45RZxCQREgWMUCuzhpsRwURCzvDnBsSWZM09A6Mx+PymXZQsk= 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 Subject: [PATCH v6 5/5] [FUTURE] tools/arm: enable vPCI for domUs Date: Mon, 13 Nov 2023 17:21:14 -0500 Message-ID: <20231113222118.825758-6-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113222118.825758-1-stewart.hildebrand@amd.com> References: <20231113222118.825758-1-stewart.hildebrand@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB75:EE_|IA1PR12MB6042:EE_ X-MS-Office365-Filtering-Correlation-Id: cc4e231c-d4b9-4b9c-3899-08dbe497158d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gVcWFUd6BeU9Kw00LyP/JHH23ye9MWx07xdwzPhJSm/kc0IetilhCORNQxNpUCZ6E6Z25eRn697zCnN3ooSs6Fhm1MzSHTbH5rSlIw0/YmP+j8eSIRiL5m9Ep2TGCLko7kWTVeE2AHjwXA8MMj2bECUP2emlEbZNI6AIUxc3hbdnuk4BxmEEar8NBwIVBrVYURU9Nr/kkfc2UqtAeGnH5dQvYsziWMAMiI7YIbT/SAiErBBlTTIgHwhiH3n2iHohaJe+9RQpmhB2r+riyr0bHoIdoAPRDZK+HpTo0hc7dPCc5zg9gmvuTYkmArURWbTlMS+rKnTaYN43EnCqUjnoFDavE9tUk9ykbx2buwpkQ47npayEXQgi9qbbSmSRnOwEq0QzYnzhw2U5LjwORLPe/1/bcYehkVrULHwfWt76v+2JUZ6bpCfAtUJ6QV8ZZWspobFs1S+mi7UWf5xCL3tYderClAMuWfy45WAM8PuJjUDc/VhfCEO4oOrOjv25lkWH6B2aelE24+wodJ8lTPWUUO+NM+o22moNCjud97Q3yqlqt1+yWcuuQFirEf4nymni924/A9RwSLtunHemJRV5J+cpMYqAfeQX0dxirVDnap9L2VNeMh6Vs0RpTbOhED9X2tW6fpMLdxG9v19/ey+YU9Sa5IYMBi8zCoiJT1RCQc/3XM29PcFdGjdt5S8qptKWPcLuoTgp7fGH84zpmoD0DY8TmOF9Q1frYHKmP7uveE88WuMPOHxGAGIF6vRZDrYV5Gc5X/E7OQOqr0wSYzACJA== 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)(136003)(39860400002)(346002)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(82310400011)(40470700004)(46966006)(36840700001)(40460700003)(4326008)(8676002)(8936002)(70206006)(316002)(70586007)(6916009)(54906003)(41300700001)(44832011)(4744005)(2906002)(86362001)(5660300002)(81166007)(47076005)(356005)(2616005)(82740400003)(426003)(336012)(1076003)(26005)(36860700001)(478600001)(36756003)(6666004)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 22:22:55.5359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc4e231c-d4b9-4b9c-3899-08dbe497158d 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: IA1PR12MB6042 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. v5->v6: * no change 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; }