From patchwork Thu Dec 29 11:13:45 2022 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: 37363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2348742wrt; Thu, 29 Dec 2022 03:18:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvltv7AsN2+VYgt1oRVxPycvR+YYMXGodOKOxc7J4Yf4vL0cCf/kimHWEIUPQzZKmofdaq4 X-Received: by 2002:a17:906:4e4b:b0:7c1:4040:ef17 with SMTP id g11-20020a1709064e4b00b007c14040ef17mr23254059ejw.54.1672312735838; Thu, 29 Dec 2022 03:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672312735; cv=none; d=google.com; s=arc-20160816; b=OjTQFIM8MTzo7EmEB9fE0KOX8r5fepz8uFakC3nrMZDL1aZoDwsxKhmTiSb8ODv7CT kfjMOoUgaDovg3BH0wi4MOxEuZ2UNNwkXCtuZNiXUlFc6g6du6YXEjnTg5qjlIbv5Drd maIi7aemVb//kXjDDQaT5+IBwN2an0Opbefd4fw+sXsAMx/6aMp+XEMOAQgC1HrizK+6 e3iFP0B3ofzS21PpZ1KPmGDPKMQh0LJvElF1wrLBXaGC1VSIlB2urwEU9SyhAAgaUbG5 remGZDTWBVvb1i/f7CNuFPJox2icgSu3lJ6uuOqJIP4UQ14DpnIdYSo4JK9eFIN10xvg jqDw== 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:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=VnpK1nkYAe3Br6uKqNc2H7ZpVwGG1Y3w1UxSUJcI+oQ=; b=MmRzXZpmmmHyUnRjDz43MbJwRgddyl3elmgETu4zOmuqGBBQjCCjq7Q+sFnrm64DUy 50JEeAinYh9NrFbfkEnDCCH1tkkbo/v/m0uujONwaiKsnZuDTyliYdnc9MapWKlai/iT zJOijT4m93XSqiPKv0XwS+DG68l6rv1vfMPUVP6IUtOb67AE0THoWhDoo5m0jjJhlAOx 3ktnITmt+i6TYXcudJlZzYQhBEVmZY6kqrlR60Fr8+PTCWAgwZ7g7u6tup0ej8KedCQI Dg+faB6pXUi4wwjMZTXyOnI/+xbaJpuwRYrhAfgjlYitxggrZHl3DHVTXEr5QKwFZnUE APlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="BZiot/nV"; dkim=neutral (no key) header.i=@linutronix.de header.b=qyu8zCZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be3-20020a1709070a4300b007c0b79e51casi14760348ejc.726.2022.12.29.03.18.31; Thu, 29 Dec 2022 03:18:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="BZiot/nV"; dkim=neutral (no key) header.i=@linutronix.de header.b=qyu8zCZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231196AbiL2LNy (ORCPT + 99 others); Thu, 29 Dec 2022 06:13:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiL2LNu (ORCPT ); Thu, 29 Dec 2022 06:13:50 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FD312A9B; Thu, 29 Dec 2022 03:13:48 -0800 (PST) Date: Thu, 29 Dec 2022 11:13:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1672312426; 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; bh=VnpK1nkYAe3Br6uKqNc2H7ZpVwGG1Y3w1UxSUJcI+oQ=; b=BZiot/nV3Jg3RSrJs2J8wQ93DclDbl7A2lwCPfQaptVe8H+ZP9q3mTeuzAZW74L2EQkCTg NTUwHipCCELbY3CLzeYhAOdK+U5lCivNO2hTN/O2IRpGo7iP+vu4o0Rh+nTIZEczpNoIBu Bc2nTTIWitoQ3U4IXe4hbGt8LrZ/YrL2N6NdlL4qEumPFRY09bZ7bVlC4Tmh8btI+1y7la 94x/BuWgY3PuZR5jTvzwdlLRyxCwTN//s1fHy348hMuCL2mfZ3FAtrmNdKlDxLxZ1sPE+n SpnJng5YaTjwCzjGCDp8LZISvNVkAs6so2AeKAhG00+biymqTBuOqPgnyKHy0w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1672312426; 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; bh=VnpK1nkYAe3Br6uKqNc2H7ZpVwGG1Y3w1UxSUJcI+oQ=; b=qyu8zCZIWCUvrY3YxgL5mTpfIMVlvkfqSzOQXNowd8+29kdJxIClICGkORpgrp9uVH4KJA jkYkohQTqoLbCCDQ== From: "tip-bot2 for Smita Koralahalli" 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: Define a function to extract ErrorAddr from MCA_ADDR Cc: Smita Koralahalli , Borislav Petkov , "Borislav Petkov (AMD)" , Yazen Ghannam , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167231242579.4906.1017232750066168905.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753546999380045407?= X-GMAIL-MSGID: =?utf-8?q?1753546999380045407?= The following commit has been merged into the ras/core branch of tip: Commit-ID: 2117654e806c08c343e3d0567bbedf33eab040c8 Gitweb: https://git.kernel.org/tip/2117654e806c08c343e3d0567bbedf33eab040c8 Author: Smita Koralahalli AuthorDate: Tue, 06 Dec 2022 11:36:06 -06:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 28 Dec 2022 22:11:48 +01:00 x86/mce: Define a function to extract ErrorAddr from MCA_ADDR Move MCA_ADDR[ErrorAddr] extraction into a separate helper function. This will be further refactored to support extended ErrorAddr bits in MCA_ADDR in newer AMD CPUs. [ bp: Massage. ] Signed-off-by: Smita Koralahalli Signed-off-by: Borislav Petkov Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Yazen Ghannam Link: https://lore.kernel.org/all/20220225193342.215780-3-Smita.KoralahalliChannabasappa@amd.com/ --- arch/x86/kernel/cpu/mce/amd.c | 10 +--------- arch/x86/kernel/cpu/mce/core.c | 10 +--------- arch/x86/kernel/cpu/mce/internal.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 10fb5b5..c6b1fd5 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -736,15 +736,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) if (m.status & MCI_STATUS_ADDRV) { m.addr = addr; - /* - * Extract [55:] where lsb is the least significant - * *valid* bit of the address bits. - */ - if (mce_flags.smca) { - u8 lsb = (m.addr >> 56) & 0x3f; - - m.addr &= GENMASK_ULL(55, lsb); - } + smca_extract_err_addr(&m); } if (mce_flags.smca) { diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 2c8ec5c..d0ade77 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -633,15 +633,7 @@ static noinstr void mce_read_aux(struct mce *m, int i) m->addr <<= shift; } - /* - * Extract [55:] where lsb is the least significant - * *valid* bit of the address bits. - */ - if (mce_flags.smca) { - u8 lsb = (m->addr >> 56) & 0x3f; - - m->addr &= GENMASK_ULL(55, lsb); - } + smca_extract_err_addr(m); } if (mce_flags.smca) { diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index 7e03f5b..6dcb94f 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -189,8 +189,23 @@ extern bool filter_mce(struct mce *m); #ifdef CONFIG_X86_MCE_AMD extern bool amd_filter_mce(struct mce *m); + +/* Extract [55:] where lsb is the LS-*valid* bit of the address bits. */ +static __always_inline void smca_extract_err_addr(struct mce *m) +{ + u8 lsb; + + if (!mce_flags.smca) + return; + + lsb = (m->addr >> 56) & 0x3f; + + m->addr &= GENMASK_ULL(55, lsb); +} + #else static inline bool amd_filter_mce(struct mce *m) { return false; } +static inline void smca_extract_err_addr(struct mce *m) { } #endif #ifdef CONFIG_X86_ANCIENT_MCE