From nobody Tue Nov 18 07:58:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1732386665; cv=pass; d=zohomail.com; s=zohoarc; b=jGIVVaPWW/ljZtGUm/oA4rhSI7M72ClK+H7DPc44wzpAeomYkIofo5LlGOxB6jCEPwvLj8JEXeIq/Arkqm+hk9fcyGAnbSvl39k8Nh1A6qDjxVcrAakPezgMdplc0G9y+mRi6EEMjVVjZycnxdE2PsXc8Rk8kkqBpnNpVgBPSqw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386665; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=50hQ5FtSJpLrNxu6yxxP08QLa9SwhIW1DEp9JlMJYIs=; b=Rz3btq6A/UNpFEyVcCAMUULSYgHDY/I9OeYr/A0TDYlf+ICqEJ1ImN1B/8IzXX4SoxATEPaJ5R3dexxA07J+44WbyctdEBq4Xz60dVCdqORuI7gby1XYVE93sHeflXKFWYtx+WAB6ZdO1FTC+5iMA28piYTrybIgTvxxaQ9HFDE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1732386665796606.6268119990664; Sat, 23 Nov 2024 10:31:05 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842178.1257644 (Exim 4.92) (envelope-from ) id 1tEuu9-0003We-QE; Sat, 23 Nov 2024 18:30:49 +0000 Received: by outflank-mailman (output) from mailman id 842178.1257644; Sat, 23 Nov 2024 18:30:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuu9-0003WV-KD; Sat, 23 Nov 2024 18:30:49 +0000 Received: by outflank-mailman (input) for mailman id 842178; Sat, 23 Nov 2024 18:30:48 +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 1tEum5-0006MT-VJ for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22:29 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e4057396-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:27 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386063716280.39222882890044; Sat, 23 Nov 2024 10:21:03 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: e4057396-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImU0MDU3Mzk2LWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTQ3Ljk3MzA3Mywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386067; cv=none; d=zohomail.com; s=zohoarc; b=CA5ufyF49tWEw6HEUKFlIdTnFNCFdZM9fXV1eeYpdEbCK6N7KMzLSeDqTUZrS5+3pKut7pguGip938h0kqikUEAOplpK68wphBChOJurChqxS67tHTXXmHmt6lTnZlYTRz0w1jTsXZ8U8Oi26SGzvjCH/naS4BqGnCpB7VfJwio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386067; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=50hQ5FtSJpLrNxu6yxxP08QLa9SwhIW1DEp9JlMJYIs=; b=UXqmBAFUJ7uDZn4U+5B6DZLlS73amZ1gkzctwzvcc2q60vVLmd3edUpZmKd2xmf/LMjba/lv0DXt6/2oXzq92mmeOASV7+UlqkaW5/gSK1tK1uEshsRCJ/gtH39qQLmw0SxdvkfoDXFnSsTjW5qfP0/+ipBzxWIznt6bju2mvqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1732386067; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=50hQ5FtSJpLrNxu6yxxP08QLa9SwhIW1DEp9JlMJYIs=; b=P21QJxxpnZoyOpzGdmbggaKgpYfpOewE+2FBhkAQvoVEHzTlAEdgTs0yqajshgQS NMlJJuBQc5dZqOKAcjjt2p53AWJM+LcqjVfyDaNfQibVCuYNpylegvDipB1he5ekNYy MsnipOwGC0SIgYPfX2feb2t1CL0SbTEDTDhdydNQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 07/15] x86/hyperlaunch: initial support for hyperlaunch device tree Date: Sat, 23 Nov 2024 13:20:36 -0500 Message-Id: <20241123182044.30687-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1732386667865116600 Content-Type: text/plain; charset="utf-8" Add the ability to detect both a formal hyperlaunch device tree or a dom0le= ss device tree. If the hyperlaunch device tree is found, then count the number= of domain entries, reporting if more than one is found. Signed-off-by: Daniel P. Smith --- xen/arch/x86/domain_builder/core.c | 14 +++++++ xen/arch/x86/domain_builder/fdt.c | 64 ++++++++++++++++++++++++++++- xen/arch/x86/domain_builder/fdt.h | 5 +++ xen/arch/x86/include/asm/bootinfo.h | 1 + 4 files changed, 83 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain_builder/core.c b/xen/arch/x86/domain_build= er/core.c index 211359895d84..a80f3711c306 100644 --- a/xen/arch/x86/domain_builder/core.c +++ b/xen/arch/x86/domain_builder/core.c @@ -40,7 +40,21 @@ void __init builder_init(struct boot_info *bi) ret); bi->hyperlaunch_enabled =3D false; } + } + + if ( bi->hyperlaunch_enabled ) + { + int ret; + + printk(XENLOG_INFO "Hyperlauch configuration:\n"); + if ( (ret =3D walk_hyperlaunch_fdt(bi)) < 0 ) + { + printk(XENLOG_INFO " walk of device tree failed (%d)\n", ret); + bi->hyperlaunch_enabled =3D false; + return; + } =20 + printk(XENLOG_INFO " Number of domains: %d\n", bi->nr_domains); } } =20 diff --git a/xen/arch/x86/domain_builder/fdt.c b/xen/arch/x86/domain_builde= r/fdt.c index 3f9dda8c34c3..ff1ba58b6907 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -14,14 +14,76 @@ =20 #include "fdt.h" =20 +static int __init find_hyperlaunch_node(void *fdt) +{ + int hv_node =3D fdt_path_offset(fdt, "/chosen/hypervisor"); + if ( hv_node >=3D 0 ) + { + /* Anything other than zero indicates no match */ + if ( fdt_node_check_compatible(fdt, hv_node, "hypervisor,xen") ) + return -ENODATA; + else + return hv_node; + } + else + { + /* Lood for dom0less config */ + int node, chosen_node =3D fdt_path_offset(fdt, "/chosen"); + if ( chosen_node < 0 ) + return -ENOENT; + + fdt_for_each_subnode(node, fdt, chosen_node) + { + if ( fdt_node_check_compatible(fdt, node, "xen,domain") =3D=3D= 0 ) + return chosen_node; + } + } + + return -ENODATA; +} + int __init has_hyperlaunch_fdt(struct boot_info *bi) { int ret =3D 0; void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); =20 - if ( fdt_check_header(fdt) < 0 ) + if ( !fdt || fdt_check_header(fdt) < 0 ) ret =3D -EINVAL; + else + ret =3D find_hyperlaunch_node(fdt); + + bootstrap_unmap(); + + return ret < 0 ? ret : 0; +} + +int __init walk_hyperlaunch_fdt(struct boot_info *bi) +{ + int ret =3D 0, hv_node, node; + void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + + if ( unlikely(!fdt) ) + return -EINVAL; + + hv_node =3D find_hyperlaunch_node(fdt); + if ( hv_node < 0 ) + { + ret =3D hv_node; + goto err_out; + } + + fdt_for_each_subnode(node, fdt, hv_node) + { + ret =3D fdt_node_check_compatible(fdt, node, "xen,domain"); + if ( ret =3D=3D 0 ) + bi->nr_domains++; + } + + /* Until multi-domain construction is added, throw an error */ + if ( !bi->nr_domains || bi->nr_domains > 1 ) + printk(XENLOG_ERR "Hyperlaunch only supports dom0 construction\n"); =20 + err_out: bootstrap_unmap(); =20 return ret; diff --git a/xen/arch/x86/domain_builder/fdt.h b/xen/arch/x86/domain_builde= r/fdt.h index 1c1569a9c633..84126db208ea 100644 --- a/xen/arch/x86/domain_builder/fdt.h +++ b/xen/arch/x86/domain_builder/fdt.h @@ -11,11 +11,16 @@ =20 #ifdef CONFIG_DOMAIN_BUILDER int has_hyperlaunch_fdt(struct boot_info *bi); +int walk_hyperlaunch_fdt(struct boot_info *bi); #else static inline int __init has_hyperlaunch_fdt(struct boot_info *bi) { return -EINVAL; } +static int __init walk_hyperlaunch_fdt(struct boot_info *bi) +{ + return -EINVAL; +} #endif =20 #endif /* __XEN_X86_FDT_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 208bec90913d..683ca9dbe2e0 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -84,6 +84,7 @@ struct boot_info { bool hyperlaunch_enabled; =20 unsigned int nr_modules; + unsigned int nr_domains; struct boot_module mods[MAX_NR_BOOTMODS + 1]; struct boot_domain domains[MAX_NR_BOOTDOMS]; }; --=20 2.30.2