From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH] xen: domain_update_node_affinity: Correct the ASSERT Date: Fri, 25 Jul 2014 16:48:00 +0100 Message-ID: <53D27C30.7020908@linaro.org> References: <1406302204-13992-1-git-send-email-julien.grall@linaro.org> <53D27B5F.8020002@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XAhj3-0006P6-U9 for xen-devel@lists.xenproject.org; Fri, 25 Jul 2014 15:48:06 +0000 Received: by mail-we0-f179.google.com with SMTP id u57so4471470wes.24 for ; Fri, 25 Jul 2014 08:48:04 -0700 (PDT) In-Reply-To: <53D27B5F.8020002@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper , xen-devel@lists.xenproject.org Cc: Juergen Gross , Keir Fraser , ian.campbell@citrix.com, tim@xen.org, Dario Faggioli , Ian Jackson , George Dunlap , stefano.stabellini@citrix.com, Jan Beulich List-Id: xen-devel@lists.xenproject.org On 07/25/2014 04:44 PM, Andrew Cooper wrote: > On 25/07/14 16:30, Julien Grall wrote: >> The commit "move domain to cpupool0 before destroying it" make Xen crashes >> when a domain is destroyed with d->vcpus allocated but no VCPU initialized. >> >> Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 >> Xen call trace: >> [<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC) >> [<00000004>] 00000004 (LR) >> [<00226870>] sched_move_domain+0x3cc/0x42c >> [<0020925c>] domain_kill+0xc8/0x178 >> [<00206a0c>] do_domctl+0xaac/0x15e4 >> [<002529c0>] do_trap_hypervisor+0xc5c/0xf94 >> [<002559f0>] return_from_trap+0/0x4 >> >> Fix the ASSERT to check if d->vcpu is allocated and VCPU 0 is initialized. >> >> Signed-off-by: Julien Grall >> Cc: George Dunlap >> Cc: Dario Faggioli >> Cc: Juergen Gross >> Cc: Ian Campbell >> Cc: Ian Jackson >> Cc: Jan Beulich >> Cc: Keir Fraser >> Cc: Tim Deegan >> >> --- >> This patch should be backported to Xen 4.4 >> --- >> xen/common/domain.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/xen/common/domain.c b/xen/common/domain.c >> index d7a84cf..188b769 100644 >> --- a/xen/common/domain.c >> +++ b/xen/common/domain.c >> @@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) >> } >> /* Filter out non-online cpus */ >> cpumask_and(dom_cpumask, dom_cpumask, online); >> - ASSERT(!cpumask_empty(dom_cpumask)); >> + ASSERT( !d->vcpu || !d->vcpu[0] || !cpumask_empty(dom_cpumask)); > > You don't actually care for the vcpu pointers themselves. You only care > whether the domain has vcpus. > > d->max_vcpus == 0 is a more appropriate check. Actually no... max_vcpus has been set before Xen is allocating alloc_vcpu (see DOMCTL_max_vpus in common common/domctl.c). So if Xen fails to allocate VCPU0, the hypervisor will still crash when the domain is killed. Regards, -- Julien Grall