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

Re: [PATCH v3 11/24] xen/domain: move get_initial_domain_id() to arch-independent header


  • To: dmukhin@xxxxxxxx
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 28 Jan 2025 16:24:56 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 28 Jan 2025 15:25:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04.01.2025 02:58, Denis Mukhin via B4 Relay wrote:
> From: Denis Mukhin <dmukhin@xxxxxxxx>
> 
> Honor 'hardware_domid=' parameter across all architectures

In which way is it not honored right now (besides depending on
LATE_HWDOM=y)? It is, for example, not supposed to be the case that
in a late-hwdom configuration all IDs below hardware_domid are
unavailable for new domains to be created.

> and update
> max_init_domid correctly so that toolstack and, subsequently, console driver
> could iterate across known domains more efficiently.
> 
> Also, move max_init_domid to arch-independent location.
> 
> Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>


> @@ -2387,15 +2388,15 @@ void __init create_dom0(void)
>      if ( !llc_coloring_enabled )
>          flags |= CDF_directmap;
>  
> -    dom0 = domain_create(0, &dom0_cfg, flags);
> +    dom0 = domain_create(domid, &dom0_cfg, CDF_privileged | CDF_directmap);

Why the move from "flags" to "CDF_privileged | CDF_directmap"?

>      if ( IS_ERR(dom0) )
> -        panic("Error creating domain 0 (rc = %ld)\n", PTR_ERR(dom0));
> +        panic("Error creating domain %d (rc = %ld)\n", domid, PTR_ERR(dom0));
>  
>      if ( llc_coloring_enabled && (rc = dom0_set_llc_colors(dom0)) )
>          panic("Error initializing LLC coloring for domain 0 (rc = %d)\n", 
> rc);
>  
>      if ( alloc_dom0_vcpu0(dom0) == NULL )
> -        panic("Error creating domain 0 vcpu0\n");
> +        panic("Error creating domain %d vcpu0\n", domid);

If already you alter this, please switch to %pd.

> @@ -65,6 +68,9 @@ DEFINE_RCU_READ_LOCK(domlist_read_lock);
>  static struct domain *domain_hash[DOMAIN_HASH_SIZE];
>  struct domain *domain_list;
>  
> +/* Last known non-system domain ID. */
> +domid_t __read_mostly max_init_domid;

I'm afraid comment and variable name conflict with one another. And
really with its present purpose it ought to be __ro_after_init, I
think.

> @@ -2261,6 +2267,15 @@ int continue_hypercall_on_cpu(
>      return 0;
>  }
>  
> +domid_t get_initial_domain_id(void)
> +{
> +#ifdef CONFIG_PV_SHIM
> +    if ( pv_shim )
> +        return pv_shim_get_initial_domain_id();
> +#endif

Aiui the #ifdef is necessary for non-x86? Would be nice to avoid that, yet
then I'm not meaning to ask you to do a lot of further rearrangements.

> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -415,10 +415,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
> u_domctl)
>      case XEN_DOMCTL_createdomain:
>      {
>          domid_t        dom;
> -        static domid_t rover = 0;
>  
>          dom = op->domain;
> -        if ( (dom > 0) && (dom < DOMID_FIRST_RESERVED) )
> +        if ( (dom > max_init_domid) && (dom < DOMID_FIRST_RESERVED) )
>          {
>              ret = -EEXIST;
>              if ( !is_free_domid(dom) )
> @@ -426,19 +425,19 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
> u_domctl)
>          }
>          else
>          {
> -            for ( dom = rover + 1; dom != rover; dom++ )
> +            for ( dom = max_init_domid + 1; dom != max_init_domid; dom++ )

The "dom != max_init_domid" is dead code now if I'm no t mistaken, due to ...

>              {
>                  if ( dom == DOMID_FIRST_RESERVED )
> -                    dom = 1;
> +                    dom = max_init_domid + 1;

... this. Thus the loop will become infinite if all permissible domain IDs
are in use. Yet then ...

>                  if ( is_free_domid(dom) )
>                      break;
>              }
>  
>              ret = -ENOMEM;
> -            if ( dom == rover )
> +            if ( dom == max_init_domid )
>                  break;
>  
> -            rover = dom;
> +            max_init_domid = dom;
>          }

... why would all of this code need changing? (If it does, I think that
wants to be in a separate patch, with appropriate description.)

> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -568,6 +568,14 @@ static long xenver_varbuf_op(int cmd, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>      return sz;
>  }
>  
> +static int __init cf_check globals_init(void)
> +{
> +    max_init_domid = get_initial_domain_id();
> +
> +    return 0;
> +}
> +__initcall(globals_init);

Imo this wants to live in the CU defining the variable.

Jan



 


Rackspace

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