Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp259791ybi; Wed, 29 May 2019 20:51:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqznDaePGmjeS20acCZRcqh5UBFSAXIkMUfKECVWtmkblrbMlT+zrf2OPTgqjrRk1GPDgkH/ X-Received: by 2002:a62:5801:: with SMTP id m1mr1674216pfb.32.1559188289334; Wed, 29 May 2019 20:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188289; cv=none; d=google.com; s=arc-20160816; b=HffEBfRhMvSjlpcK4SkcPi8jHr3D228J5v/Tm4ES2CNgYUzhf/KKx2XY/xdZjWOCdP 0PUONja4NuXe7F7x9oy0EAINoF2TrDg0h84vGfRhK5zqQY+kegAWAPyvIf+3gEfLJoVt KeS3LbpHFty1nv6+mRPnOkBvMjE1dBTKeYn8xl9xa4rqXDVVaKdvE+vCDhnnZ1DHg7OF IkZscb3mqu90iRdFcaAAO6+HdjW+98Nbk89tp88xiBLdVFDSUsGnSo8pHbnexvBYPLoJ 9F4hbxmBfGDWsiQ0dTkcLDlyq5hm/QG56Sq9KIRkXSFtTC8SwBpX15tbdgNouZEr5Z5O OKqQ== 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=mKjrkiJixFI91cyPGFmJsue1Xt4lH2KfSQq0OhY3ycc=; b=MhqCgF8Ko19NHsO3zbcaWypX4X6yCDHtrQfecn5ChgN2nJuT6hkYF35wxCqcq0zc0X xLUzwlTrLsZJ9XNwgtN/UpK/x4VFUr+auc9ebu/ysv1k6AX/vXLXS+6g8+7LE//t37It i7DUxkGMf1LKoDNEC/XPnSEiM6HejgNNH2Kf8l6NmeWN8Mw8KVuRuLiyKjoeiZJLi4jV E7/VZ6Bz+iCslT3UeRGvfRb3gJevsE5cGBLniM/31BsDBcxTISiubJmBFHsuK8dsX2NN LiY8TqcEKiqmnNILO5NzMSiIRam+dE+mdb2SGbMGZgYRdrpa0RrYIvg4ADA8oKaa9Pnv 1a9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MFiufwXZ; 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 t7si1989145pgu.3.2019.05.29.20.51.12; Wed, 29 May 2019 20:51:29 -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=MFiufwXZ; 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 S2387594AbfE3DtQ (ORCPT + 99 others); Wed, 29 May 2019 23:49:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:57748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729827AbfE3DUD (ORCPT ); Wed, 29 May 2019 23:20:03 -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 9B83F24908; Thu, 30 May 2019 03:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186402; bh=s6gkeyv+vOhrrTJlNoeVWCKqxkTCnhUdxoSHnP7Ihtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MFiufwXZo73TTSTLIQ7ITixOZf/DI9WxsSaHWpZj94OZmxMw4TUXkZYqsot7XD8yi GtV97Uva1bxsIOrDthu7HyaPoD6n4zXriQfAD8wp8C/sNHJNb8tslPcXBVPjOi7mlG i0pKdK2aKE9AID0ZRtyzpZ7H/MN9klEVd6BEUHeA= 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.14 169/193] x86/mce: Fix machine_check_poll() tests for error types Date: Wed, 29 May 2019 20:07:03 -0700 Message-Id: <20190530030511.533950292@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@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 54874e2b1d325..4f3be91f0b0bc 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -701,19 +701,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)) + 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