From patchwork Mon Mar 31 21:43:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 14034146 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 CF309C36018 for ; Mon, 31 Mar 2025 21:43:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.932996.1335046 (Exim 4.92) (envelope-from ) id 1tzMuv-0004k0-FB; Mon, 31 Mar 2025 21:43:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 932996.1335046; Mon, 31 Mar 2025 21:43: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 1tzMuv-0004js-Bt; Mon, 31 Mar 2025 21:43:37 +0000 Received: by outflank-mailman (input) for mailman id 932996; Mon, 31 Mar 2025 21:43: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 1tzMuu-0004aC-PV for xen-devel@lists.xenproject.org; Mon, 31 Mar 2025 21:43:36 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060c.outbound.protection.outlook.com [2a01:111:f403:2009::60c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 31c8e539-0e79-11f0-9ea7-5ba50f476ded; Mon, 31 Mar 2025 23:43:34 +0200 (CEST) Received: from SJ0PR13CA0043.namprd13.prod.outlook.com (2603:10b6:a03:2c2::18) by DS0PR12MB6608.namprd12.prod.outlook.com (2603:10b6:8:d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Mon, 31 Mar 2025 21:43:29 +0000 Received: from SJ1PEPF00002314.namprd03.prod.outlook.com (2603:10b6:a03:2c2:cafe::a7) by SJ0PR13CA0043.outlook.office365.com (2603:10b6:a03:2c2::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.20 via Frontend Transport; Mon, 31 Mar 2025 21:43:29 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00002314.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.8606.22 via Frontend Transport; Mon, 31 Mar 2025 21:43:28 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 31 Mar 2025 16:43:27 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 31 Mar 2025 16:43:26 -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: 31c8e539-0e79-11f0-9ea7-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nqq1WQU3eeueK8dcfyvh31KoJB/KwqrRA8bNDZJDYGnbFS0+cOsS6qm4eZUqJpXyIOtLu++HNeX3fG7+bXIEky7ITBs0mM+MsC2TQlQD9teI47AtxZ0QRqsAOJRBrO/jLLUIdYePTBK4mS4IOMB6kxqp8iFh+HhzeCp+lMoZ6qkm+3KjKnh/ybdaqWMZS1/8+UwSo7uSkDn9A81YmRCsuJ8GznL3BFasZgE16YE/vr4P9BZcTnqnJ4yd2CfK05/Luwpd70h4H4SXT5MDKwOMkqhhj4066kFEwdmrGTqzRXUUhKq0eLd5Wzz5+qLHNiT/mYdH6rGaUUGdQw1gNT27Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q0hX3MCb+pXj1x8o06lhrPKBbpxKlpmGAl267NUETHw=; b=QZkLbHDZroI64xHcr+LEXSCGUeM0zv5FmQRu/31riRTi/HJMA0Rh9N/jbSQ3W9sIDHKmKUHZzKq8gBnmzLyCU/O7YmeaspMz7x4Ba+zQX8Wywl+4p/9L5Hq7e1sBegCFk+CAWOLQsaDgPWaUAmMTKTtZYT6lQXKgpVaTECDkVqRVUazw29IxTSrI3DPSgAa2DMwOpocmiXqoYcfPxGl+Dzi6BdbVr7+2o3FMqo3OtUv51NWIlSasNOmd+8u4qumsVvhsnc7jt3d/kBENlK7PfJbn+eEH0DsV5AvOYZFatdGo2DiUR+IpqkRssnUaEWkjzDnNU50XnnJCIlLBLoReKA== 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=Q0hX3MCb+pXj1x8o06lhrPKBbpxKlpmGAl267NUETHw=; b=sxyzwyrZfoh03drI/ibdRS5Ozpb6mw0w+FA8TiE+iU00YaQSTg1DGV7WqLFXWBtq0PdCqocxLSXMAHe0GxzHZhgOpupOZeg0kznLvZAfNftATi8qNVVVKBRcdYiydF9mvlRovtUltEVTWFujRdYQFSrp/liDv3erecB8nLDrSrY= 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: Jason Andryuk To: CC: "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , Anthony PERARD , "Jan Beulich" , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Jason Andryuk Subject: [PATCH v2 1/6] xen: introduce hardware domain create flag Date: Mon, 31 Mar 2025 17:43:16 -0400 Message-ID: <20250331214321.205331-2-jason.andryuk@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331214321.205331-1-jason.andryuk@amd.com> References: <20250331214321.205331-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002314:EE_|DS0PR12MB6608:EE_ X-MS-Office365-Filtering-Correlation-Id: 02aeb4d3-79d5-41b0-d0bd-08dd709d12eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|34020700016|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: hvZECFTcQVbns7mR5kGAgcKD1Pd/HNuUci6HIF18OJn20OokqNjMkioEkQrwRWVvGF3fbcr7wdtsgjaWoqmU7qRyG8re6niitceYy4QQsASlnexURItFVnfoKv5mVu37srDEx+shE6siCjSDOtUB9Ko+NhpmydSCBfIotEMitqqtfbH6ytiz2Dm416SCdTYlH5LhpXwxwHGVBmQsMcdk/0tS2XsjVEstmk8jfWkarA7Zy+d/s5TqRoosuKqURZWc366+DwL0pMkJBMmCFWHXkdhdaoKquCe2NvrocGrlzyv8X43LfIbSA5mVIjsenb2p69a8UMaJg96ZecRYkN6RPCoUMPEuRt1CPjTFY3vn8U3Q6tjbzq2uNIniX/GGrvnCcwUCgOLq1pD2lVIQDhCo/dL6pzm8LYQnnj1bQg5ifw3YES7Cj+qBu5xQJxhvUG7mqTvgZjoSJU7088aP0NfSisMxZ5mdqGmusRopcrIhlC6AcjWPjC4pb7njtKSlQ61xuYWm0S4/qSCJY+nWmIy9Hiq1WPVRXBfDbTXEJjdegrT93+LCeN1FmelVDvxghVn6wyHWX+6jVxlHxor8pivYgdpAXo0thh0bUXvnpsbNS02rI/ooX68dpTQsKxsIXW8PEVqB2c/AUci8tcFkhPOMI1cdxUaPmnzOhqco74czQD7cPtDBbUH1giEhOy4WHHy8SiJLjCeTtqs+CXrdXWvzSUJW5X5BbP1mhoKdBGCQ8dmoHfIcIJjzRM35/1Yvm9Pz/FDZewCZF8lozY00KG6l+eQGn/POSHN6/uhbanfdIAzEpZJIJvAK/jWxsvpiQppcq+7fc1d73mKNgUDK3kx9uVBeZ4GW09qTQ7gktC9EYQw+aMtVZAZepW0ZvLnQvU61iel37tsNRjg8VGjQFNuWw9TTdvhXfDFc7uNjs6GCAWpicnjssrBZYcyrnGNHrPXNaGJwWaYIGbJSCehEmwTA76V95Bv17Jn+VxfoCs39wNYFb5ULUyjfBDUtXUo7cAlOmMuqDeQbzT0+sSMdRN6YhkEo02mUmDys6SJE0TV820+gyNz3yq1R+EeQSJyne3hBZ+YBFcfaMo4XJ0fp+ylirOcwMMiU4cI0RlSsASBsOBIGCeWOYr0kYKnBXeLotXTtiFvfImKdlwjTjM7gmsOcp9Vp8G4aWnlJRH5tkKoyiShWkNywRRzWIzOebBvmLjD+r8/YZOJZEUG4Q0S2uLcaaclCNRluBMAWzIlrwjok0QXVPwRGbcUckY2w5sg9ryghLzGpDvqzKNN+hmYhfEOutK4Au8PmGQw0P4EpqraH1fhUUm5Cu4Al4jKO1dQDE47nK9rgRhJcGzGIrs0zpU99+Hdcb2MjZyW9wVyzyXC59RawDoryKj/dRqp0GFHN7DwqE/KID29jGdUpHcSf7WTUbeEsC/jpUOMcmP/zJZeHPTLfBwZIEOlse6xI6Fl+NmnR/8G1HHR+KwSqcEXE8vVf9Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(34020700016)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 21:43:28.4536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02aeb4d3-79d5-41b0-d0bd-08dd709d12eb 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: SJ1PEPF00002314.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6608 From: "Daniel P. Smith" Add and use a new internal create domain flag to specify the hardware domain. This removes the hardcoding of domid 0 as the hardware domain. This allows more flexibility with domain creation. Signed-off-by: Daniel P. Smith Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v2: () around binary & Only allow late_hwdom for dom0 --- xen/arch/arm/domain_build.c | 2 +- xen/arch/x86/setup.c | 3 ++- xen/common/domain.c | 6 +++++- xen/include/xen/domain.h | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 2b5b433183..051c48329a 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2366,7 +2366,7 @@ void __init create_dom0(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; - unsigned int flags = CDF_privileged; + unsigned int flags = CDF_privileged | CDF_hardware; int rc; /* The vGIC for DOM0 is exactly emulating the hardware GIC */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d70abb7e0c..67d399c469 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1018,7 +1018,8 @@ static struct domain *__init create_dom0(struct boot_info *bi) /* Create initial domain. Not d0 for pvshim. */ domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + d = domain_create(domid, &dom0_cfg, + pv_shim ? 0 : CDF_privileged | CDF_hardware); if ( IS_ERR(d) ) panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); diff --git a/xen/common/domain.c b/xen/common/domain.c index 585fd726a9..b3eb589872 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -820,11 +820,15 @@ struct domain *domain_create(domid_t domid, d->is_privileged = flags & CDF_privileged; /* Sort out our idea of is_hardware_domain(). */ - if ( domid == 0 || domid == hardware_domid ) + if ( (flags & CDF_hardware) || domid == hardware_domid ) { if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED ) panic("The value of hardware_dom must be a valid domain ID\n"); + /* late_hwdom is only allowed for dom0. */ + if ( hardware_domain && hardware_domain->domain_id ) + return ERR_PTR(-EINVAL); + old_hwdom = hardware_domain; hardware_domain = d; } diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 83069de501..9be18d16b9 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -52,6 +52,8 @@ domid_t get_initial_domain_id(void); #else #define CDF_staticmem 0 #endif +/* This is the hardware domain. Only 1 allowed. */ +#define CDF_hardware (1U << 3) #define is_domain_direct_mapped(d) ((d)->cdf & CDF_directmap) #define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) From patchwork Mon Mar 31 21:43:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 14034144 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 745C5C36014 for ; Mon, 31 Mar 2025 21:43:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.932997.1335056 (Exim 4.92) (envelope-from ) id 1tzMuw-0004zG-RS; Mon, 31 Mar 2025 21:43:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 932997.1335056; Mon, 31 Mar 2025 21:43:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzMuw-0004z3-OF; Mon, 31 Mar 2025 21:43:38 +0000 Received: by outflank-mailman (input) for mailman id 932997; Mon, 31 Mar 2025 21:43:37 +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 1tzMuv-0004Vr-CD for xen-devel@lists.xenproject.org; Mon, 31 Mar 2025 21:43:37 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20616.outbound.protection.outlook.com [2a01:111:f403:2009::616]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3255c74c-0e79-11f0-9ffb-bf95429c2676; Mon, 31 Mar 2025 23:43:35 +0200 (CEST) Received: from SJ0PR13CA0045.namprd13.prod.outlook.com (2603:10b6:a03:2c2::20) by CH3PR12MB7618.namprd12.prod.outlook.com (2603:10b6:610:14c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.47; Mon, 31 Mar 2025 21:43:30 +0000 Received: from SJ1PEPF00002314.namprd03.prod.outlook.com (2603:10b6:a03:2c2:cafe::b9) by SJ0PR13CA0045.outlook.office365.com (2603:10b6:a03:2c2::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.20 via Frontend Transport; Mon, 31 Mar 2025 21:43:30 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00002314.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.8606.22 via Frontend Transport; Mon, 31 Mar 2025 21:43:30 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 31 Mar 2025 16:43:29 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 31 Mar 2025 16:43:28 -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: 3255c74c-0e79-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OQk1v3sz2qJeiZigHQudTSnn6T6p3Edp2cYSHA+hO9jnlzuOQKrsRNS3pkWUCFNZsVxV+8DKJJ8PD5NXQlBWMMnO8DoUa4YsOnNMGXE85MXGHAgF4XGvgXPCYMk096nTiDizZHuYwEf4ibbQE7uMIGTQOniAcMJ24CmKoiHhdekhXnguFDmixh03CGaTe9E22+SwskSbQJULRK9bLR2X8tjWF8wPLdbEiJ1BTxTYcTwP1Waysd7MDJgUfXPQJzVerf431K0HAaSfES0fFcK/K1oOxCfE6AeDGctYUBDH0+dwa2cuLjQ4qbVH/wlGR9AMmXqRf0pDh4nTMESWkogWUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4vl8Wpz8L2rcI/9x1YYhQCkm3Y97kmSSKSN0YHgP/Xg=; b=qyXHnB7Es85tEHpUKRahEpa7RM7Y/WCtX/7nVwKoILTmQ1/bQTVyzo+z1P7FIIStAdBa3mBhIzRAQi4QVwbI14cNvzDl2uCwbgj1TDZXKwvRvJ8zElusV5YXuyORppRJBlJvd5PeFUgH/t3Wdw3wpFI7bNMIFQ67I12PelXywj+0Xb2u3ZzlZCp8Dth9cGRqDS5Z+IIOSnO3HdpcHjWiBtFiQwcA7JyRio23nmZcCUZTClajZz9ZQhTPIYWbVPJDcvOx1KMrdwjbvO4JsoRhjymu028thxaRYmcqARaYPzVB4evcrFFUGlhhu2Np7E0ThtFJTCybk2/7WqlujdGYvQ== 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=4vl8Wpz8L2rcI/9x1YYhQCkm3Y97kmSSKSN0YHgP/Xg=; b=3/9h10hMms6wBPtd+Tq4N0ihvbygJe6PikXmCTT35HpkoFAT9YaJtKy3Nm1kOLEVnCIoRl6YDVQzzQ1U+7/2PzmMWkTuL2zehLZHiVYa6ORGTOgapW1R1GrZXtxlVaxXtr5YLpIt19AqaU+nDWP0su7jS3EBbWGDm99mssYTaZ0= 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: Jason Andryuk To: CC: Jason Andryuk , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" Subject: [PATCH v2 2/6] xen/arm: dom0less hwdom construction Date: Mon, 31 Mar 2025 17:43:17 -0400 Message-ID: <20250331214321.205331-3-jason.andryuk@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331214321.205331-1-jason.andryuk@amd.com> References: <20250331214321.205331-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002314:EE_|CH3PR12MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: e227e2b6-b178-452f-8ae4-08dd709d13e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|34020700016|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: IXbUr6XG58lRFs1ssTvJ9gu3U6jGdNCnbryQKQORAVJ1A5y3fx9cefcnz0vc/nk2Szdmu3AWORSxNSUxnxN44/cNNMPKTbJeodlIkGCUzG4FkCcM8bCvKHxK36maOm8ozG0SMFkIQFZVALQq4f8zBHVwRSGSVUlMeUbTVrWke/S/NSnntiTLTCy4IdKUtuB+NJCXLttzWooQs+CPHXJ+TYDyCqCS7nNSNeD4s9IkczcWPPQ/SpVRCeaO5C5HwkrCft5SJ7/CDh15DIZIleiSf+cPCG3xkJTOyEEQPla2ltVK/4r7THubSpmaFXmVru8XDbHKyfUEEPfq8syID0yeZPqo4FSqQ0S1Yxx0eMEpvGGr05juqApYa24rDvWu/SsyZtpBrcq3M8RS2C6qUXyd2Tzjrio9DJy0iJpkhyNMa2tb+ufIW3UR4enWaI+ySae03FiuBOI58zfl0cvjUK2+AkCpKbRCgSgqZpTs0aR9IZDeo0ZFrXsPXrsLFn3q9D+1lOfPaoLSgAfRX/6vVVXQAIW6X9JARr7zasXVnbHoAyfXaS2PyInVn3RLuHvQlfyxMx2Zk4x3e0BYytkezEQpEmMr2kIvOpNKN1rCbWleaUQneuC5uirsYT81LG8ebYFgsHKFcrFVToSKF0PZsA6SfdzCw6+3inTuW8VGJ+ZZijK5rdLQY4jPLmpEEFkz5mXQZ8MrrMbFJDZgKG6HyimocVIxTFCUTL+9JWSeK9qbvkBjXAgm6fUVG1gy3CdaCPsfikb+vvxp3ejJMO2FO/KK7DlIDemn/pvWgAcgQPesRJybr+ntGrV4e0pMLGZOzmBWHRD6Q1ewu2R7rEjMg0CzHfjcnwHfFaesLbNYOppi6d51OV+MM79ES7MePN0lD/w9CcpdcGDKQJqjkudZbicbh+SsEteGSshhiGp2DFYSy5yz1ywUtBWsZ7yPrL6N2L9jsgsH6+Sg7ozPZ1xFSRhqPtu3+eBsgbGB/csttN0ogQBW8ti9AR2zp8Kzd3ITx5nhneeZ1m53PSWrnw9k8NEpfsZPJhbxyaWrsxPzmlF4BzMnucdziSSmyI3/fLkAlfvyDWMwzzl2ZYs5XPvheuRmZXEz3gfCdMWJhX6Bk6SI0CuPPBTOWDkdGcj3XUaBCSklNcIBLyJa9OyCAMGZmrMO2tV6Q4zRIiBSN0rzC+/Y0iWBAudcz476iGUhOYvCo5rZ4uqI5Jw7GQhsskL3H3pzcWVFV41PiYwhGvvwdE6dW47cy1nXlzPeqEzQR1vNoBlmykZuURdxpNP24bsk5pHKkWA6CKuW0pFU17H1PDq/pxIabmuUOnrEKB704VL1gkgAwdCXWv2ckKdczsZg4VhYXO+iM4KPgzgX8GPELC7UsxKbvvHaxya2lctLF465oHjTns+mze8hGCcPDSFWObXIy1fyG+9mOuuk6bEGRm4S6XXN5dEmlutzRkk4rvYoW2++n3Vbu2bqVbrho2sV6Ub2PSedG3ENRnPhKixQ50kC59c11wjoip5EuJPLju7FQPXM X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(34020700016)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 21:43:30.1099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e227e2b6-b178-452f-8ae4-08dd709d13e8 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: SJ1PEPF00002314.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7618 When creating a hardware domain, have the dom0less code call construct_hwdom() which is shared with the dom0 code. The hardware domain requires building that best matches the dom0 build path. Re-use it to keep them in sync. The device tree node of the dom0less config is now passed into construct_hwdom(). dom0 uses /chosen for process_shm while a hwdom will use the value from its dom0less device tree node. Signed-off-by: Jason Andryuk --- xen/arch/arm/dom0less-build.c | 57 ++++++++++++++----------- xen/arch/arm/domain_build.c | 10 +++-- xen/arch/arm/include/asm/domain_build.h | 3 +- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 573b0d25ae..e25d7bd468 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -911,36 +911,45 @@ static int __init construct_domU(struct domain *d, /* type must be set before allocate memory */ d->arch.type = kinfo.type; #endif - if ( !dt_find_property(node, "xen,static-mem", NULL) ) - allocate_memory(d, &kinfo); - else if ( !is_domain_direct_mapped(d) ) - allocate_static_memory(d, &kinfo, node); - else - assign_static_memory_11(d, &kinfo, node); - - rc = process_shm(d, &kinfo, node); - if ( rc < 0 ) - return rc; - - /* - * Base address and irq number are needed when creating vpl011 device - * tree node in prepare_dtb_domU, so initialization on related variables - * shall be done first. - */ - if ( kinfo.vpl011 ) + if ( is_hardware_domain(d) ) { - rc = domain_vpl011_init(d, NULL); + rc = construct_hwdom(&kinfo, node); if ( rc < 0 ) return rc; } + else + { + if ( !dt_find_property(node, "xen,static-mem", NULL) ) + allocate_memory(d, &kinfo); + else if ( !is_domain_direct_mapped(d) ) + allocate_static_memory(d, &kinfo, node); + else + assign_static_memory_11(d, &kinfo, node); - rc = prepare_dtb_domU(d, &kinfo); - if ( rc < 0 ) - return rc; + rc = process_shm(d, &kinfo, node); + if ( rc < 0 ) + return rc; - rc = construct_domain(d, &kinfo); - if ( rc < 0 ) - return rc; + /* + * Base address and irq number are needed when creating vpl011 device + * tree node in prepare_dtb_domU, so initialization on related variables + * shall be done first. + */ + if ( kinfo.vpl011 ) + { + rc = domain_vpl011_init(d, NULL); + if ( rc < 0 ) + return rc; + } + + rc = prepare_dtb_domU(d, &kinfo); + if ( rc < 0 ) + return rc; + + rc = construct_domain(d, &kinfo); + if ( rc < 0 ) + return rc; + } domain_vcpu_affinity(d, node); diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 051c48329a..b3a396c2fc 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2305,10 +2305,11 @@ static int __init construct_dom0(struct domain *d) if ( rc < 0 ) return rc; - return construct_hwdom(&kinfo); + return construct_hwdom(&kinfo, NULL); } -int __init construct_hwdom(struct kernel_info *kinfo) +int __init construct_hwdom(struct kernel_info *kinfo, + const struct dt_device_node *node) { struct domain *d = kinfo->d; int rc; @@ -2325,7 +2326,10 @@ int __init construct_hwdom(struct kernel_info *kinfo) else allocate_memory(d, kinfo); - rc = process_shm_chosen(d, kinfo); + if ( node ) + rc = process_shm(d, kinfo, node); + else + rc = process_shm_chosen(d, kinfo); if ( rc < 0 ) return rc; diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h index 134290853c..17619c875d 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -13,7 +13,8 @@ bool allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size); void allocate_memory(struct domain *d, struct kernel_info *kinfo); int construct_domain(struct domain *d, struct kernel_info *kinfo); -int construct_hwdom(struct kernel_info *kinfo); +int construct_hwdom(struct kernel_info *kinfo, + const struct dt_device_node *node); int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit); int make_chosen_node(const struct kernel_info *kinfo); int make_cpus_node(const struct domain *d, void *fdt); From patchwork Mon Mar 31 21:43:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 14034148 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 3A405C36014 for ; Mon, 31 Mar 2025 21:43:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.932999.1335066 (Exim 4.92) (envelope-from ) id 1tzMv1-0005I4-1X; Mon, 31 Mar 2025 21:43:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 932999.1335066; Mon, 31 Mar 2025 21:43:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzMv0-0005Hv-Ur; Mon, 31 Mar 2025 21:43:42 +0000 Received: by outflank-mailman (input) for mailman id 932999; Mon, 31 Mar 2025 21:43:41 +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 1tzMuz-0004Vr-3d for xen-devel@lists.xenproject.org; Mon, 31 Mar 2025 21:43:41 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20603.outbound.protection.outlook.com [2a01:111:f403:2415::603]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3444c228-0e79-11f0-9ffb-bf95429c2676; Mon, 31 Mar 2025 23:43:39 +0200 (CEST) Received: from BLAPR03CA0008.namprd03.prod.outlook.com (2603:10b6:208:32b::13) by PH0PR12MB8051.namprd12.prod.outlook.com (2603:10b6:510:26d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Mon, 31 Mar 2025 21:43:33 +0000 Received: from BL6PEPF00022573.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::bc) by BLAPR03CA0008.outlook.office365.com (2603:10b6:208:32b::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Mon, 31 Mar 2025 21:43:32 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF00022573.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Mon, 31 Mar 2025 21:43:32 +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.39; Mon, 31 Mar 2025 16:43:31 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 31 Mar 2025 16:43:31 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 31 Mar 2025 16:43:30 -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: 3444c228-0e79-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hqo1KS5nxhXXEPUvAE8o6FqElcZMM72DHlRXlYJlaQHRhfMjCpiUSOk2tO1QCZD+ZgONr6kDYysL9WDStrhhbHQu5tR9SZMgbnP1GrKbCdC7OYz54qTs/EDShVae7G9dwcaNR5UuouNCBg8+/tezNjb5cRpm/86aqeAJ3RPmQMngFOnrvX1BvBC2Vjne3/zXG2dSkKtEw2fBfA8dcfNhT3Tax0sGfJ4tJW1o4qzZlLrmSmd/I+1wVNu5sWucVBPYGtEM0IG24Tf9s/WMSEgK9UEgo75KqXKyy9Za2OPpwfclxqkRF55eNTCjHg8w52H6DQTeFSo6zSMj3kTmO5frJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=obPuKkWxG0z+mEVF9qf+2e+HKAoV+mglU8Qp/Nk6GDI=; b=P4f7Ty00OWA/alaYaSpIYmqZZqVV/ZB8xdl8O4+7lWQymYKwFmdV/jrveO57IOSqqz2ohUI6S+IFIBLjZ9NeVVNeotoLE+Mz/EJ0VqFvKfcxQ8WJHYP93hnxASfL2jau5Dcobmf37IlKBNpy9sRH+iT99yPftM727ygE7OHgeBogI7VuzSabDLJ+pSU1FPbbSqSD0Cfjc4S8sIgEvZKtzheOxyQwqHG8LeHRycCZVDAj6NcCmqJ+jnhteoMusOyhawXdcKmh5ibYJTguBaGgsFul2RR7glaMYeftJRX37nu8ZZZBHmKxZDa0TKi/gnEEShnqxwPAqwNTRzyqHAX5JQ== 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=obPuKkWxG0z+mEVF9qf+2e+HKAoV+mglU8Qp/Nk6GDI=; b=hLt1WjO2+VpqZTbzzffcgxtzhjGxeJ3ZZ/3c0JA1kIlTKhhCmW/WHuY2yGm8nDyiw6GwjiNuvzJPEjtzgE8MrDMVnGpbr+TXtlfEWW6/c+ob6L3mwWwXUtyZb6i7MHjv87rGr5CKVtiw0UwM/lofRf5L/8oTu1iSTyx051YiR+o= 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: Jason Andryuk To: CC: Jason Andryuk , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" Subject: [PATCH v2 3/6] xen/arm: dom0less delay xenstore initialization Date: Mon, 31 Mar 2025 17:43:18 -0400 Message-ID: <20250331214321.205331-4-jason.andryuk@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331214321.205331-1-jason.andryuk@amd.com> References: <20250331214321.205331-1-jason.andryuk@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00022573:EE_|PH0PR12MB8051:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f280073-b276-4295-8b26-08dd709d1508 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|34020700016|82310400026|376014; X-Microsoft-Antispam-Message-Info: KHQdASEBlfybq4TDO0Ghhrx1EijTSmnkl3QjnEVkEhxXepQqvU5GGv3NLn69fwp6mLgM62KIDdw5tV7uP3k8LhfuggBnlkPEAVH7aIZtov4eTFuio1atFe3lBPZIznNpH8jpwv2SBqXPTkoHrUDmARGdzVVHCXg+QKhBkSwG3tdbRDO5LKXxt+Sm0xn3SYBZSjdWSsKk5A3EdQNe3jVrFEgCuNDPf5VJnD4WinUJN5kh2g0A0CZV4Aj5bO4f7HMsc2hunrraiBsUdaWUgErep/t33v3OxmzdOuj+xmmjiOOGYhZ4pEX8LC3T8GXJvfa1q0mRdgxAw0TCwl52lq82IMxnhav1FcFX4CelSsdpDTqzLkro4y2GfQKqV//FiCjyLBIldEbS0X/azbE06f/cy9cMXi7cIuvuU452QuAzqV3Z1mXVBsDWZ2EobWyy15GfYWckoYHPm6X/5J7QXztb734wFJF/S9Bz2ex1A5pxQYYSlvHstZyYtQq0C6Nmw7mb0QXXiKbO1xutHbjmermsDbPR5dsX/QORwyf+dufAAKzJw6OLhHLiP8bdiKa3B4yHPeLifn2PAVgB/cGuz2nvEbKtM1PpUuQms5uccsVcrKu1oWFLw11T00EVQZKT6Pgc2i5NY71uMeaQkLqEQDxelRfDbFJC0aM9kzgPDM6xC7RV0uEZdVM7nB/NYMSfIYuPWBFNxn7BJlYS8zhpsFCDG0MTJz6vG0VV3uD99UfHL4eLjB5ouBOZPsjzKM5ZQK8TK3wSryI8wpucnPxS3W1/lVKKSZ13xZSQj6iJrfZs+If5sEg1SRJA3LtUM+77kPaBQdc614ob154pAyZO/7aU6sqhfuvFVgD/iycOxga3rhK7wjobqo6vDVgzN0O2O50NwnuBBM4MUJTVFIuWwDLm27+zq71Vj18+1DP3Iaek03jng1UozUlWv6z8oXZRacbZvxuc0mCGrZsCvYSw9emDmu0idBqdOS+aO30KGNWYfEQoY9/XkWOJ1nW+Gq2BC8+dKreM80MU4xKCJC3z4ZKjBdg0mKu7bncREyiaYB8Nf2pjd9RZloITIvwxmKpY6qWaSoE345AUDEFjl9Sq97rmrV7pCNpE8YG1MTpt4j+r58uk5k+aNiAIjCjV49MIbDTKef0XffZWIKtQKU9vy/SUGJIiwaNZh3hm0qGosJ58YG4tETpGsQNNwxyFWWCyYI9oJs06uOHGUW/IyxVqDswqQ+3eouSkg2P1Zs7DIbrciarPUmzMtyims9uNxdQhxb1X4tl/CpFO7KO1/OIKZUh88aAJNH5jb6Fh3a/67DobK1ZFtnzqc+U2fkFyr1s/yuIoQg1IUBPUCT3x1sKqFOq+AcILZUcx5KDVx7AaGqUpaRh3Kk4sQ3WIR8oH3kFa4UBh6JsHXV9I6yB7cHQUy7zClItDRB5S6pYLA/fb/LikTK7lt84g0e3fQVNgI/vHPjLqw5JhdesZ5xeKb6DHwzFJQgNbyp6H5T283vbTjxLv9j4= 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:(13230040)(36860700013)(1800799024)(34020700016)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 21:43:32.1067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f280073-b276-4295-8b26-08dd709d1508 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: BL6PEPF00022573.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8051 To allocate the xenstore event channel and initialize the grant table entry, the xenstore domid is neeed. A dom0 is created before the domUs, so it is normally available through hardware_domain. With capabilities and dom0less, the xenstore domain may not be created first. Keep the population of the page and HVM_PARAM_STORE_PFN in the normal domain construction, but delay event channel creation and grant seeding to after all domUs are created. HVM_PARAM_STORE_PFN now serves as indication to setup xenstore since the device tree is no longer immediately available. 0 means no xenstore. ~0ULL means legacy so only the event channel needs setup, and any other value means to seed the page. dom0 needs to set xs_domid when it is serving as the xenstore domain. The domain running xenstored needs to be the handler for VIRQ_DOM_EXC, so set that as well - it otherwise defaults to hardware domain. Signed-off-by: Jason Andryuk Reviewed-by: Stefano Stabellini --- v2: Re-order ahead of seeding. Fix created type in commit message Change set_xs_domid to set_xs_domain Set xenstore domain as VIRQ_DOM_EXC handler Signed-off-by: Jason Andryuk --- xen/arch/arm/dom0less-build.c | 67 +++++++++++++++++------ xen/arch/arm/domain_build.c | 2 + xen/arch/arm/include/asm/dom0less-build.h | 2 + 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index e25d7bd468..a46f292c1f 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -20,6 +20,15 @@ #include #include +static domid_t __initdata xs_domid = DOMID_INVALID; +static bool __initdata need_xenstore; + +void __init set_xs_domain(struct domain *d) +{ + xs_domid = d->domain_id; + set_global_virq_handler(d, VIRQ_DOM_EXC); +} + bool __init is_dom0less_mode(void) { struct bootmodules *mods = &bootinfo.modules; @@ -694,7 +703,7 @@ static int __init alloc_xenstore_evtchn(struct domain *d) int rc; alloc.dom = d->domain_id; - alloc.remote_dom = hardware_domain->domain_id; + alloc.remote_dom = xs_domid; rc = evtchn_alloc_unbound(&alloc, 0); if ( rc ) { @@ -760,16 +769,10 @@ static int __init alloc_xenstore_params(struct kernel_info *kinfo) struct domain *d = kinfo->d; int rc = 0; - if ( kinfo->dom0less_feature & (DOM0LESS_XENSTORE | DOM0LESS_XS_LEGACY) ) - { - ASSERT(hardware_domain); - rc = alloc_xenstore_evtchn(d); - if ( rc < 0 ) - return rc; + if ( (kinfo->dom0less_feature & (DOM0LESS_XENSTORE | DOM0LESS_XS_LEGACY)) + == (DOM0LESS_XENSTORE | DOM0LESS_XS_LEGACY) ) d->arch.hvm.params[HVM_PARAM_STORE_PFN] = ~0ULL; - } - - if ( kinfo->dom0less_feature & DOM0LESS_XENSTORE ) + else if ( kinfo->dom0less_feature & DOM0LESS_XENSTORE ) { rc = alloc_xenstore_page(d); if ( rc < 0 ) @@ -841,6 +844,30 @@ static void __init domain_vcpu_affinity(struct domain *d, } } +static void __init initialize_domU_xenstore(void) +{ + struct domain *d; + + if ( xs_domid == DOMID_INVALID ) + return; + + for_each_domain( d ) + { + unsigned long gfn = d->arch.hvm.params[HVM_PARAM_STORE_PFN]; + int rc; + + if ( gfn == 0 ) + continue; + + if ( is_xenstore_domain(d) ) + continue; + + rc = alloc_xenstore_evtchn(d); + if ( rc < 0 ) + panic("%pd: Failed to allocate xenstore_evtchn\n", d); + } +} + static int __init construct_domU(struct domain *d, const struct dt_device_node *node) { @@ -881,17 +908,13 @@ static int __init construct_domU(struct domain *d, rc == -ENODATA || (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) ) { - if ( hardware_domain ) - kinfo.dom0less_feature = DOM0LESS_ENHANCED; - else - panic("At the moment, Xenstore support requires dom0 to be present\n"); + need_xenstore = true; + kinfo.dom0less_feature = DOM0LESS_ENHANCED; } else if ( rc == 0 && !strcmp(dom0less_enhanced, "legacy") ) { - if ( hardware_domain ) - kinfo.dom0less_feature = DOM0LESS_ENHANCED_LEGACY; - else - panic("At the moment, Xenstore support requires dom0 to be present\n"); + need_xenstore = true; + kinfo.dom0less_feature = DOM0LESS_ENHANCED_LEGACY; } else if ( rc == 0 && !strcmp(dom0less_enhanced, "no-xenstore") ) kinfo.dom0less_feature = DOM0LESS_ENHANCED_NO_XS; @@ -1138,7 +1161,15 @@ void __init create_domUs(void) if ( rc ) panic("Could not set up domain %s (rc = %d)\n", dt_node_name(node), rc); + + if ( d_cfg.flags & XEN_DOMCTL_CDF_xs_domain ) + set_xs_domain(d); } + + if ( need_xenstore && xs_domid == DOMID_INVALID ) + panic("xenstore requested, but xenstore domain not present\n"); + + initialize_domU_xenstore(); } /* diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index b3a396c2fc..d99ca7b43f 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2408,6 +2408,8 @@ void __init create_dom0(void) rc = construct_dom0(dom0); if ( rc ) panic("Could not set up DOM0 guest OS (rc = %d)\n", rc); + + set_xs_domain(dom0); } /* diff --git a/xen/arch/arm/include/asm/dom0less-build.h b/xen/arch/arm/include/asm/dom0less-build.h index 5864944bda..b0e41a1954 100644 --- a/xen/arch/arm/include/asm/dom0less-build.h +++ b/xen/arch/arm/include/asm/dom0less-build.h @@ -9,6 +9,7 @@ void create_domUs(void); bool is_dom0less_mode(void); +void set_xs_domain(struct domain *d); #else /* !CONFIG_DOM0LESS_BOOT */ @@ -17,6 +18,7 @@ static inline bool is_dom0less_mode(void) { return false; } +static inline void set_xs_domain(struct domain *d) {} #endif /* CONFIG_DOM0LESS_BOOT */ From patchwork Mon Mar 31 21:43:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 14034147 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 BC1A3C36017 for ; Mon, 31 Mar 2025 21:43:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.933001.1335076 (Exim 4.92) (envelope-from ) id 1tzMv2-0005Y5-CK; Mon, 31 Mar 2025 21:43:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 933001.1335076; Mon, 31 Mar 2025 21:43:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzMv2-0005Xl-7s; Mon, 31 Mar 2025 21:43:44 +0000 Received: by outflank-mailman (input) for mailman id 933001; Mon, 31 Mar 2025 21:43:42 +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 1tzMv0-0004Vr-6T for xen-devel@lists.xenproject.org; Mon, 31 Mar 2025 21:43:42 +0000 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2062e.outbound.protection.outlook.com [2a01:111:f403:240a::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 34dfc078-0e79-11f0-9ffb-bf95429c2676; Mon, 31 Mar 2025 23:43:40 +0200 (CEST) Received: from MW4PR04CA0207.namprd04.prod.outlook.com (2603:10b6:303:86::32) by DM4PR12MB7645.namprd12.prod.outlook.com (2603:10b6:8:107::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.46; Mon, 31 Mar 2025 21:43:35 +0000 Received: from SJ1PEPF00002313.namprd03.prod.outlook.com (2603:10b6:303:86:cafe::6f) by MW4PR04CA0207.outlook.office365.com (2603:10b6:303:86::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.50 via Frontend Transport; Mon, 31 Mar 2025 21:43:35 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00002313.mail.protection.outlook.com (10.167.242.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Mon, 31 Mar 2025 21:43:34 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 31 Mar 2025 16:43:33 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 31 Mar 2025 16:43:32 -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: 34dfc078-0e79-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U3gESWeJBZkRXprX9wo8pdSKhjAorlN1HNXGboptiCeNihwvX9bkJA4DDPVeJK7X76eUfAmjgyLlpXtA2ZuKVZ2juLgJG1FJHp1wZmSIAB+3tAocSrazG9w13a+9oH8Gppnduvs6ebOif3ebxCUsSPdG1g3qv4NVN/M3o7wlEdhxLG6usoVCA9EUv91MB+QliwUXcyg/qyjEZr1hFkY0rRk06OjHF6yn6iltKXosaTQNVf4g9F2c/GT9gjBS2bTQ3UEY/8bQx8CHtSOO0VRrdcylF9SgWKM9g6GHquTz3a3OZrtYZn+VUSCPgwi9J7uneQ2PCtr7ZvmP/AohZJWVLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PQhJHw7567ypHQ6EQlLWOtnRHhS4n0cVpMQbZjCkjSA=; b=aB7p/9nf/XnIkVxVO63kWJJ8bZ4UdIt8/0AkHFyIgaUvFrqjP6Ok29j9D8E33ZTVTqR6QnbGPnGeVlXlCXwiG8McyEpET+gUSoyNmBrDXuS7Ulg5Mye0PD8HDW8Pq8uIoRnDABRjeSdmoeMWnEXp9Sp4bm3lDC1ApNay6jnz1QEmgjRmXkbh0KrSgXjNz5R5MQ6EnWV+qUI4Pummjvvw19Xo0+U+z25GvwCWgk7cY+EfX23/xV9kxSPUIzExTn61hkZUYcu2gGHe74Z2rtlP0sljOcXcCa2MqvgBlMYxhqaL10Cl78SiMaoNFrw7owkuRfCVFCGdesqlFpn3C2eLmA== 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=PQhJHw7567ypHQ6EQlLWOtnRHhS4n0cVpMQbZjCkjSA=; b=oj48K7/ieUMjXESgau6tFU3fl3X9ZIC95uEF3TFZsxKf9taJw4tI47Zm1HxY7+PlQCOLa74OKxJ4J+Xf6a5mWqDeq3YR1iktfW1SbJsrpiR5DUTDYSDsGwu3LFR3RT9JAWOujPMioIR8e9VFa42R9o3PXzsQMjnsj5Pb5scXzkA= 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: Jason Andryuk To: CC: Jason Andryuk , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , Anthony PERARD , "Jan Beulich" , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v2 4/6] xen/arm: dom0less seed xenstore grant table entry Date: Mon, 31 Mar 2025 17:43:19 -0400 Message-ID: <20250331214321.205331-5-jason.andryuk@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331214321.205331-1-jason.andryuk@amd.com> References: <20250331214321.205331-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB04.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002313:EE_|DM4PR12MB7645:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fc3ddeb-cc61-4cb9-3ae1-08dd709d1670 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|34020700016|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: j3BLBTyuwp6uFeTJhOIc7dONKeSM5EQ562Nc9zDnPcK1fZwugBWCYLUfG9HAYonQ4B7+VQIa7KujkGV8d7XCgwb397dVcd2lphMDW4FVXdJhFy0FhUHM0XNe9HZYbmXycBhm9vhibIDxmRfDdErmJGHpUm6ieOOoZbHQT7ewGqsoATsxbVMpWXw5tEnR6NEefNpbysNCNVHVk3Z+ZS7l8TT+4Pt5iQIL0ZQ2QkSoAwCntPxQO5V5YumHPbQXFj7iJ/72fipXdCflMd5W3apt3RkzVxdfO1YK4oCT3BYvsda/YGNWVJSPPmXhzCL8ur6EFJ8a3Yy9eMrA/v9E1eC2u8Z0iGN1uwrkGmmWdQ2GT1XVZ1T9Y0Kqsxj3CJDS7dvNXmIGZ0orjVkdW2PnKNalM5x93fUI/+3cXsCA9ICiW7hjsXLxBMPDmIzcbeXLwA7Jlo6QsP4W9z6iT08G/bewyJUypMoaUbeuZi4fI0R80vgeSni164sgqZrYoqQuk3n2uFN3wjSi9TvIHapGV0Nbpzw7Xqzm+q3wnhA78mCKRraSo3GZyDZlG3MQXYqoz+2KXyOvT2SVsi3gbEEXAqF/yQ8NwEM4mQtMG0dqP/1ztZEdL6MbR7UQI6QqDaqyL0ZC/6DdgowO3ov+VbtVgJg6VGNmP2wFljTLDOt3tNuBRkWBXIGbPNuOOmgRUo9KnUREerVceKGxd8AFqMCF0u/57jaWZR10Gona4MY3DuP857IEHXQUqfx+R6XfUE1yLT0Frs79Ho6sAk1J50OkXdcfGsemCeaLu7sN7mXwfFFU+IH4IObQaamUrT7ak86TuF/6ipNNuhu3c0O2S2n/riw232ViYIs4OlV7CmS/DM19RvS4Q5SdQq5GotvDOJE88G9yJKDbj4e7DjmP7ygEzJL59Eu2CPnb4LqKQpFolpqfPXBAH7Te89iApYTf6smLo9ClhloWIc9vW8MfAob3UychjzGnptmNsTVgr2brmmBFMFz1eVT3Vd4zeVCt4Hw+biEP+QYgy92fm+nIWk8jL01y2/M841dco/y2w8uGHPodVFPc+73nZqWHt9BuZuFqHAVFHjlbhhQL/n4JzEQfzboSm3Cx6FREgTYLJMS0UMIM+M0WH7h6qui73c9JkH/2WOGmy8Rhm3bEOlMgRjB2Dae8bbc6SEeEixmB0Q8eEI+D0JXlu3OT8Gxh5kqbdmMZFqJAOYt3mwAakGnSQFMs1dluLVFGzVMyjwycRRNqhUPyUETt+Iiu5GgWI9cYERUjNL3gGFyHxNXlxvv3SyN/A8aqey5jIGZq1jxCVKrnDhAJRlHTtOOhq7bjG6tqY1B3kjd6LpcrQZLxyM+rb2Cz9343tlJUqp7oYBa6ZDU+P/F+v1IKWeMp7ei1pmJb/e6S03vwzRcc1suyHvjvOGDgFxqqcpBwMlgai/wfYQDo3ipS6eKT+D4uV1KUcpkVx2KIjEGshHYgxeanA2yewu1sLuHOtQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(34020700016)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 21:43:34.3546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fc3ddeb-cc61-4cb9-3ae1-08dd709d1670 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: SJ1PEPF00002313.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7645 xenstored maps other domains' xenstore pages. Currently this relies on init-dom0less or xl to seed the grants from Dom0. With split hardware/control/xenstore domains, this is problematic since we don't want the hardware domain to be able to map other domains' resources without their permission. Instead have the hypervisor seed the grant table entry for every dom0less domain. The grant is then accessible as normal. This works with C xenstored. OCaml xenstored does not use grants and would fail to foreign map the page. Signed-off-by: Jason Andryuk --- v2: Tweak commit message Mark gnttab_seed_entry() __init and put inside CONFIG_DOM0LESS_BOOT Add ASSERT(!d->creation_finished) and ASSERT(gt->gt_version == 1); const struct domain & struct grant_table --- xen/arch/arm/dom0less-build.c | 4 ++++ xen/common/grant_table.c | 15 +++++++++++++++ xen/include/xen/grant_table.h | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index a46f292c1f..fc515c9852 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -865,6 +865,10 @@ static void __init initialize_domU_xenstore(void) rc = alloc_xenstore_evtchn(d); if ( rc < 0 ) panic("%pd: Failed to allocate xenstore_evtchn\n", d); + + if ( gfn != ~0ULL ) + gnttab_seed_entry(d, GNTTAB_RESERVED_XENSTORE, xs_domid, + gfn, GTF_permit_access); } } diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 6c77867f8c..2fb3679447 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -4346,6 +4346,21 @@ static void gnttab_usage_print(struct domain *rd) printk("no active grant table entries\n"); } +#ifdef CONFIG_DOM0LESS_BOOT +void __init gnttab_seed_entry(const struct domain *d, unsigned int idx, + domid_t be_domid, uint64_t frame, + unsigned int flags) +{ + const struct grant_table *gt = d->grant_table; + + ASSERT(!d->creation_finished); + ASSERT(gt->gt_version == 1); + shared_entry_v1(gt, idx).flags = flags; + shared_entry_v1(gt, idx).domid = be_domid; + shared_entry_v1(gt, idx).frame = frame; +} +#endif + static void cf_check gnttab_usage_print_all(unsigned char key) { struct domain *d; diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h index 50edfecfb6..a17f1787da 100644 --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -45,6 +45,11 @@ void grant_table_destroy( struct domain *d); void grant_table_init_vcpu(struct vcpu *v); +/* Seed a gnttab entry for Hyperlaunch/dom0less. */ +void __init gnttab_seed_entry(const struct domain *d, unsigned int idx, + domid_t be_domid, uint64_t frame, + unsigned int flags); + /* * Check if domain has active grants and log first 10 of them. */ @@ -85,6 +90,10 @@ static inline void grant_table_destroy(struct domain *d) {} static inline void grant_table_init_vcpu(struct vcpu *v) {} +static inline void gnttab_seed_entry(struct domain *d, int idx, + domid_t be_domid, uint64_t frame, + unsigned int flags) {} + static inline void grant_table_warn_active_grants(struct domain *d) {} static inline int gnttab_release_mappings(struct domain *d) { return 0; } From patchwork Mon Mar 31 21:43:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 14034149 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 AFDB8C36016 for ; Mon, 31 Mar 2025 21:43:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.933003.1335086 (Exim 4.92) (envelope-from ) id 1tzMv3-0005qH-Oy; Mon, 31 Mar 2025 21:43:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 933003.1335086; Mon, 31 Mar 2025 21:43:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzMv3-0005q5-KU; Mon, 31 Mar 2025 21:43:45 +0000 Received: by outflank-mailman (input) for mailman id 933003; Mon, 31 Mar 2025 21:43:44 +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 1tzMv2-0004Vr-1m for xen-devel@lists.xenproject.org; Mon, 31 Mar 2025 21:43:44 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060a.outbound.protection.outlook.com [2a01:111:f403:2416::60a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 35fccfc6-0e79-11f0-9ffb-bf95429c2676; Mon, 31 Mar 2025 23:43:42 +0200 (CEST) Received: from MW4PR04CA0197.namprd04.prod.outlook.com (2603:10b6:303:86::22) by DM4PR12MB6589.namprd12.prod.outlook.com (2603:10b6:8:b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Mon, 31 Mar 2025 21:43:37 +0000 Received: from SJ1PEPF00002313.namprd03.prod.outlook.com (2603:10b6:303:86:cafe::88) by MW4PR04CA0197.outlook.office365.com (2603:10b6:303:86::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.52 via Frontend Transport; Mon, 31 Mar 2025 21:43:37 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00002313.mail.protection.outlook.com (10.167.242.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Mon, 31 Mar 2025 21:43:36 +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.39; Mon, 31 Mar 2025 16:43:35 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 31 Mar 2025 16:43:35 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 31 Mar 2025 16:43:34 -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: 35fccfc6-0e79-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S8Bp+SbkC78F/OT2n6StEgGTYMSr1Ia5vfEZwVOtAHdiMadtJvqBnisQycjlAEMczVN/b2Dk3EjfdHOmaM5kH0NEjMFX9dQXtxQdpBPpT1Etoepvt+UmTe9zG7jUW/cNThzO/BCj3yf05i9rfrD1GsRcUzBWibKuTbmmhpOUYYBChTxNMfyruGW5+aEulRzeJT1i2V9XpeZfdFBNvOlL7BbEPGr2ibjQaqFEfThAavI8oPpX3wAbMNH/7xqCOIEglYSCdyOTbcBWTQuh/ZFLRgIWgvKr3tEqnMqA6YvyTWMfM8EJEWAKWQ7rFmCrnv85zC91g3fp79TTbCsPuMeSRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HIwhjfknntHy51daW0G7gVn2WkUksiIVEhJto7dMW3I=; b=KV1z4hKEbfUKBf0h58ZlFmg36JAVekH17HDyqMBOV9OOy+oi57i9d6hTQpHFHBp1e9CqyCwZm5C35/P9JOPZl+CrXiqZmrO6iysu2RR7QmDYgNEzWCyGwc1D0L4ShCWVOTl19xvoXcHruIKDZ0nlOx7ejTZ59O3+iqEgued3BhrAhfxFYt16+0JQy4XROIrTRYn8jhjpllupZ/PkiblnCubU8xjCZ5yWAt8XvBH7ihD9RZDRQrplfdPpOfBhoHB2Fsk4iHeZxK+6HmTdCB0fDbsNIoriCoe2zBWgImFIINpjKOajJkro6a3Z+WdTsY8aLOwfwM/rE0Tqh2JHurj3+Q== 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=HIwhjfknntHy51daW0G7gVn2WkUksiIVEhJto7dMW3I=; b=W8T+hhcyUgok8FPwkPysexnWOhqTZlmIwt4TwhmlLWr+3EwvvwQHbktFQRQYZCU/cgytuz712yZ7f/VkcNu9IHO7kq8HdEfUBm6v1MDj99QabMpr+P83ANrppCMk55J74yJTED5+kyheO/zKi9Wr0L/Suw4W5LWgjKVjO6r9VWM= 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: Jason Andryuk To: CC: Jason Andryuk , Anthony PERARD Subject: [PATCH v2 5/6] tools/init-dom0less: Only seed legacy xenstore grants Date: Mon, 31 Mar 2025 17:43:20 -0400 Message-ID: <20250331214321.205331-6-jason.andryuk@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331214321.205331-1-jason.andryuk@amd.com> References: <20250331214321.205331-1-jason.andryuk@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002313:EE_|DM4PR12MB6589:EE_ X-MS-Office365-Filtering-Correlation-Id: 7977a475-1e84-496b-0656-08dd709d179f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|34020700016|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: 7nX9vEClksZZGT1Bx8VFl9gahrgM7f1odpCEVgZY2C0UXGPduDtP05g89WeV0nOALs1dvHzH8JQxp2ChCRzZXaRsJJgGflytcy7HOJI1DO9gFqXuzYNKbZciJyAZQBveetN30UfQleNIthzsF1zpouAak6uou2m9zxtwcv3i62mzLTWQPNwxmFhuHP1ZC3w0blc5l8b3xHmlbZ37dPnvWLDHXi83haWJaL/PIbOWRJTfnKdfkKgdz8TA+B/QJHI87Thwlr3MhWVzpQEw3e4rowV5vTSkrCIPIsBI6Dm/IXP5uA+jDybv9kBsuR9/TMYNKtyHXQSYxpjH0skSGSdGkL9Bc5uG2QB1BWu5KE8sNljW4jC+EJ2+RtdViavqmAD7mkeoXN408H+w9CZqWY743/hSp6sp2ryaVVWnbpN5vUOHNteyuHUqut0MSu7939QJJk8yhZ47KHf3SAWKEvi6nyHsmrkr7iqx6BIhB+6xdnaScBcjZW9dV2lDKT6RELopM530CWSOVD9M+VEnuBt/073JT/D8ZJkQdZwKuUnIJ7DpX9dYxjPVlmDZKL9Gju2ByBse2iPjIlPUT8VcrF1Amf/UrkRtG0SEgmTU4Hz088sA0YSpoRSYifeqyUJxo9eQBP+cK2z6GKzJGgXaAEHoM30Mxc+2HX9SCKjjknuUg8STQ6VDZlZwAGgpNmQNMHl4q9vXrBU3rEp6dnTZfSL8qnTnfeteXoJmBB22RTze8t+plhJVAkRDk0kUCos0JkPZS1iPDwyMmWEAnEHtT0qSJISVr8XAbhODSL9JqTV1EEmQm2ePpWPf0Rl6jeT0I3cLk6boeHso4mqCAbtckabvWo7hCdlvLBdnVgNAYplwsHByavG6W+h2Kgt2V9ors9GKYcBQjCU/Cx8cdEd8HiKMNVludqlmJgvDZk3tdVzGkxPbZj3UyiiNkS8R7AmgUCCil8e5gvclmsT2OF6IHZUdvxmRS7p+WOE/EHLiX5TLUiOu4ly0/hBaQ2WWkisRb35IchwPgXShvdch0KcCcOvJPuWKG80pFSCpb9gUP7hplT5EpvwsYz0D1OCvVCQ9L9HUiK1GmfPpBYlx9KAil/kDFfuhlv4qiPRt0D3eJjlEZhIr82op7MPa9ZERskrDhlWOoY3H9SuIqb04tyYibfBVdgCKLA38q143z3FYWsI0BbdQsrSAActx9bOrjqayHtRQMvGmXnv7fZPhMnPYIOpybld8rnoLrVRKnkrMzxF4hiJVxFEjwYr+t5JoxPEKiHgaNAVoaQMjm9CEdutCLeMAo3Ab3RVZNZfbxnYShzPpYYy8FhmJYX+1oCaCNRQuDlJISMqrR1f6TU1BjMz1Q08NqMq4zE/7sfxwhg7Im5PrYnjnXkTJyC2MK5LjDIreszQWAw1Ol3Ws8bAFBVUHd5XS2z3wZZDaOygD1OKcJxZFzROSCCqRZmJWceZeL/qYgs6XdizZT3mP6vvWylqto41nVkHu7elMvi3YZLMOriYd9JY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(34020700016)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 21:43:36.3546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7977a475-1e84-496b-0656-08dd709d179f 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: SJ1PEPF00002313.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6589 The hardware domain is unable to seed a control domain, but we want the control domain to use xenstore. Rely on the hypervisor to seed dom0less grant table entries for Xenstore, so this seeding is unnecessary. However, that only works for the new xenstore late init. The legacy protocol which uses init-dom0less to populate the page still needs to seed the grant. Signed-off-by: Jason Andryuk --- tools/helpers/init-dom0less.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index 17579fe2e8..91edf17b6c 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -286,12 +286,12 @@ static int init_domain(struct xs_handle *xsh, xenstore_pfn); if (rc < 0) return rc; - } - rc = xc_dom_gnttab_seed(xch, info->domid, true, - (xen_pfn_t)-1, xenstore_pfn, 0, 0); - if (rc) - err(1, "xc_dom_gnttab_seed"); + rc = xc_dom_gnttab_seed(xch, info->domid, true, + (xen_pfn_t)-1, xenstore_pfn, 0, 0); + if (rc) + err(1, "xc_dom_gnttab_seed"); + } libxl_uuid_generate(&uuid); xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid)); From patchwork Mon Mar 31 21:43:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 14034150 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 B41E8C36014 for ; Mon, 31 Mar 2025 21:43:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.933004.1335096 (Exim 4.92) (envelope-from ) id 1tzMv6-00069z-1Q; Mon, 31 Mar 2025 21:43:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 933004.1335096; Mon, 31 Mar 2025 21:43: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 1tzMv5-00069i-TI; Mon, 31 Mar 2025 21:43:47 +0000 Received: by outflank-mailman (input) for mailman id 933004; Mon, 31 Mar 2025 21:43:46 +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 1tzMv4-0004aC-9s for xen-devel@lists.xenproject.org; Mon, 31 Mar 2025 21:43:46 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20607.outbound.protection.outlook.com [2a01:111:f403:200a::607]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3790d7bf-0e79-11f0-9ea7-5ba50f476ded; Mon, 31 Mar 2025 23:43:45 +0200 (CEST) Received: from BN8PR15CA0009.namprd15.prod.outlook.com (2603:10b6:408:c0::22) by CH1PPF0316D269B.namprd12.prod.outlook.com (2603:10b6:61f:fc00::604) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.54; Mon, 31 Mar 2025 21:43:39 +0000 Received: from BL6PEPF00022571.namprd02.prod.outlook.com (2603:10b6:408:c0:cafe::2f) by BN8PR15CA0009.outlook.office365.com (2603:10b6:408:c0::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8583.39 via Frontend Transport; Mon, 31 Mar 2025 21:43:39 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by BL6PEPF00022571.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8606.22 via Frontend Transport; Mon, 31 Mar 2025 21:43:37 +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.39; Mon, 31 Mar 2025 16:43:37 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 31 Mar 2025 16:43:37 -0500 Received: from fedora.mshome.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 31 Mar 2025 16:43:36 -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: 3790d7bf-0e79-11f0-9ea7-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EEZW/IDiMen7Y7SuxTPCZ36jQxkhNKDNkqBd9GYuEDf/DfAea0cc7LdgYq1GpSMC1JFxL5l2mptk8VIBFGGejD4riRxpQCf0PZABx4rOJqR0eOk8KJ0sACMKuF/fdiCIcndyUwzuapf//1fB5xwoMGsGYAmoDJgHwgAKD7hylC0TvHjw7aL2UR4GpmUWov/nm2iUxBfy6p7letl0WjmhdroCjlGoBuskeTGaaF/Ly0Yha+dN1Xfmzm11yl1XUQqIbornqQ9KvhWFGLqxL+8t2HQqtqRwMK4P95wlDCBKEYZ+Wfyd0SUjISddh3WH/Lh5/UUnmCQBMCeDJuEh7jTSjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fijYQspdfZFoThhaS1WIWMVtQUseoBzQfmLgz8dnLRI=; b=cee9CuueYi5vPoGosF6edylesJ7hSCxKllABUfGyyGNUMmukcWF114Zi+/SbbbdE9IDlpYTHBShuKRgTFTBe992S8nDFDDZdG5I3bmFwjZ9QD5OtxoWHdJPA28wzpnXChA9f3C7ET44pPQBGyHl+3h2Ig2WFggkXR3r3hXBwXq4zp21EopoX2cmmXZey2QggHTZzUQ2LwsGiqJfLv+TYO9W/6AWICMi5YXxwzGjqIzKbX1e+3bGUh1CWLvJVXbRw2EyBXh4GqiM9elTaq1K9SEfnRvVrOvela2PwWyB4ghMsbRQiC7t7vwXy1arqoTdTS6Df5pcMmd+o6NXUok7Ryw== 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=fijYQspdfZFoThhaS1WIWMVtQUseoBzQfmLgz8dnLRI=; b=churWQHjrUNOXAa5EJBikr8I4X2Y0nace2HidOaldfdbgKn/rjRm5+x2+t0QYF3Aa+JkYRxVH7oKHhIajvUZqiHu/DG6i9fw3cQG5PPWUFWdpcdyMmflZ+1rG91i8Iyqxo58PnEujIC+nQhvH8FGYcYE8bHhLr1+YlfZai/UcR0= 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: Jason Andryuk To: CC: Jason Andryuk , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , "Volodymyr Babchuk" , Andrew Cooper , Anthony PERARD , "Jan Beulich" , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v2 6/6] xen/arm: Add capabilities to dom0less Date: Mon, 31 Mar 2025 17:43:21 -0400 Message-ID: <20250331214321.205331-7-jason.andryuk@amd.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250331214321.205331-1-jason.andryuk@amd.com> References: <20250331214321.205331-1-jason.andryuk@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00022571:EE_|CH1PPF0316D269B:EE_ X-MS-Office365-Filtering-Correlation-Id: 28b1f1d1-62f0-4204-0c6a-08dd709d188c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|34020700016|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: GrGLMk88tUv/ReFrs+v1f/KCTu7Nx2M/+bYZRhvrWrVGVmjV1i14i5tB1KkdmdODfD67oieEKodUQX5O10u7LDXRHLdVtjBWYYMfe0n6r6b34/OGTke8kRLE0S8eppQLxdRm97xjyMm8NFp+p78uWpDsVhIP1D11CPgo152Xc8NqPX/HAlimW68x9EDzZdwEV0tsr+BPDn/EW1eNsS0S2XB0duWWN7TUKMh/0CpbgMMx/InMmbWJ+tWEwrKeKfC2CzxwCoxPJsP4WQV3aYob6apt8vo6hzfaokeigIgCwTFBNi1Z8KRloItHbO3RSQ1i4rIVLsYWukEsePnRn+bFFh/tKYd3vVHJ8qu2pbw1P4A+UCWFIrqFLvph+74dNtHX5WkATr5W5YU3jKV9P33yxAelFO6lRhAFat+/ANMAn8g8gmmOEPzdUec3LWaVQuJhxZeZZ+dXDh6rgtNMay/j5NOvfGb0COm9fzRqcsjefU5eRhAUcbrH/24EOrBkfLl9hZEqgkWOhzmxMujpl+fHWQJJ+oLj9ZFnMCg0Blo0chDedOGYVGAkFOjw+b7k+qMMDTzJISIeeXEPzrTbpjW+Sx84HX07vP8+BABsJiWR208EzR2dTDRsiQQVDm11O6zKlKLS7f408JWaJRTBMLFZQ2zCyQKdtyqFAKfcCbZl06XPwB/KrJExt2k374zJ0imZK3aS59HacE/8V208mqH+4gNRgQaKHoeb7yhrh6iyFXbzQrt1fv7NqhRj/3X3NGSnj+Z6O7rBanXUyknrn26OSjm7i9FmeIno0ArU9Cs7CxG8dKje0T0e38NwlE6IEBaswzCLvAnWTfDULY0amwO/RoV4PTO4L6dWw+JuYwF9MxWgnneic3/VW3gBS2nlmGDOlU/MXEdAo/pzQTNdGP0PmEViCch08atA15F56fHrBIDX2hORQkystq5lk8qjDobtZSHE8glaFQGZGzWmqfR/SRHcAVYiSaAeVhPliPnenImmztmihuBmiaD0puBZEFXe4iFnqNMtSsDJnVqGZOuZJet0Ok0jqaQLpr7f1rtTvn3ITsLKnia4/Kxpuf/K8rXxy53E9uUpenJnDjZWUQtTa4rODjJuEWF3QA+LDN/WKUiD/jXS9m9C7iI/jxjMxkmCFuWeP2avVwUFqZ5EM9rle9Mae64wLimN7sIOPAnXWr62Fm6eXb8SaN1YqFrTXXIi8t8XjkN15mxQ1sevrVeCSGDVjqDyVZnYuHuuDeX3EJ3AL0zeCor0aqEf5Bys1QWo4HT6iIPyUuA96/gg1G1qOoVoS7+fwPVKBBwCR30BQmp96V/qHvuyAIWllSAQQQbgdvTVLO0T/7avzBx9YVi6Y9j55/KNKOQsScaPGJQdkwChBAJ4nM60kdbkqeC/nYeeHozgs59XiH2xS5SAER/bhYGyeQzqLz6FSNeADNToHgqeDn3EB9EAROw0jvV3c2KQ2lxaOMQPGdHJiG735oKZyR3Ff2dPWK2l2Cnq55o3N3w= 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:(13230040)(1800799024)(34020700016)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 21:43:37.9236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28b1f1d1-62f0-4204-0c6a-08dd709d188c 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: BL6PEPF00022571.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PPF0316D269B Add capabilities property to dom0less to allow building a disaggregated system. Only a single hardware domain and single xenstore domain can be specified. Multiple control domains are possible. Introduce bootfdt.h to contain these constants. When using the hardware or xenstore capabilities, adjust the grant and event channel limits similar to dom0. For a hardware domain, require an IOMMU and disallow specifying a vpl011 console or nr_spis. Signed-off-by: Jason Andryuk --- v2: Fix comment style Make DOMAIN_CAPS_* unsigned Remove forced directmap & iommu Require iommu with use of hardware domain Limit to a single xenstore domain There is overlap with hyperlaunch. The numeric values are the same. Hyperlaunch doesn't expose the values in a public header as done here. Is this to be expected for dom0less? It seems most of dom0less isn't in a header, but just in docs. Hyperlaunch uses BUILD_CAPS_, but I chose DOMAIN_CAPS_ since there are domain-level capabilities. Only a single xenstore and hardware domain make sense. Hardware domain receiving all hardware can only have a single domain. For Xenstore, the logic latches the single xs_domid and uses that for all domains. Also, only a single domain can register for VIRQ_DOM_EXC. --- docs/misc/arm/device-tree/booting.txt | 11 ++++++++ xen/arch/arm/dom0less-build.c | 39 +++++++++++++++++++++++++++ xen/arch/arm/domain.c | 3 ++- xen/include/public/bootfdt.h | 31 +++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 xen/include/public/bootfdt.h diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index ac781c9cc8..490c792ddf 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -167,6 +167,17 @@ with the following properties: Refer to docs/misc/cache_coloring.rst for syntax. This option is applicable only to Arm64 guests. +- capabilities + Optional. A bit field of domain capabilities for a disaggregated + system. A traditional dom0 has all all of these capabilities, and a + domU has none of them. + + 0x1 DOMAIN_CAPS_CONTROL - A privileged, control domain + 0x2 DOMAIN_CAPS_HARDWARE - The hardware domain - there can be only 1 + 0x4 DOMAIN_CAPS_XENSTORE - The xenstore domain - there can be only 1 + + The default is no capabilities. + - vpl011 An empty property to enable/disable a virtual pl011 for the guest to diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index fc515c9852..1cb6c170a7 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -906,6 +907,8 @@ static int __init construct_domU(struct domain *d, d->max_vcpus, mem); kinfo.vpl011 = dt_property_read_bool(node, "vpl011"); + if ( kinfo.vpl011 && is_hardware_domain(d) ) + panic("hardware domain cannot specify vpl011\n"); rc = dt_property_read_string(node, "xen,enhanced", &dom0less_enhanced); if ( rc == -EILSEQ || @@ -1020,6 +1023,40 @@ void __init create_domUs(void) if ( (max_init_domid + 1) >= DOMID_FIRST_RESERVED ) panic("No more domain IDs available\n"); + if ( dt_property_read_u32(node, "capabilities", &val) ) + { + if ( val & ~DOMAIN_CAPS_MASK ) + panic("Invalid capabilities (%"PRIx32")\n", val); + + if ( val & DOMAIN_CAPS_CONTROL ) + flags |= CDF_privileged; + + if ( val & DOMAIN_CAPS_HARDWARE ) + { + if ( hardware_domain ) + panic("Only 1 hardware domain can be specified! (%pd)\n", + hardware_domain); + + if ( !iommu_enabled ) + panic("iommu required for dom0less hardware domain\n"); + + d_cfg.max_grant_frames = gnttab_dom0_frames(); + d_cfg.max_evtchn_port = -1; + flags |= CDF_hardware; + iommu = true; + } + + if ( val & DOMAIN_CAPS_XENSTORE ) + { + if ( xs_domid != DOMID_INVALID ) + panic("Only 1 xenstore domain can be specified! (%u)\n", + xs_domid); + + d_cfg.flags |= XEN_DOMCTL_CDF_xs_domain; + d_cfg.max_evtchn_port = -1; + } + } + if ( dt_find_property(node, "xen,static-mem", NULL) ) { if ( llc_coloring_enabled ) @@ -1082,6 +1119,8 @@ void __init create_domUs(void) d_cfg.arch.nr_spis = MAX(d_cfg.arch.nr_spis, vpl011_virq - 32 + 1); } + else if ( flags & CDF_hardware ) + panic("nr_spis cannot be specified for hardware domain\n"); /* Get the optional property domain-cpupool */ cpupool_node = dt_parse_phandle(node, "domain-cpupool", 0); diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 3ba959f866..dc4b4e84c1 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -608,7 +608,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_xs_domain ); unsigned int sve_vl_bits = sve_decode_vl(config->arch.sve_vl); if ( (config->flags & ~flags_optional) != flags_required ) diff --git a/xen/include/public/bootfdt.h b/xen/include/public/bootfdt.h new file mode 100644 index 0000000000..86c46b42a9 --- /dev/null +++ b/xen/include/public/bootfdt.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Xen Device Tree boot information + * + * Information for configuring Xen domains created at boot time. + */ + +#ifndef __XEN_PUBLIC_BOOTFDT_H__ +#define __XEN_PUBLIC_BOOTFDT_H__ + +/* + * Domain Capabilities specified in the "capabilities" property. Use of + * this property allows splitting up the monolithic dom0 into separate, + * less privileged components. A regular domU has no capabilities + * (which is the default if nothing is specified). A traditional dom0 + * has all three capabilities. + */ + +/* Control/Privileged domain capable of affecting other domains. */ +#define DOMAIN_CAPS_CONTROL (1U << 0) +/* + * Hardware domain controlling physical hardware. Typically providing + * backends to other domains. + */ +#define DOMAIN_CAPS_HARDWARE (1U << 1) +/* Xenstore domain. */ +#define DOMAIN_CAPS_XENSTORE (1U << 2) +#define DOMAIN_CAPS_MASK (DOMAIN_CAPS_CONTROL | DOMAIN_CAPS_HARDWARE | \ + DOMAIN_CAPS_XENSTORE) + +#endif /* __XEN_PUBLIC_BOOTFDT_H__ */