[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen/x86: Check supported features even for PVH dom0


  • To: Frediano Ziglio <freddy77@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 3 Apr 2026 12:11:00 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MIjkorNB9CPnV6O+GF6fe4Ge+rZOSD9pos/2Nuym3Z4=; b=gkmSFwUsKoyloJZ4r3IMv58hVfg7n3GRR+VLWZlv3J0Nd3R//7xeQmow6NZJSAycAh2vTqmcw8yt1+WvvY5frKBELF6Ccg+hl/aq2zHEfeVysLphh/udmnZu5i1mKH+tCGhH2pvpf7RJ00EHArCRJwcCw6TXG4moT/hS2CzjJpmloeJ1JTuLd8CU3SEJygeFhN2XebimIY8BvNFMUaIlSbvnaoM3EkiF4yWDojpzZExusXtuX5n7f5Et0XRYv3gGZA7g+Xu3DnCh/CjuEXltIvgBMNHUnVW5cgmHyw+Y4WM/PfeEs1HIqNMtpnibG1NRaqecK0BRJj+a4/NGyJ/JHg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QzXJdjS6Q46QCYEgJbRIl1sYBfTOfCpPCD8UbYtwRxUFSarY7bthALAXdSNzIoSCadFqoLZcxjxJNkLL95jrA2vepfyqpiJCLys2WQ6dAvdkqmnnmo2Tthogb3HtY/+7zUvC1bp0qJLcaYKlhiwnCnmJK6YYa3kt58BHLrThRItm6Pcgs1Fb6b6CekYNliMAOlUwtI/zVLy9hs97A0VJUwftocgFXQlsIOQBnG4fakguz0uPQ5TZaoXbW/HmTRPVVEFbfCg+lL1H5zMTeRCBFBEyNSWDEPlnukQRKrzZbCmEn6uRDGfQtE813aSilYJ3ua64gAnxKb1Icluoaf8xew==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Frediano Ziglio <frediano.ziglio@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Fri, 03 Apr 2026 10:11:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.