Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp253292ybi; Wed, 29 May 2019 20:42:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqhhcsPpe4rWtcO3BJdiS0a1qV/jmm2CMEt3y7znaWQ+b9sWFHfyA0ged8TZIGmp58SsG3 X-Received: by 2002:a17:902:b70b:: with SMTP id d11mr1771996pls.84.1559187773345; Wed, 29 May 2019 20:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187773; cv=none; d=google.com; s=arc-20160816; b=HtzHKwp5103FwfCf0a5UOEP2+/sVHaSc7xj+JaCvd/NMW88VLVH4+l4RQDSnfKC7VL lWdErnaDqvFshGECNjpMRkJ7x8zxAVBY7O5zhhKscdP9aqR84sx0ZnignkcEB8ogLJt+ hG6veUWluhp9nROwDLUZrluxcmavPLvaJdIalZ/Q6FhEN7JK4Sjeckb2EFiHVFKd+rsQ 1S5Bc9Pqvmc4S5d3iZ/5D1lucwOIaQppNiUq6Gaj60dSUbQIWbO+5/QgG+OG4WfydIgZ VCodLlefYlta4x8xmUYggkFjdtgZsBjTsqO1KG8U8RBn5I4T35jVc2/9SuvhUJSdYPUY XeYw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YlROkMkpZZZprGHmltsTcYvRK9wIv1xDg3ABpC1Ugwg=; b=gH4tH67z81XuRxanRffCoga8UzDuS0Pe1S7uRlM8w3rK/bd2l9EI6PU+TLjdgGNqL0 3T8ccJXp5Tz+UPRO9zq4l9aN6RZ6tTFYwexmAwnA7FyJ5MKeVjE+Z1OBkvpyX5TjTRZ+ av5UdNuV/w81qctE+S7QYCMN+Na2H/W6GSiS8n01JjIXx82v9TxUjJ1oFwEMYvbb3aEB A3LeWCMcWQl9G9t7A4wZ380MP56dSi9Ima5AefVOLaA1OC2z62/969T6sh2cCyWuq/3u jSe/IwjJUKYOifW3PB/FHa2BOFAo9DC/17dGL18LX3xBqujHk0CFcOV5Eh33X2Iorz2k DHEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1rUOgyz4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si2005880pgc.469.2019.05.29.20.42.36; Wed, 29 May 2019 20:42:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=1rUOgyz4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730060AbfE3Dld (ORCPT + 99 others); Wed, 29 May 2019 23:41:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:34114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732511AbfE3DVT (ORCPT ); Wed, 29 May 2019 23:21:19 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C13BE249E6; Thu, 30 May 2019 03:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186478; bh=DU2lb/T5lGZcyTlQNAmsuw6JM1ERt1KKN1Iwg5cX+IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1rUOgyz43VjhUWNYjTiqD3oH0HC4K1uTL+9MDJV7yfElK032eCJUaGYocaN//9wOh 6t9gaPoP5qWrG230gQ0plRkjUZsLzFkqL/quxMaCwdTFHwrVh7HOc96kVZKkedCcue OsaV63hsmrRWtvuhVRseq1rMu2tXKFBEED8E3xAQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ashok Raj , Tony Luck , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , linux-edac , Thomas Gleixner , x86-ml , Yazen Ghannam , Sasha Levin Subject: [PATCH 4.9 113/128] x86/mce: Fix machine_check_poll() tests for error types Date: Wed, 29 May 2019 20:07:25 -0700 Message-Id: <20190530030454.822261528@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030432.977908967@linuxfoundation.org> References: <20190530030432.977908967@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit f19501aa07f18268ab14f458b51c1c6b7f72a134 ] 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. [ bp: Massage a bit and flip the "== 0" check to the usual !(..) test. ] 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 Signed-off-by: Borislav Petkov Cc: Ashok Raj Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: linux-edac Cc: Thomas Gleixner Cc: x86-ml Cc: Yazen Ghannam Link: https://lkml.kernel.org/r/20190312170938.GA23035@agluck-desk Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/mcheck/mce.c | 44 +++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index d9ad49ca3cbe2..e348bee411e35 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -673,20 +673,50 @@ 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)) + 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.20.1