Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1355695imc; Mon, 11 Mar 2019 11:52:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTKBAjdyJ0YlZ00lnBPAUumVAwn9kO4EVCBeq6pETaM37WSSL9AbKEq/qewIXmpv+USSUL X-Received: by 2002:a62:11c6:: with SMTP id 67mr34187209pfr.68.1552330346398; Mon, 11 Mar 2019 11:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552330346; cv=none; d=google.com; s=arc-20160816; b=ni6JI+yRLYIUi8kOG498DUTosSBrPg3h8BEa28sXWVXEwmmw+OI8UIMJUt6lBsMLGD yyq7yoyq/4RQIaiesVYIjwfczvXJp3MlihAmtO5Hc+Z40jcra1ir5Dg4ttejoa11fvrG sYdOK1VN+RN1yDmMhSBsJso1sSh8QrQVXcxYRLhH8+eq0a7q6yBNSpnXt147fCX3LCp2 nCKktDQmzBvvRq9tNQNXxywhGDTu6wl6r4UWSKJob51PAmqjufsAw8/PArS/+GUzShSg uwHE6OpFt4RiCbm7KpoHWaI/dLrKL1JHKzGWzoAQIK9ZYlnquuUbLa1fbNk9bXDsGiVu ZrMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7rny8xQHBHyXql0LaVRqp66jpRYcY2rg6xaV2RWkMng=; b=VIkyZjvJKJA1KknpresvyKghjKTzdgkTjBHhXcKTY10iPUYvXK2HvUeViarvGzyQs0 V5ys5788jYJWQAY6zyQwpu11GIo6eDPdOOrTp+SsfrVsRrp5exGFI/hIlTCbHyT3i8/8 SGKTluruNS6iCfOa/AajlkMv0WAC8/Lrsx3KCY7Ca3a+3tn/cutK9NEs6iegUGRfpswV Ch5TrMzDQHOD/4FYJyEX4dmH/jpkgLQkaCBDvkCKO2i774+iplE/ocX/k/DbyJO2mTWa B1MvUk7s8MgW5Y2UOM1O3NdAMYSgIQ/Prjlx3S/aKBz1ktTH2qoxu7+hxrwPvwuc56oO dSfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id cv7si6175883plb.322.2019.03.11.11.52.11; Mon, 11 Mar 2019 11:52:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728153AbfCKSvT (ORCPT + 99 others); Mon, 11 Mar 2019 14:51:19 -0400 Received: from mga01.intel.com ([192.55.52.88]:21034 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726942AbfCKSvS (ORCPT ); Mon, 11 Mar 2019 14:51:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2019 11:51:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,468,1544515200"; d="scan'208";a="326310855" Received: from agluck-desk.sc.intel.com ([10.3.52.160]) by fmsmga006.fm.intel.com with ESMTP; 11 Mar 2019 11:51:18 -0700 From: Tony Luck To: Borislav Petkov Cc: Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org, Ashok Raj Subject: [PATCH] x86, mce: Fix machine_check_poll() tests for which errors to log Date: Mon, 11 Mar 2019 11:51:18 -0700 Message-Id: <20190311185118.32667-1-tony.luck@intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There has been a lurking "TBD" in the machine check poll routine ever since it was first split out from the machine check handler. The potential issue is that the poll routine may have just begun a read from the STATUS register in a machine check bank when the hardware logs an error in that bank and signals a machine check. That race used to be pretty small back when machine checks were broadcast, but the addition of local machine check means that the poll code could continue running and clear the error from the bank before the local machine check handler on another CPU gets around to reading it. Fix the code to be sure to only process errors that need to be processed in the poll code, leaving other logged errors alone for the machine check handler to find and process. Fixes: b79109c3bbcf ("x86, mce: separate correct machine check poller and fatal exception handler") Fixes: ed7290d0ee8f ("x86, mce: implement new status bits") Reported-by: Ashok Raj Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 42 ++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 6ce290c506d9..806551b381ae 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -712,19 +712,47 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b) barrier(); m.status = mce_rdmsrl(msr_ops.status(i)); + + /* If this entry is not valid, ignore it */ if (!(m.status & MCI_STATUS_VAL)) continue; /* - * Uncorrected or signalled events are handled by the exception - * handler when it is enabled, so don't process those here. - * - * TBD do the same check for MCI_STATUS_EN here? + * If we are logging everything (at CPU online) or this + * is a corrected error, then we must log it. */ - if (!(flags & MCP_UC) && - (m.status & (mca_cfg.ser ? MCI_STATUS_S : MCI_STATUS_UC))) - continue; + if ((flags & MCP_UC) || (m.status & MCI_STATUS_UC) == 0) + goto log_it; + + /* + * Older systems that do not support software error recovery + * should skip over uncorrected errors, but log everything else + */ + if (!mca_cfg.ser) { + if (m.status & MCI_STATUS_UC) + continue; + goto log_it; + } + + /* Log "not enabled" (speculative) errors */ + if (!(m.status & MCI_STATUS_EN)) + goto log_it; + + /* + * Log UCNA (SDM: 15.6.3 "UCR Error Classification") + * UC == 1 && PCC == 0 && S == 0 + */ + if (!(m.status & MCI_STATUS_PCC) && !(m.status & MCI_STATUS_S)) + goto log_it; + + /* + * Skip anything else. Presumption is that our read of this + * bank is racing with a machine check. Leave the log alone + * for do_machine_check() to deal with it. + */ + continue; +log_it: error_seen = true; mce_read_aux(&m, i); -- 2.19.1