On Thu Jul 31, 2025 at 11:42 AM CEST, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_stras...@epam.com>
>
> The vcpu ctx initialization (arch_set_info_guest()) is depends on proper
                                                       ^
                                                   stray "is"

> domain type (32/64bit) configuration, so check that vcpus are not
> initialized when toolstack issues XEN_DOMCTL_set_address_size hypercall.
>
> Signed-off-by: Grygorii Strashko <grygorii_stras...@epam.com>
> ---
>  xen/arch/arm/arm64/domctl.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/xen/arch/arm/arm64/domctl.c b/xen/arch/arm/arm64/domctl.c
> index 8720d126c97d..82eff26fb0d1 100644
> --- a/xen/arch/arm/arm64/domctl.c
> +++ b/xen/arch/arm/arm64/domctl.c
> @@ -13,6 +13,19 @@
>  #include <asm/arm64/sve.h>
>  #include <asm/cpufeature.h>
>  
> +static bool vcpus_check_initialised(struct domain *d)

nit: I'd call it vcpus_any_initialised(), that way it's far easier to
     see what it does without jumping into the implementation.

> +{
> +    struct vcpu *v;
> +
> +    for_each_vcpu(d, v)
> +    {
> +        if ( v->is_initialised )
> +            return true;
> +    }
> +
> +    return false;
> +}
> +
>  static long switch_mode(struct domain *d, enum domain_type type)
>  {
>      struct vcpu *v;
> @@ -21,6 +34,8 @@ static long switch_mode(struct domain *d, enum domain_type 
> type)
>          return -EINVAL;
>      if ( domain_tot_pages(d) != 0 )
>          return -EBUSY;
> +    if ( vcpus_check_initialised(d) )
> +        return -EBUSY;
>      if ( d->arch.type == type )
>          return 0;
>  


Reply via email to