xen/arch/x86/dom0_build.c | 14 ++++++++++++++ xen/arch/x86/hvm/dom0_build.c | 3 +++ xen/arch/x86/include/asm/dom0_build.h | 2 ++ xen/arch/x86/pv/dom0_build.c | 10 ++-------- 4 files changed, 21 insertions(+), 8 deletions(-)
The supported features ELF notes was tested only if the dom0 was
PV. Factor out a function to check ELF notes and reuse it even
for PVH.
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
--
Changes since v1:
- fix typo in title;
- fix minor formatting issue;
- use is_hardware_domain instead of checking is_pv_shim;
- reduce indentation returning earlier;
- return error instead of jumping to cleanup code.
Changes since v2:
- rename dom0_check_parms to initdom_check_parms;
- move call to initdom_check_parms in PVH code earlier;
- make "struct domain" constant.
---
xen/arch/x86/dom0_build.c | 14 ++++++++++++++
xen/arch/x86/hvm/dom0_build.c | 3 +++
xen/arch/x86/include/asm/dom0_build.h | 2 ++
xen/arch/x86/pv/dom0_build.c | 10 ++--------
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index 864dd9e53e..56eba8f59a 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -320,6 +320,20 @@ unsigned long __init dom0_paging_pages(const struct domain *d,
return DIV_ROUND_UP(memkb, 1024) << (20 - PAGE_SHIFT);
}
+int __init initdom_check_parms(
+ const struct domain *d, const struct elf_dom_parms *parms)
+{
+ if ( parms->elf_notes[XEN_ELFNOTE_SUPPORTED_FEATURES].type == XEN_ENT_NONE )
+ return 0;
+
+ if ( is_hardware_domain(d) && !test_bit(XENFEAT_dom0, parms->f_supported) )
+ {
+ printk("Kernel does not support Dom0 operation\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
/*
* If allocation isn't specified, reserve 1/16th of available memory for
diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index d69a83b089..aa06cdb2f7 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -692,6 +692,9 @@ static int __init pvh_load_kernel(
return -EINVAL;
}
+ if ( (rc = initdom_check_parms(d, &parms)) != 0 )
+ return rc;
+
/* Copy the OS image and free temporary buffer. */
elf.dest_base = (void *)(parms.virt_kstart - parms.virt_base);
elf.dest_size = parms.virt_kend - parms.virt_kstart;
diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h
index ff021c24af..1332f18cc6 100644
--- a/xen/arch/x86/include/asm/dom0_build.h
+++ b/xen/arch/x86/include/asm/dom0_build.h
@@ -8,6 +8,8 @@
extern unsigned int dom0_memflags;
+int initdom_check_parms(const struct domain *d,
+ const struct elf_dom_parms *parms);
unsigned long dom0_compute_nr_pages(struct domain *d,
struct elf_dom_parms *parms,
unsigned long initrd_len);
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index 075a3646c2..12d8ba744a 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -494,14 +494,8 @@ static int __init dom0_construct(const struct boot_domain *bd)
return -EINVAL;
}
- if ( parms.elf_notes[XEN_ELFNOTE_SUPPORTED_FEATURES].type != XEN_ENT_NONE )
- {
- if ( !pv_shim && !test_bit(XENFEAT_dom0, parms.f_supported) )
- {
- printk("Kernel does not support Dom0 operation\n");
- return -EINVAL;
- }
- }
+ if ( (rc = initdom_check_parms(d, &parms)) != 0 )
+ return rc;
nr_pages = dom0_compute_nr_pages(d, &parms, initrd_len);
--
2.43.0
On 08/04/2026 1:55 pm, Frediano Ziglio wrote:
> diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
> index 864dd9e53e..56eba8f59a 100644
> --- a/xen/arch/x86/dom0_build.c
> +++ b/xen/arch/x86/dom0_build.c
> @@ -320,6 +320,20 @@ unsigned long __init dom0_paging_pages(const struct domain *d,
> return DIV_ROUND_UP(memkb, 1024) << (20 - PAGE_SHIFT);
> }
>
> +int __init initdom_check_parms(
> + const struct domain *d, const struct elf_dom_parms *parms)
> +{
> + if ( parms->elf_notes[XEN_ELFNOTE_SUPPORTED_FEATURES].type == XEN_ENT_NONE )
> + return 0;
> +
> + if ( is_hardware_domain(d) && !test_bit(XENFEAT_dom0, parms->f_supported) )
> + {
> + printk("Kernel does not support Dom0 operation\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
Your v1 structure was better (give or take whitespace mangling).
This needs to be a nested pair of if() conditions to not need rewriting
when SecureBoot check is added.
I'm going to fold this adjustment and commit it, because I need this
patch to fix a separate bug in the patchqueue.
~Andrew
On Wed, Apr 08, 2026 at 01:55:14PM +0100, Frediano Ziglio wrote: > The supported features ELF notes was tested only if the dom0 was > PV. Factor out a function to check ELF notes and reuse it even > for PVH. > > Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com> I think you dropped my RB from v2: Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Thanks, Roger.
On 08.04.2026 14:55, Frediano Ziglio wrote:
> The supported features ELF notes was tested only if the dom0 was
> PV. Factor out a function to check ELF notes and reuse it even
> for PVH.
>
> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
> --- a/xen/arch/x86/dom0_build.c
> +++ b/xen/arch/x86/dom0_build.c
> @@ -320,6 +320,20 @@ unsigned long __init dom0_paging_pages(const struct domain *d,
> return DIV_ROUND_UP(memkb, 1024) << (20 - PAGE_SHIFT);
> }
>
> +int __init initdom_check_parms(
> + const struct domain *d, const struct elf_dom_parms *parms)
> +{
> + if ( parms->elf_notes[XEN_ELFNOTE_SUPPORTED_FEATURES].type == XEN_ENT_NONE )
> + return 0;
> +
> + if ( is_hardware_domain(d) && !test_bit(XENFEAT_dom0, parms->f_supported) )
> + {
> + printk("Kernel does not support Dom0 operation\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
Merely as a remark - personally I would have made a function like this return a
boolean. Both call sites would imo benefit from that.
Jan
© 2016 - 2026 Red Hat, Inc.