|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] xen/x86: Check supported features even for PVH dom0
On Fri, 3 Apr 2026 at 11:11, Roger Pau Monné <roger.pau@xxxxxxxxxx> wrote:
>
> On Thu, Apr 02, 2026 at 04:55:10PM +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@xxxxxxxxx>
> > --
> > 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.
> > ---
> > 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..a33ce77321 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 dom0_check_parms(
> > + struct domain *d, const struct elf_dom_parms *parms)
>
> d should be const also.
>
> > +{
> > + 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..f95a00acfd 100644
> > --- a/xen/arch/x86/hvm/dom0_build.c
> > +++ b/xen/arch/x86/hvm/dom0_build.c
> > @@ -699,6 +699,9 @@ static int __init pvh_load_kernel(
> > if ( !check_and_adjust_load_address(d, &elf, &parms) )
> > return -ENOSPC;
> >
> > + if ( (rc = dom0_check_parms(d, &parms)) != 0 )
> > + return rc;
>
> I would do the check ahead of check_and_adjust_load_address(), as then
> we could avoid the load address adjustment if we detect earlier than
> the dom0 feature is not present. But that's just my taste.
>
> I can adjust the const-ification of d on commit if there are no
> further objections:
>
> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>
> Thanks, Roger.
Fine with me.
Frediano
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |