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 if more than one is found.
Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
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_builder/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 = false;
}
+ }
+
+ if ( bi->hyperlaunch_enabled )
+ {
+ int ret;
+
+ printk(XENLOG_INFO "Hyperlauch 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 3f9dda8c34c3..ff1ba58b6907 100644
--- a/xen/arch/x86/domain_builder/fdt.c
+++ b/xen/arch/x86/domain_builder/fdt.c
@@ -14,14 +14,76 @@
#include "fdt.h"
+static int __init find_hyperlaunch_node(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;
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..84126db208ea 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 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
On 23.11.2024 19:20, Daniel P. Smith wrote:
> 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 if more than one is found.
"reporting" reads like informational logging, when comment and printk() in
walk_hyperlaunch_fdt() indicate this is actually an error (for now).
> --- a/xen/arch/x86/domain_builder/fdt.c
> +++ b/xen/arch/x86/domain_builder/fdt.c
> @@ -14,14 +14,76 @@
>
> #include "fdt.h"
>
> +static int __init find_hyperlaunch_node(void *fdt)
> +{
> + int hv_node = fdt_path_offset(fdt, "/chosen/hypervisor");
> + if ( hv_node >= 0 )
Nit: Blank line between declaration(s) and statement(s) please (also
elsewhere).
> --- 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 int __init walk_hyperlaunch_fdt(struct boot_info *bi)
inline?
Jan
On 12/2/24 06:37, Jan Beulich wrote:
> On 23.11.2024 19:20, Daniel P. Smith wrote:
>> 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 if more than one is found.
>
> "reporting" reads like informational logging, when comment and printk() in
> walk_hyperlaunch_fdt() indicate this is actually an error (for now).
That is not a shared assumptive reading. It is equally correct to say I
will report info and I will report an error. With that said, I can make
it explicit.
>> --- a/xen/arch/x86/domain_builder/fdt.c
>> +++ b/xen/arch/x86/domain_builder/fdt.c
>> @@ -14,14 +14,76 @@
>>
>> #include "fdt.h"
>>
>> +static int __init find_hyperlaunch_node(void *fdt)
>> +{
>> + int hv_node = fdt_path_offset(fdt, "/chosen/hypervisor");
>> + if ( hv_node >= 0 )
>
> Nit: Blank line between declaration(s) and statement(s) please (also
> elsewhere).
ack.
>> --- 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 int __init walk_hyperlaunch_fdt(struct boot_info *bi)
>
> inline?
Should have been.
v/r,
dps
On 2024-11-23 13:20, Daniel P. Smith wrote:
> 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 if more than one is found.
>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> ---
> 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_builder/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 = false;
> }
> + }
> +
> + if ( bi->hyperlaunch_enabled )
> + {
> + int ret;
> +
> + printk(XENLOG_INFO "Hyperlauch configuration:\n");
Hyperlaunch
> + 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 3f9dda8c34c3..ff1ba58b6907 100644
> --- a/xen/arch/x86/domain_builder/fdt.c
> +++ b/xen/arch/x86/domain_builder/fdt.c
> +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");
You continue execution - is that intended? It'll take the next module
as the kernel and try to boot? Would you rather panic?
Regards,
Jason
>
> + err_out:
> bootstrap_unmap();
>
> return ret;
On 11/25/24 15:11, Jason Andryuk wrote:
> On 2024-11-23 13:20, Daniel P. Smith wrote:
>> 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 if more than one is found.
>>
>> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
>> ---
>> 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_builder/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 = false;
>> }
>> + }
>> +
>> + if ( bi->hyperlaunch_enabled )
>> + {
>> + int ret;
>> +
>> + printk(XENLOG_INFO "Hyperlauch configuration:\n");
>
> Hyperlaunch
Ack.
>> + 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 3f9dda8c34c3..ff1ba58b6907 100644
>> --- a/xen/arch/x86/domain_builder/fdt.c
>> +++ b/xen/arch/x86/domain_builder/fdt.c
>
>> +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");
>
> You continue execution - is that intended? It'll take the next module
> as the kernel and try to boot? Would you rather panic?
Yes, it was intended, and as of this commit, it will use the next module
as the kernel. That is the boot convention at this point. In this
scenario, the system was given a valid HL device tree that happen to
have multiple domains defined in it. At this point in the series, a
domain definition literally has zero effect on the boot process, so
there is no reason to panic.
v/r,
dps
© 2016 - 2026 Red Hat, Inc.