On 19.05.2025 21:23, dm...@proton.me wrote:
> From: Denis Mukhin <dmuk...@ford.com>
> 
> Currently, hypervisor code has two different non-system domain ID allocation
> implementations:
> 
>   (a) Sequential IDs allocation in dom0less Arm code based on max_init_domid;
> 
>   (b) Sequential IDs allocation in XEN_DOMCTL_createdomain; does not use
>       max_init_domid (both Arm and x86).
> 
> It makes sense to have a common helper code for such task across architectures
> (Arm and x86) and between dom0less / toolstack domU allocation.
> 
> Wrap the domain ID allocation as an arch-independent function domid_alloc() in
> common/domain.c based on the bitmap.
> 
> Allocation algorithm:
> - If an explicit domain ID is provided, verify its availability and use it if
>   ID is not used;
> - If DOMID_INVALID is provided, perform an exhaustive search within
>   [0..CONFIG_MAX_DOMID-1] range, starting from the last used domain ID.

CONFIG_MAX_DOMID first appears in patch 3 afaics, and hence doesn't want
mentioning here, yet. That patch,for eample, may never make it into the
tree (and thus the description here may be confusing to future readers).

> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -66,6 +66,12 @@ DEFINE_RCU_READ_LOCK(domlist_read_lock);
>  static struct domain *domain_hash[DOMAIN_HASH_SIZE];
>  struct domain *domain_list;
>  
> +/* Non-system domain ID allocator. */
> +#define CONFIG_MAX_DOMID DOMID_FIRST_RESERVED

Oh, wait - you're actually introducing such an identifier. Please don't.
It's bad enough that we still have a few CONFIG_* left which aren't
Kconfig-controlled. We don't want any new ones.

Jan

Reply via email to