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

Re: [PATCH] xen/sched: fix sched_move_domain() for domain without vcpus


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 6 Sep 2021 13:23:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=P10PInH1DfhGLms21QzcUomgnt98pv9+SUigsNNpRbw=; b=ctIUMbPmrAqRPB2SMPfaizx+Dr7nyPBafW3aTN47XsS9fOIzSeciOgSbO3X2/QugePwO0VAp+OVA3OygUEIznoYa8qjcdj6c2vylTo1bA91UHz68TrPpfhO5l+aO+JreUMa8KLhADmGBmvKBYsoUpiAXtBbg4i//t7lQu6j9cigffc7tn06rwD74ED8rKAe70/yh3nxxuUNNfQkhsd5h4EgaaQbJCMyJ8H7KupQhSNHsd/DYbpYDvXaM4sMpG+7rJdqTW0YXfvoZKoDKBKevkCrVwsLui8msaoU8lHbzyQDzdReZlee2PfI669jvkIrNFPbxcKK+7phl0RS5GRuRrA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nv4AqZAEXed4h/4/31nXsI8HDGBgLiqohdxyp7hkBikhUv74YGeNmwk618m+7Z81++uXeQvZSOTdcfQNqU4xqBQfJAaaE3Pk4nu9cvSQg04WG8F6eP3lNG//PxpVcoT3rAJa+2K00b8nz67uI2uS71M4gADgZ7eRE1Xaj4TvB5QVK60SXXvGf8Z/dh6sfHdWYTmVfdX8rQj+fZ1QIUznaUB4uiAkyJlozRHBRuuIvKXFofzhfS5gzokETtGclqLFbZ1TcNQpcyqvjODBnz3mjPpHGLp5qB1bu/1izvywnGE+4zRfon5cYCREjfFOZRecUz31mm6kf5NfhsvsW8DZFQ==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 06 Sep 2021 11:23:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.09.2021 13:18, Andrew Cooper wrote:
> On 06/09/2021 12:14, Andrew Cooper wrote:
>> On 06/09/2021 12:00, Juergen Gross wrote:
>>> In case a domain is created with a cpupool other than Pool-0 specified
>>> it will be moved to that cpupool before any vcpus are allocated.
>>>
>>> This will lead to a NULL pointer dereference in sched_move_domain().
>>>
>>> Fix that by tolerating vcpus not being allocated yet.
>>>
>>> Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between 
>>> cpupools with different granularity")
>>> Reported-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>>> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>>> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
>>> ---
>>>  xen/common/sched/core.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
>>> index 8d178baf3d..79c9100680 100644
>>> --- a/xen/common/sched/core.c
>>> +++ b/xen/common/sched/core.c
>>> @@ -671,6 +671,10 @@ int sched_move_domain(struct domain *d, struct cpupool 
>>> *c)
>>>  
>>>      for ( unit_idx = 0; unit_idx < n_units; unit_idx++ )
>>>      {
>>> +        /* Special case for move at domain creation time. */
>>> +        if ( !d->vcpu[unit_idx * gran] )
>>> +            break;
>>> +
>>>          unit = sched_alloc_unit_mem();
>>>          if ( unit )
>>>          {
>> I think the logic would be clearer if you wrap the entire for loop in if
>> ( d->max_vcpus ).
> 
> And of course, this is wrong.  Turns out the domain_has_vcpus()
> predicate still hasn't been committed, but d->vcpu[0] is the correct
> internal.

Which in turn might want to be done by setting n_units to zero when
d->vcpus[0] is NULL?

Jan




 


Rackspace

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