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/cNNMPKTbJeodlIkGCUzG4FkCcM8bCvKHxK36maOm8ozG0SMFkIQFZVALQq4f8zBHVwRSGS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I5Jw7GQhsskL3H3pzcWVFV41PiYwhGvvwdE6dW47cy1nXlzPeqEzQR1vNoBlmykZuURdxpNP24bsk5pHKkWA6CKuW0pFU17H1PDq/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);