On 03.04.2025 23:46, Jason Andryuk wrote:
> From: "Daniel P. Smith" <dpsm...@apertussolutions.com>
> 
> Add and use a new internal create domain flag to specify the hardware
> domain.  This removes the hardcoding of domid 0 as the hardware domain.
> 
> This allows more flexibility with domain creation.
> 
> Signed-off-by: Daniel P. Smith <dpsm...@apertussolutions.com>
> Signed-off-by: Jason Andryuk <jason.andr...@amd.com>
> Reviewed-by: Jan Beulich <jbeul...@suse.com>
> ---
> v3:
> Or-in CDF_hardware for late hwdom case

Except that ...

> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -820,13 +820,18 @@ struct domain *domain_create(domid_t domid,
>      d->is_privileged = flags & CDF_privileged;
>  
>      /* Sort out our idea of is_hardware_domain(). */
> -    if ( domid == 0 || domid == hardware_domid )
> +    if ( (flags & CDF_hardware) || domid == hardware_domid )
>      {
>          if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED )
>              panic("The value of hardware_dom must be a valid domain ID\n");
>  
> +        /* late_hwdom is only allowed for dom0. */
> +        if ( hardware_domain && hardware_domain->domain_id )
> +            return ERR_PTR(-EINVAL);
> +
>          old_hwdom = hardware_domain;
>          hardware_domain = d;
> +        flags |= CDF_hardware;
>      }

... this isn't quite enough. You're only modifying what will go out of scope
when returning from the function. What's at least equally important to OR into
is d->cdf.

Jan

Reply via email to