From patchwork Mon Oct 16 13:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 153451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3473642vqb; Mon, 16 Oct 2023 06:49:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS/XOaVqS+vcQuiegS/1ooePfCx84Z5WJWcYfgmFSa0s8iwXPf6NQoe1lS4WLUkS11MviJ X-Received: by 2002:a05:6870:b508:b0:192:6fce:d3be with SMTP id v8-20020a056870b50800b001926fced3bemr36745861oap.1.1697464187697; Mon, 16 Oct 2023 06:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697464187; cv=none; d=google.com; s=arc-20160816; b=cgxnMuY8y4HOeT+KmplW6umrwusFeDREFUwtGrqhXYtj6Wd4EYnU4ujmKfQb+vq6ox z9wbe3KM2XsLjXsPW5UeSvkv2qFeZ3KLSeXIAroo9G5AG9xQmtR8U80Thk/spmaK8x0N TXw/uuPZvkEAntSWWR70kn5KoTIv5UkNSbPKJBIkjXj+6vftBo/J3/j6cCa0JO+VJn7j nXkRePOECP71tWRkevJGJaj/0zM2gcMwKJ4lbooJZ3wLOIm0IR6ZqQr71AyT6spJsRfI FXA+zXFJ41rjO+AexIcEeWvE26AV7aZ5F9pNnjdu6VMt4LxlV2qRjsfHM08aHEZruIGH KQkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=yzjbF6qk1vI0M7eaJT2fgIaqJymQ1gJxl89gNX4MTHg=; fh=i/gJ3xj9E1Arj21pdPUX6ES8yMextyN9cwS58CA/uOo=; b=X+3pP8I1bPcrwye6WgiDAZq9l9ARu283+JKktyKQUC5mikzS+a5pf8LrLbaQuVil+A 9hNWN1X9DBUUANYRlcA26ZyqxB8Ckg3Y70LSjMsOOx4XkQPjuoLIJVXFomDghGurvTAc cb8j8XVWNhbSOOQNzWaLguBnnKAz7VP5yTuNsnxiesx2NK8FyJqwQMaUtY8TMzEtA6QV OeSc+7oUpOUhAmW+qBxu5FlGVnEPfA2syiQlotIGIuBNCYQP/5IDf/H4SMMp/mvUdq8K vej3RzAVNA/nZm3G9zxefb1flIWY9U5HEx9DHdQ1vSyA65k71LCcLxjMGplf3DFnTSNb e3IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JFJlAyoC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cb9-20020a056a02070900b005aebc9096d4si7126164pgb.150.2023.10.16.06.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 06:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JFJlAyoC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 856F180AD0AB; Mon, 16 Oct 2023 06:49:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233958AbjJPNtT (ORCPT + 18 others); Mon, 16 Oct 2023 09:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233594AbjJPNsk (ORCPT ); Mon, 16 Oct 2023 09:48:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82D7A100; Mon, 16 Oct 2023 06:48:15 -0700 (PDT) Date: Mon, 16 Oct 2023 13:48:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697464094; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yzjbF6qk1vI0M7eaJT2fgIaqJymQ1gJxl89gNX4MTHg=; b=JFJlAyoCd3sY2R3Ww9X1WigZB+hKLCx7XplDdoH/TPsB2ZNi2QH8SgvTSox5jipmRV5Lj0 hjA9JDC/XHH885gUemYe4XpJALLlkVxuw9NVkD+D+wJ8uhikS2Dd2mALwOkcuYMAugkqQr +TLKbZkMrfTW5Vd/lQoB33R+bMUNRD9ia+zZlvt3KZ2Rkjqh99Lq2X44WjoOkvB/9ZItCG nQngD/z71lBZ1Uos1ylUvR8HQAfINXK9J8IidE7OVwngpS16AyN06+mpRvEzBArE4YulYw m465zWONyRIYbRlyPl6J4wDs5zPxvK/0ASAQG4WdaBtZwOa84lMrr6aJqu4mtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697464094; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yzjbF6qk1vI0M7eaJT2fgIaqJymQ1gJxl89gNX4MTHg=; b=wRoE6EkBFh5UHslWFtmBYkzxxWT+tlsmnJm80YH9A4PuFZ99hcl+II7dC75u1vhPsmjHD7 jAycSjZGiEFtsIAQ== From: "tip-bot2 for Yazen Ghannam" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: ras/core] x86/MCE/AMD: Split amd_mce_is_memory_error() Cc: Yazen Ghannam , "Borislav Petkov (AMD)" , Shuai Xue , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230613141142.36801-2-yazen.ghannam@amd.com> References: <20230613141142.36801-2-yazen.ghannam@amd.com> MIME-Version: 1.0 Message-ID: <169746409345.3135.6438220840208007314.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 16 Oct 2023 06:49:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1768598457038178078 X-GMAIL-MSGID: 1779920207912193985 The following commit has been merged into the ras/core branch of tip: Commit-ID: 495a91d0998367f4f079593f491bdfe8ef06838e Gitweb: https://git.kernel.org/tip/495a91d0998367f4f079593f491bdfe8ef06838e Author: Yazen Ghannam AuthorDate: Tue, 13 Jun 2023 09:11:40 -05:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 16 Oct 2023 15:04:53 +02:00 x86/MCE/AMD: Split amd_mce_is_memory_error() Define helper functions for legacy and SMCA systems in order to reuse individual checks in later changes. Describe what each function is checking for, and correct the XEC bitmask for SMCA. No functional change intended. [ bp: Use "else in amd_mce_is_memory_error() to make the conditional balanced, for readability. ] Signed-off-by: Yazen Ghannam Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shuai Xue Link: https://lore.kernel.org/r/20230613141142.36801-2-yazen.ghannam@amd.com --- arch/x86/kernel/cpu/mce/amd.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index c267f43..c069934 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -713,17 +713,37 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) deferred_error_interrupt_enable(c); } -bool amd_mce_is_memory_error(struct mce *m) +/* + * DRAM ECC errors are reported in the Northbridge (bank 4) with + * Extended Error Code 8. + */ +static bool legacy_mce_is_memory_error(struct mce *m) +{ + return m->bank == 4 && XEC(m->status, 0x1f) == 8; +} + +/* + * DRAM ECC errors are reported in Unified Memory Controllers with + * Extended Error Code 0. + */ +static bool smca_mce_is_memory_error(struct mce *m) { enum smca_bank_types bank_type; - /* ErrCodeExt[20:16] */ - u8 xec = (m->status >> 16) & 0x1f; + + if (XEC(m->status, 0x3f)) + return false; bank_type = smca_get_bank_type(m->extcpu, m->bank); - if (mce_flags.smca) - return (bank_type == SMCA_UMC || bank_type == SMCA_UMC_V2) && xec == 0x0; - return m->bank == 4 && xec == 0x8; + return bank_type == SMCA_UMC || bank_type == SMCA_UMC_V2; +} + +bool amd_mce_is_memory_error(struct mce *m) +{ + if (mce_flags.smca) + return smca_mce_is_memory_error(m); + else + return legacy_mce_is_memory_error(m); } static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc)