Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE391C00523 for ; Wed, 8 Jan 2020 10:45:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A600D205F4 for ; Wed, 8 Jan 2020 10:45:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A600D205F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ip8pl-0000d8-CI; Wed, 08 Jan 2020 10:45:05 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ip8pj-0000cw-E5 for xen-devel@lists.xenproject.org; Wed, 08 Jan 2020 10:45:03 +0000 X-Inumbo-ID: ec709b4a-3203-11ea-ad7a-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ec709b4a-3203-11ea-ad7a-12813bfff9fa; Wed, 08 Jan 2020 10:45:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CEFF5AD54; Wed, 8 Jan 2020 10:45:01 +0000 (UTC) To: Tao Xu , xen-devel@lists.xenproject.org References: <764d3c88-ce22-c968-9169-896892aa55e5@intel.com> <61d03b85-fd54-f6a0-dcd5-8fda2194a9f0@suse.com> <2a111e1a-9016-7488-1e48-4ac2e2e34351@intel.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <4d2c8710-e544-3f9b-a036-5dab073d46bf@suse.com> Date: Wed, 8 Jan 2020 11:45:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <2a111e1a-9016-7488-1e48-4ac2e2e34351@intel.com> Content-Type: multipart/mixed; boundary="------------74F0E2186D38737332F849E7" Content-Language: en-US Subject: Re: [Xen-devel] [BUG] XEN crash and double fault when doing cpu online/offline X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is a multi-part message in MIME format. --------------74F0E2186D38737332F849E7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 08.01.20 09:32, Tao Xu wrote: > > On 1/8/20 3:50 PM, Jürgen Groß wrote: >> On 08.01.20 06:50, Tao Xu wrote: >>> Hi, >>> >>> When I use xen-hptool cpu-offline/cpu-online to let CPU in a socket >>> online/offline using the script as follows: >>> >>> for((j=48;j<=95;j++)); >>> do >>>    xen-hptool cpu-offline $j >>> done >>> >>> for((j=48;j<=95;j++)); >>> do >>>    xen-hptool cpu-online $j >>> done >>> >>> Xen crash when cpu re-online. I use the upstream XEN(0dd92688) and >>> try many days, it still crash. But if I only do cpu online/offline >>> for CPU 48~59, Xen will not crash. The bug can be reproduced when we >>> do cpu online/offline for most CPU in a socket. And interesting thing >>> is when we use the script as follow: >>> >>> for((j=48;j<=95;j++)); >>> do >>>    xen-hptool cpu-offline $j >>>    xen-hptool cpu-online $j >>> done >>> >>> Xen will not crash too. Is there a bug in sched_credit2? >>> >>> The crash message as follows: >>> >>> (XEN) Adding cpu 77 to runqueue 1 >>> (XEN) Adding cpu 78 to runqueue 1 >>> (XEN) Adding cpu 79 to runqueue 1 >>> (XEN) Adding cpu 80 to runqueue 1 >>> (X(ENXE) N) *** DOUBLE FAULT *** >>> (XEN) Assertion 'debug->cpu == smp_processor_id()' failed at >>> spinlock.c:88 >>> (XEN) ----[ Xen-4.14-unstable  x86_64  debug=y   Not tainted ]---- >>> (XEN) Debugging connection not set up. >>> (XEN) CPU:    48 >>> (XEN) ----[ Xen-4.14-unstable  x86_64  debug=y   Not tainted ]---- >>> (XEN) CPU:    0 >>> (XEN) RIP:    e008:[] _spin_unlock+0x40/0x42 >> >> So the original problem causes a double fault, but spinlock debugging >> causes a subsequent panic. >> >> Can you please retry the tests with the attached patch? It should >> result in diagnostic data related to the real problem. >> >> >> Juergen > > Hi Juergen, > > After apply your patch, spin_lock still assert. And the address > ffff82d0bffce880 is not in the xen-syms. Yes, I had a bug in my modified ASSERT(), but this time the data is better. > > (XEN) Adding cpu 78 to runqueue 1 > (XEN) *** DOUBLE FAULT *** > (XEN) ----[ Xen-4.14-unstable  x86_64  debug=y   Not tainted ]---- > (XEN) CPU:    49 > (XEN) RIP:    e008:[] ffff82d0bffce880 This seems to be a crash in the stub page of cpu 48. I don't think this is related to the scheduler, but to stub page handling. Can you please try the attached patch? Juergen --------------74F0E2186D38737332F849E7 Content-Type: text/x-patch; charset=UTF-8; name="0001-xen-x86-clear-per-cpu-stub-page-information-in-cpu_s.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0001-xen-x86-clear-per-cpu-stub-page-information-in-cpu_s.pa"; filename*1="tch" From 6067e84192b1c5aaa4675437c3d2a743d18c7c7d Mon Sep 17 00:00:00 2001 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Date: Wed, 8 Jan 2020 11:41:17 +0100 Subject: [PATCH] xen/x86: clear per cpu stub page information in cpu_smpboot_free() cpu_smpboot_free() removes the stubs for the cpu going offline, but it isn't clearing the related percpu variables. This will result in crashes when a stub page is released due to all related cpus gone offline and one of those cpus going online later. Fix that by clearing stubs.addr and stubs.mfn in order to allocate a new sub page when needed. Signed-off-by: Juergen Gross --- xen/arch/x86/smpboot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 7e29704080..46c0729214 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -945,6 +945,8 @@ static void cpu_smpboot_free(unsigned int cpu, bool remove) (per_cpu(stubs.addr, cpu) | ~PAGE_MASK) + 1); if ( i == STUBS_PER_PAGE ) free_domheap_page(mfn_to_page(mfn)); + per_cpu(stubs.addr, cpu) = 0; + per_cpu(stubs.mfn, cpu) = 0; } FREE_XENHEAP_PAGE(per_cpu(compat_gdt, cpu)); -- 2.16.4 --------------74F0E2186D38737332F849E7 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcKaHR0cHM6Ly9saXN0 cy54ZW5wcm9qZWN0Lm9yZy9tYWlsbWFuL2xpc3RpbmZvL3hlbi1kZXZlbA== --------------74F0E2186D38737332F849E7--