All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: xen-devel@lists.xenproject.org
Cc: "Daniel P. Smith" <dpsmith@apertussolutions.com>,
	jason.andryuk@amd.com, christopher.w.clark@gmail.com,
	stefano.stabellini@amd.com, "Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v2 07/15] x86/hyperlaunch: initial support for hyperlaunch device tree
Date: Thu, 26 Dec 2024 11:57:32 -0500	[thread overview]
Message-ID: <20241226165740.29812-8-dpsmith@apertussolutions.com> (raw)
In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com>

Add the ability to detect both a formal hyperlaunch device tree or a dom0less
device tree. If the hyperlaunch device tree is found, then count the number of
domain entries, reporting an error if more than one is found.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
Changes since v1:
- corrected typo in error message
- clarified commit message on "reporting"
- added missing inline decl
- code style
---
 xen/arch/x86/domain-builder/core.c  | 15 +++++++
 xen/arch/x86/domain-builder/fdt.c   | 65 ++++++++++++++++++++++++++++-
 xen/arch/x86/domain-builder/fdt.h   |  5 +++
 xen/arch/x86/include/asm/bootinfo.h |  1 +
 4 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c
index d6ae94f45c72..c50eff34fb68 100644
--- a/xen/arch/x86/domain-builder/core.c
+++ b/xen/arch/x86/domain-builder/core.c
@@ -44,6 +44,21 @@ void __init builder_init(struct boot_info *bi)
             break;
         }
     }
