From patchwork Thu Apr 6 04:55:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9666027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B87DE602B8 for ; Thu, 6 Apr 2017 04:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A361B28533 for ; Thu, 6 Apr 2017 04:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93A6928581; Thu, 6 Apr 2017 04:58:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1459627317 for ; Thu, 6 Apr 2017 04:58:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvzTI-0000nG-Ug; Thu, 06 Apr 2017 04:56:36 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvzTH-0000mu-Tx for xen-devel@lists.xen.org; Thu, 06 Apr 2017 04:56:36 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id E6/C2-14551-38AC5E85; Thu, 06 Apr 2017 04:56:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXS1tYhodt06mm EQct2I4slHxezODB6HN39mymAMYo1My8pvyKBNaP/yEfGgsdiFZs/X2JqYDwh3MXIycEicItJ Yt2Wii5GLg4hgWmMEnv7FrCDJCQEeCWOLJvBCmEHSDyZtYUFoqiXUeL5x+1MIAk2AX2JFY8Pg hWJCEhLXPt8mRHEZhaolpi28hwbiC0s4CBxa9MndohtqhKdx36CxXkFbCSeT/3KBrFAXuLC1V MsIDangK3E7D1PwGYKAdVcmH6SfQIj3wJGhlWMGsWpRWWpRbpGlnpJRZnpGSW5iZk5uoYGxnq 5qcXFiempOYlJxXrJ+bmbGIGBUs/AwLiDsWmv3yFGSQ4mJVFeBZ8nEUJ8SfkplRmJxRnxRaU5 qcWHGGU4OJQkeLNOPo0QEixKTU+tSMvMAYYsTFqCg0dJhPcOSJq3uCAxtzgzHSJ1ilFRSpw3B SQhAJLIKM2Da4PFySVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwrzbQKbwZOaVwE1/BbSYCW jxkzsPQRaXJCKkpBoYVf/Krst5q7Cm9NbR0yWXslgydib9ljbJi7Zd05W9rPCiZvsfw11pmTd meYvWq5bf/hM81US2oLpKVCf5cMKUjJg+uZmiK93nuZTUSNgL534VNtXaM+ej9v+ZyyadW3Xo RfXHqYmNNtluk1Qv5HyPy2ZUKj/3/rDMtpP2E6pL9h75sS3axUZOiaU4I9FQi7moOBEAFyyXt Y4CAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1491454591!86900910!2 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25028 invoked from network); 6 Apr 2017 04:56:34 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-7.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Apr 2017 04:56:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491454594; x=1522990594; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=SJXyNX+/GFch/Qg8oSzRHnmEroJxA4+DKYJrvZxUS1g=; b=oa+jxdegXmXK3uMQJV/jw3p589LiyVE49TFy8sexSy5Di/cDPZUfQTU9 MAj3HqbsMAdimcVW23YTqCaUTRJVAw==; Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2017 21:56:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.37,282,1488873600"; d="scan'208"; a="1116051624" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.153]) by orsmga001.jf.intel.com with ESMTP; 05 Apr 2017 21:56:31 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Thu, 6 Apr 2017 12:55:37 +0800 Message-Id: <20170406045537.1573-2-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170406045537.1573-1-haozhong.zhang@intel.com> References: <20170406045537.1573-1-haozhong.zhang@intel.com> Cc: Andrew Cooper , Jan Beulich , Haozhong Zhang Subject: [Xen-devel] [PATCH 2/2] xen/mce: fix static variable 'severity_cpu' X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 1. Distinguish 'severity_cpu' used in mcheck_cmn_handler() and mce_softirq(), which should be different variables. Otherwise, they may interfere with each other if MC# comes during mce_softirq(). 2. Always (re-)initialize 'severity_cpu' to clear historical information. Signed-off-by: Haozhong Zhang --- xen/arch/x86/cpu/mcheck/mce.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 7618120..d9ab80a 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -177,7 +177,7 @@ void mce_need_clearbank_register(mce_need_clearbank_t cbfunc) static struct mce_softirq_barrier mce_inside_bar, mce_severity_bar; static struct mce_softirq_barrier mce_trap_bar; -static struct mce_softirq_barrier mce_handler_init_bar; +static struct mce_softirq_barrier mce_handler_init_bar, mce_softirq_init_bar; /* * mce_logout_lock should only be used in the trap handler, @@ -187,8 +187,6 @@ static struct mce_softirq_barrier mce_handler_init_bar; */ static DEFINE_SPINLOCK(mce_logout_lock); -static atomic_t severity_cpu = ATOMIC_INIT(-1); - const struct mca_error_handler *__read_mostly mce_dhandlers; const struct mca_error_handler *__read_mostly mce_uhandlers; unsigned int __read_mostly mce_dhandler_num; @@ -452,7 +450,7 @@ static int mce_urgent_action(const struct cpu_user_regs *regs, /* Shared #MC handler. */ void mcheck_cmn_handler(const struct cpu_user_regs *regs) { - static atomic_t found_error; + static atomic_t severity_cpu, found_error; static cpumask_t mce_fatal_cpus; struct mca_banks *bankmask = mca_allbanks; struct mca_banks *clear_bank = __get_cpu_var(mce_clear_banks); @@ -461,6 +459,7 @@ void mcheck_cmn_handler(const struct cpu_user_regs *regs) struct mca_summary bs; mce_barrier_enter(&mce_handler_init_bar); + atomic_set(&severity_cpu, -1); atomic_set(&found_error, 0); cpumask_clear(&mce_fatal_cpus); mce_barrier_exit(&mce_handler_init_bar); @@ -1704,11 +1703,16 @@ static int mce_delayed_action(mctelem_cookie_t mctc) /* Softirq Handler for this MCE# processing */ static void mce_softirq(void) { + static atomic_t severity_cpu; int cpu = smp_processor_id(); unsigned int workcpu; mce_printk(MCE_VERBOSE, "CPU%d enter softirq\n", cpu); + mce_barrier_enter(&mce_softirq_init_bar); + atomic_set(&severity_cpu, -1); + mce_barrier_exit(&mce_softirq_init_bar); + mce_barrier_enter(&mce_inside_bar); /* @@ -1774,6 +1778,7 @@ void mce_handler_init(void) mce_barrier_init(&mce_severity_bar); mce_barrier_init(&mce_trap_bar); mce_barrier_init(&mce_handler_init_bar); + mce_barrier_init(&mce_softirq_init_bar); spin_lock_init(&mce_logout_lock); open_softirq(MACHINE_CHECK_SOFTIRQ, mce_softirq); }