Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2264438imc; Tue, 12 Mar 2019 10:10:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwITZaRUMcyb+OgMteI1A6XwKtGAh3BRN6m8Ht/DySGbkNlxvy3LMgWyn5zZrcDANiRcEsv X-Received: by 2002:a63:7e0e:: with SMTP id z14mr36084834pgc.436.1552410636890; Tue, 12 Mar 2019 10:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552410636; cv=none; d=google.com; s=arc-20160816; b=XmDZC+jZaompMQ3H4pQ9DiZR4xdk3clLbVPhPX0OmyAI+xQbFbhMrBFrUC12myMX6I FoJ8YUb2173Gf+cLrNXIdjnUGJ0nHw61HXrjs5NUAIvVgo2aX10aLGn9MJfZnfJ8AUcj Csz2JU3zry75pbr7mHkgldpg+IfrpC3ORIUtQlgFCWwaPmgYoZxdGA7xbDTERYhXxU+7 DRWIj6TpN/lYgdvQJIdntHpo4dS8Kn3qULTRL3xNtu3lW3EFFeXXitycGc5xac2QkZg/ SY0QqsY4/0Ee6hBbdfkW90q+pEBDPXtK6JLToMF2dj2YnjbdSjDr7dzAbLNC8NXT2vo7 7XMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=V7r4sV+W4bKWzXQI2X5QNJGVFbEN7BLUnKnUwz0mCsc=; b=wWKmQVyDxplV1ppargkB5BTh0QYgXkJBPZ2JPXWEpUyVPpKStSOgyxb7eGriKYBiXa 7JCcowsIm16O1KM21zBp5OC8Wrx+RtdXFVXejjxpWYyf5ObCaU+3GRy//g99X3hKCZUX V6ajaTBH1BqAqzTIBTvlpFwuCxfSbRs/gGy8wEMyChjB1i/vMrym+n5rlpeRHLOnTKks d68JSRRAsnmbPYDy0rvsRL6Vk65t0SxLjxfj3XVo59O491HQ/0NmlCeoq62EgI7PbRFK MyJLjZGLT6KpFMV+/0qwrDQ25baqj6WFzapfh6FcP++36ITYNTcy+pPn2hj+nr++20x4 sY4Q== 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 h9si2428268pfj.70.2019.03.12.10.10.20; Tue, 12 Mar 2019 10:10:36 -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 S1726643AbfCLRJk (ORCPT + 99 others); Tue, 12 Mar 2019 13:09:40 -0400 Received: from mga01.intel.com ([192.55.52.88]:58030 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbfCLRJj (ORCPT ); Tue, 12 Mar 2019 13:09:39 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2019 10:09:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,471,1544515200"; d="scan'208";a="141381808" Received: from agluck-desk.sc.intel.com (HELO agluck-desk) ([10.3.52.160]) by orsmga002.jf.intel.com with ESMTP; 12 Mar 2019 10:09:38 -0700 Date: Tue, 12 Mar 2019 10:09:38 -0700 From: "Luck, Tony" To: Borislav Petkov Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Ashok Raj , "Ghannam, Yazen" Subject: [PATCH v2] x86, mce: Fix machine_check_poll() tests for which errors Message-ID: <20190312170938.GA23035@agluck-desk> References: <20190311185118.32667-1-tony.luck@intel.com> <20190311204217.GA1810@agluck-desk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 --- V2: Update comment to make it clear that only Intel CPUs with software error recovery reach the final few tests on whether to log. arch/x86/kernel/cpu/mce/core.c | 44 ++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 6ce290c506d9..663e8b82eacc 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -712,19 +712,49 @@ 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; + + /* + * Newer Intel systems that support software error + * recovery need to make additional checks. Other + * CPUs 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