+
+    if ( bi->hyperlaunch_enabled )
+    {
+        int ret;
+
+        printk(XENLOG_INFO "Hyperlaunch configuration:\n");
+        if ( (ret = walk_hyperlaunch_fdt(bi)) < 0 )
+        {
+            printk(XENLOG_INFO "  walk of device tree failed (%d)\n", ret);
+            bi->hyperlaunch_enabled = false;
+            return;
+        }
+
+        printk(XENLOG_INFO "  Number of domains: %d\n", bi->nr_domains);
+    }
 }
 
 /*
diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builder/fdt.c
index 4a3f80648f86..5793bdc9fd47 100644
--- a/xen/arch/x86/domain-builder/fdt.c
+++ b/xen/arch/x86/domain-builder/fdt.c
@@ -13,14 +13,77 @@
 
 #include "fdt.h"
 
+static int __init find_hyperlaunch_node(const void *fdt)
+{
+    int hv_node = fdt_path_offset(fdt, "/chosen/hypervisor");
+
+    if ( hv_node >= 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 = 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") == 0 )
+                return chosen_node;
+        }
+    }
+
+    return -ENODATA;
+}
+
 int __init has_hyperlaunch_fdt(struct boot_info *bi)
 {
     int ret = 0;
     const void *fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]);
 
-    if ( fdt_check_header(fdt) < 0 )
+    if ( !fdt || fdt_check_header(fdt) < 0 )
         ret = -EINVAL;
+    else
+        ret = find_hyperlaunch_node(fdt);
+
+    bootstrap_unmap();
+
+    return ret < 0 ? ret : 0;
+}
+
+int __init walk_hyperlaunch_fdt(struct boot_info *bi)
+{
+    int ret = 0, hv_node, node;
+    void *fdt = bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]);
+
+    if ( unlikely(!fdt) )
+        return -EINVAL;
+
+    hv_node = find_hyperlaunch_node(fdt);
+    if ( hv_node < 0 )
+    {
+        ret = hv_node;
+        goto err_out;
+    }
+
+    fdt_for_each_subnode(node, fdt, hv_node)
+    {
+        ret = fdt_node_check_compatible(fdt, node, "xen,domain");
+        if ( ret == 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");
 
+ err_out:
     bootstrap_unmap();
 
     return ret;
diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builder/fdt.h
index 1c1569a9c633..f5b89cb54b29 100644
--- a/xen/arch/x86/domain-builder/fdt.h
+++ b/xen/arch/x86/domain-builder/fdt.h
@@ -11,11 +11,16 @@
 
 #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 inline int __init walk_hyperlaunch_fdt(struct boot_info *bi)
+{
+    return -EINVAL;
+}
 #endif
 
 #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;
 
     unsigned int nr_modules;
+    unsigned int nr_domains;
     struct boot_module mods[MAX_NR_BOOTMODS + 1];
     struct boot_domain domains[MAX_NR_BOOTDOMS];
 };
-- 
2.30.2



  parent reply	other threads:[~2024-12-26 17:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-26 16:57 [PATCH v2 00/15] Hyperlaunch device tree for dom0 Daniel P. Smith
2024-12-26 16:57 ` [PATCH v2 01/15] x86/boot: introduce boot domain Daniel P. Smith
2025-01-30 13:45   ` Jan Beulich
2025-04-05  0:04     ` Daniel P. Smith
2025-04-07  7:10       ` Jan Beulich
2025-04-09 23:55         ` Daniel P. Smith
2025-04-10  6:37           ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 02/15] x86/boot: introduce domid field to struct boot_domain Daniel P. Smith
2025-01-30 13:51   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 03/15] x86/boot: add cmdline " Daniel P. Smith
2025-01-10 19:52   ` Jason Andryuk
2025-01-15 17:22     ` Daniel P. Smith
2025-01-15 19:50       ` Jason Andryuk
2025-01-30 14:15   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 04/15] kconfig: introduce option to independently enable libfdt Daniel P. Smith
2025-01-30 14:19   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 05/15] kconfig: introduce domain builder config option Daniel P. Smith
2025-01-10 19:55   ` Jason Andryuk
2025-01-15 17:24     ` Daniel P. Smith
2025-01-30 14:30   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 06/15] x86/hyperlaunch: introduce the domain builder Daniel P. Smith
2025-01-08 21:54   ` Jason Andryuk
2025-01-15 17:25     ` Daniel P. Smith
2025-01-30 14:52   ` Jan Beulich
2025-04-01 18:01     ` Jason Andryuk
2025-04-02  9:25       ` Jan Beulich
2025-04-02 19:44         ` Jason Andryuk
2024-12-26 16:57 ` Daniel P. Smith [this message]
2025-01-10 22:20   ` [PATCH v2 07/15] x86/hyperlaunch: initial support for hyperlaunch device tree Jason Andryuk
2025-01-15 17:47     ` Daniel P. Smith
2025-01-30 15:01   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 08/15] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Daniel P. Smith
2025-01-10 23:06   ` Jason Andryuk
2025-01-30 15:42   ` Jan Beulich
2025-01-30 21:14     ` Stefano Stabellini
2025-01-31  6:36       ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 09/15] x86/hyperlaunch: obtain cmdline from device tree Daniel P. Smith
2025-01-15 16:38   ` Jason Andryuk
2025-01-30 15:58   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 10/15] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Daniel P. Smith
2025-01-15 16:43   ` Jason Andryuk
2025-01-30 16:39   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 11/15] x86/hyperlaunch: add domain id parsing to domain config Daniel P. Smith
2025-01-30 16:49   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 12/15] x86/hyperlaunch: specify dom0 mode with device tree Daniel P. Smith
2025-01-15 19:42   ` Jason Andryuk
2025-01-30 16:55   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 13/15] x86/hyperlaunch: add memory parsing to domain config Daniel P. Smith
2025-01-15 16:55   ` Jason Andryuk
2025-01-30 17:01   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 14/15] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Daniel P. Smith
2025-01-15 19:40   ` Jason Andryuk
2025-01-30 17:04   ` Jan Beulich
2024-12-26 16:57 ` [PATCH v2 15/15] x86/hyperlaunch: add capabilities to boot domain Daniel P. Smith
2025-02-04 11:13   ` Jan Beulich
2025-02-04 15:40     ` Jason Andryuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241226165740.29812-8-dpsmith@apertussolutions.com \
    --to=dpsmith@apertussolutions.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=christopher.w.clark@gmail.com \
    --cc=jason.andryuk@amd.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=stefano.stabellini@amd.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.