Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp398468pxb; Wed, 18 Nov 2020 07:20:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzviTZuA9DQs2QQju7S6TuMCPmaLHAosW+dshT5Fi/ym2QHam/oURtxV3uTCKFhBG2SuIS0 X-Received: by 2002:a50:aa84:: with SMTP id q4mr27773885edc.331.1605712836919; Wed, 18 Nov 2020 07:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605712836; cv=none; d=google.com; s=arc-20160816; b=YflyygwG7cQJ3zJHdt3hk1JJVeFLYYVjc2WIx6c1XiQKTVtSvp2+hTe09FqjT6ycRr cKY5YoJ/kDx/gV9wctMcLNzfnqnUQp01RXJzQiE0K5LvqH+fEb4c46PUh5zkrOpcTnoE kVV2Q2gq3WWtyouUUp776Qy/VGcWLyfVYzb64sedwbydd5YFTufs6CVTwLI5RfBDaDxc aLQvGvCmBFeLkGZ7Lja+2jkcLFbyTx9m27M4yIzH49Rx4b78WKV2G+z20MS346BiimN1 q4VzCWSymCmlVYMMklRdPBzWhjdM0zu1wH4BB5ihU04KlJOxPoRxBW4AnX1Pd7Q+fKGR tlZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=A+w8TZjv6WtHz9X+Ynh+2M+XtsB6jqWf1GTXKHbLgPQ=; b=KilJfQCvMtAdpKoKkPF9T5Rk20EaBXRHnIC6alt/bQ2+2U34Y6WJ5HL2sC1+7knA7w b0Yj/AZHurljpSOLztZquevpRHwFFBnJ15PsLfeKezs4nFy5nXrur6hvi33obLtdUP7Q VTp94GCd5w6WrLQDs04mXLjgAyVElkpqA5Drj4GrBMMTjzpuvIiE56qVmFxKN9w2nNr5 ZgHKvDgG+GG7j+v0+8s9zqaO9g7qMt2iLDOgSVwkwhGz8QsY+Ovz9ID/7lePiUojjQf0 FLFEAT1WuOymYRVidEv80atyTyBQderBqSMaFODbSZGzT3cbKOS8GgQF1sVLR4PTtbsG +Tmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si1411414edu.498.2020.11.18.07.20.13; Wed, 18 Nov 2020 07:20:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727239AbgKRPQG (ORCPT + 99 others); Wed, 18 Nov 2020 10:16:06 -0500 Received: from mga12.intel.com ([192.55.52.136]:8041 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbgKRPQF (ORCPT ); Wed, 18 Nov 2020 10:16:05 -0500 IronPort-SDR: K3HjGX1a54vaJlemn/4Jm/oaECa4wSLVdar+mMdAAk6DOHJmqdL/ag869B4F2qQuf5oZNtbyZs reHre9+wqiEA== X-IronPort-AV: E=McAfee;i="6000,8403,9808"; a="150399361" X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="150399361" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 07:16:03 -0800 IronPort-SDR: YsAkNBARL3HuPONP6kRUnF11yeoR3+ZaUcpZskIYpOJG2DWYRZUtTZ+eTWadQ2Lq3sjmZnV/4z mSsF6lGpIX9Q== X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="359492091" Received: from paolonig001.ir.intel.com ([163.33.183.93]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 07:16:01 -0800 From: Gabriele Paoloni To: tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gabriele.paoloni@intel.com, linux-safety@lists.elisa.tech Subject: [PATCH 2/4] x86/mce: move the mce_panic() call and kill_it assignments at the right places Date: Wed, 18 Nov 2020 15:15:50 +0000 Message-Id: <20201118151552.1412-3-gabriele.paoloni@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201118151552.1412-1-gabriele.paoloni@intel.com> References: <20201118151552.1412-1-gabriele.paoloni@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Right now for local MCEs we panic(),if needed, right after lmce is set. For global MCEs mce_reign() takes care of calling mce_panic(). Hence this patch: - improves readibility by moving the conditional evaluation of tolerant up to when kill_it is set first - moves the mce_panic() call up into the statement where mce_end() fails Signed-off-by: Gabriele Paoloni Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index b990892c6766..e025ff04438f 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1350,8 +1350,7 @@ noinstr void do_machine_check(struct pt_regs *regs) * severity is MCE_AR_SEVERITY we have other options. */ if (!(m.mcgstatus & MCG_STATUS_RIPV)) - kill_it = 1; - + kill_it = (cfg->tolerant == 3) ? 0 : 1; /* * Check if this MCE is signaled to only this logical processor, * on Intel, Zhaoxin only. @@ -1384,8 +1383,15 @@ noinstr void do_machine_check(struct pt_regs *regs) * When there's any problem use only local no_way_out state. */ if (!lmce) { - if (mce_end(order) < 0) + if (mce_end(order) < 0) { no_way_out = no_way_out ? no_way_out : worst >= MCE_PANIC_SEVERITY; + /* + * mce_reign() has probably failed hence evaluate if we need + * to panic + */ + if (no_way_out && mca_cfg.tolerant < 3) + mce_panic("Fatal machine check on current CPU", &m, msg); + } } else { /* * If there was a fatal machine check we should have @@ -1401,15 +1407,6 @@ noinstr void do_machine_check(struct pt_regs *regs) } } - /* - * If tolerant is at an insane level we drop requests to kill - * processes and continue even when there is no way out. - */ - if (cfg->tolerant == 3) - kill_it = 0; - else if (no_way_out) - mce_panic("Fatal machine check on current CPU", &m, msg); - if (worst > 0) irq_work_queue(&mce_irq_work); -- 2.20.1 --------------------------------------------------------------------- INTEL CORPORATION ITALIA S.p.A. con unico socio Sede: Milanofiori Palazzo E 4 CAP 20094 Assago (MI) Capitale Sociale Euro 104.000,00 interamente versato Partita I.V.A. e Codice Fiscale 04236760155 Repertorio Economico Amministrativo n. 997124 Registro delle Imprese di Milano nr. 183983/5281/33 Soggetta ad attivita' di direzione e coordinamento di INTEL CORPORATION, USA This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.