From patchwork Tue Apr 12 15:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12810897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6EE7C433EF for ; Tue, 12 Apr 2022 15:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357201AbiDLPnj (ORCPT ); Tue, 12 Apr 2022 11:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357193AbiDLPnf (ORCPT ); Tue, 12 Apr 2022 11:43:35 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028A95FF04; Tue, 12 Apr 2022 08:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AEjMyejZ70m06D5cWEv4eFRGdfQPPWocRA/lWlDzpq/mE5L2Ix8rV3q8ENNrdRvPI+7zpXqlLyXmYPdzYg6H2B+6X+PXi+zc+RmnIqeftL+7uz1maOHtgE88qyvhVkbs3biEwtBn3GefUHlL3vVJu1aDlS4C9jqCqbP2MiExwW9lZwiVr4ltpLkRNObpiCQU58zlhMuRAOlXsQFO/Pd3b5audmR4Kz7hedVFE61I/rcrw57/Vwj8xfvODoDxffPXt7x88/B5h+iMOyzuxIQyEddszFxq54nyEoMFUPoCaw78vbzNO226s8JqzOF7iDzjM/HeET7LbID208bKwvTH4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bptFFi8iUmgDZBG1ZuTcPbI+ZXweWm79vVr7677tibo=; b=OQkV4URVq6KgJEvTO767VEYoyvFcUqrsDi9xD6tn83nS9fk1w20I1mOFAvr7rHbrrlAbvJ9Cmn76mwRdr+Y4aNG6SioebZlFQHmNN8TlHqNQ23dcXo+NDbCQ46IntDbJ2SoP6hQFc6dpg706Atl3BWqB9i9GRBPFHn0/kYOiyoFDE3LnJvdEAlpnmgW3N5GJMdjy7klQtpU6P/vWf+x1bcO1lC9Bx8Nov1UraqgFTAuWM4Znu7q/tGB84AyCTS8zrhLkp1FXnHYnfgHmu/Ts3ZD/1eNKv0Q3KqnfiOpY6dIzw27vZMqnY9vcW6feKdHbtfSmc4dmZhLyf/0q92T0Tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bptFFi8iUmgDZBG1ZuTcPbI+ZXweWm79vVr7677tibo=; b=2L75fkHLB092+VUt9Gh3OalNE7quqsGO/HDp8JqWiiMtRyvrUfXNvJI5YzaN/ChQqn8/9ocgBEV/OcMh2Q62bVt4+0oYP7HpQogGLBAghu1841Q9IKl69IQevN26QdkzJLoRB4QyiImVZMo1tTdOd01CEFjTcnAaVS3xoM4IA50= Received: from MW4PR03CA0214.namprd03.prod.outlook.com (2603:10b6:303:b9::9) by SN6PR12MB2830.namprd12.prod.outlook.com (2603:10b6:805:e0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Tue, 12 Apr 2022 15:41:02 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::d2) by MW4PR03CA0214.outlook.office365.com (2603:10b6:303:b9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29 via Frontend Transport; Tue, 12 Apr 2022 15:41:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5144.20 via Frontend Transport; Tue, 12 Apr 2022 15:41:01 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 12 Apr 2022 10:41:00 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , Smita Koralahalli , , Yazen Ghannam , Dave Hansen , "Borislav Petkov" Subject: [PATCH v5 1/2] x86/mce: Define function to extract ErrorAddr from MCA_ADDR Date: Tue, 12 Apr 2022 10:40:37 -0500 Message-ID: <20220412154038.261750-2-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220412154038.261750-1-Smita.KoralahalliChannabasappa@amd.com> References: <20220412154038.261750-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f2f6218-3654-4d21-b87d-08da1c9ad931 X-MS-TrafficTypeDiagnostic: SN6PR12MB2830:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OofetUrzvia9c/4GFH6wgjC96o2I7ueHAZspaJ4d85gBXxR6rM5579avNH6KxpzG8BLO0cVQeuOFrc2s8+FwHqM5h9lNpy5pDq5vORh2rd3mYba2E6oqDmFIPnSdPHzc2GDDUPzPXxCeCsU3oma2Lk+UzlNJc7mT/atsaIH5hyMGsqLOthAG559ayI/hlv1ElGu9szjyZX5oEpTuRqOTXVrRA1nAsSoyU9VOHA5CmJrmnF+AT7N3kjaJ+kgPF4HUcwVf+nezmLiWMk8WZN3/8GgYiK14t5bK0fr7GLzDXp6/OK/yzJRsWCCrFC9ywP7iEQBVXodTN3FoYuU9pEF/1xorSJMm8Lm6BUA4B2WPLGHPUpJwNxecK4RofdpekE2pO91ZdZ4XXfdr64xkg/7yOZj0mU2RuVMrsz21j+zmBIJ29lWpQDEcpt1PFPTFeXtw8R8kuJZY1oUae7zWApEy8f/SvVYv+BbP3D9mbAwsQEGRmWSJZIsPjwKh+4DQSzHaEjgTdAF5gTFb2pDgJMQ3l9vdVnUIcxtzBvPUU5Bb3kZH1OTHEvO7jpv+Kn/krDwGvNZpUP5rQKVRqf2/aIRxawWdAnf5Dx9t7chPAxCUsLacwZgp2m8e0X+4LAJBQxLMHgKlwOAR0wmBigY+cTyC4167eCgQ68Hw1B8hM1wR8wdnELyPxCF0JJxwv6602cop3A/cCFrCmajdxg4e6lIB6HrN8HPJH95iZ4E6IwWIkcs20sNE4yWEKiUxK1skABDngqV5+VtTgG/0BzkNMU0ebSyt+f58zT1eGSL1IcN/kaE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(70586007)(70206006)(316002)(54906003)(356005)(110136005)(86362001)(8936002)(186003)(26005)(83380400001)(1076003)(2616005)(81166007)(36756003)(16526019)(426003)(508600001)(336012)(6666004)(8676002)(36860700001)(966005)(40460700003)(2906002)(7696005)(4326008)(5660300002)(47076005)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2022 15:41:01.9083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f2f6218-3654-4d21-b87d-08da1c9ad931 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2830 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org 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 Reviewed-by: Yazen Ghannam Link: https://lore.kernel.org/r/20220225193342.215780-3-Smita.KoralahalliChannabasappa@amd.com --- v2: No change. v3: Rebased on the latest tip tree. No functional changes. v4: Commit description change to be void of the patch linearity. v5: Extract entire function including comments. Define smca_extract_err_addr() in mce/internal.h --- 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 1c87501e0fa3..f809eacac523 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 d775fcd74e98..39614c19da25 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 4ae0e603f7fa..64dbae6b8a09 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 From patchwork Tue Apr 12 15:40:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smita Koralahalli X-Patchwork-Id: 12810898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1D8FC433FE for ; Tue, 12 Apr 2022 15:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357212AbiDLPnk (ORCPT ); Tue, 12 Apr 2022 11:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357234AbiDLPnh (ORCPT ); Tue, 12 Apr 2022 11:43:37 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2081.outbound.protection.outlook.com [40.107.101.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6747A5EBC0; Tue, 12 Apr 2022 08:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ma/54x0gjN9Wl0AR8CXFPEOD1HYaYzvLqVNlgxWKzfXUSKh6hDuC3ITRrxqFBXFl0ESsp+iM188nOOM74QPKA3FQjPP6ymWjEIHeJT32Tu1vplgHvnnhJInQaA7VY/sCaFI6toPGWHyxa1IfgWSEAcIjAd2EADZ7OeBu1DAvDMp+QXYMoebSdYRbvh/3Yc2GovZgs3asvLpnAZeR7CWaW5qmNeixo6/9rHdt+P/xqzh1hyNHoxiL7+v1gjM1uOH+PF49Gob+/IAApPHtuJihCNkSO6G/HOhe4eVk5EBhRWfQYU3AMPGKqJtyXowWdIz3nKCKxXgJq1h14HMEAibHLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c9PQ59TSscRf3tO6llEJb1LV+fjoiheEe7Rxr8Fce/Q=; b=ipqC9lPhUBLLcJ+gcMe2zk9WCWQVEXajSIpK/BA+hNaoUUJwYNR6JscmgpubXED0yuq2ibtcsaBtkw7hzKnWatfU47h0m32UOsgboSY4HzTeNExRn/8xHr3VgU0BXgOF2M+KdvhQvHxSqMG6B5Ymm/+xEmUFwGOFUq8v2lLsYrd3EmTh0+BQj4/ZUyXBcEvAGiwGHr6Y7FTziMY6+twIKy2eeQHxPX0jhR3RX9y6UcnER3ul5MaxPaiq0CJ5tCh+p0y2YjqlEPw9pPU3Io0+/1U2JCT5DpJreY0AT/yba6TB+5RHlcl6OoAtPUyrI7YV8lBlpjpr6oYMnHdwiWC7kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c9PQ59TSscRf3tO6llEJb1LV+fjoiheEe7Rxr8Fce/Q=; b=O9i0eUrX6v31X/JnPU4u8ZNjW5MnbkrTdp6SPgoaO9kLK6nDMiPgd/Wz7pDXRqOIC4Emw8TXBuC5/2CapDKXXp8IG/oiKFGdKmMsmIPRf4lDDD4OJjBqOivnlY+W4slhFdLTc/9yyF7RZ9+DUhIVv+etPRHJN907oj/KW4Yjppg= Received: from MW4PR03CA0234.namprd03.prod.outlook.com (2603:10b6:303:b9::29) by MN2PR12MB3567.namprd12.prod.outlook.com (2603:10b6:208:c9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Tue, 12 Apr 2022 15:41:04 +0000 Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::9c) by MW4PR03CA0234.outlook.office365.com (2603:10b6:303:b9::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29 via Frontend Transport; Tue, 12 Apr 2022 15:41:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5144.20 via Frontend Transport; Tue, 12 Apr 2022 15:41:03 +0000 Received: from ethanolx50f7host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 12 Apr 2022 10:41:01 -0500 From: Smita Koralahalli To: , , CC: Tony Luck , Smita Koralahalli , , Yazen Ghannam , Dave Hansen Subject: [PATCH v5 2/2] x86/mce: Add support for Extended Physical Address MCA changes Date: Tue, 12 Apr 2022 10:40:38 -0500 Message-ID: <20220412154038.261750-3-Smita.KoralahalliChannabasappa@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220412154038.261750-1-Smita.KoralahalliChannabasappa@amd.com> References: <20220412154038.261750-1-Smita.KoralahalliChannabasappa@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1e2ad81-a90a-45fb-aa2c-08da1c9ada0a X-MS-TrafficTypeDiagnostic: MN2PR12MB3567:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ONXVqCzuRbPQvVDqThyOiLfR9YsDf418XSCm9zMAYUjTvSkpG5UIS6AXrPlVw73qOBd5Mu5jeMLBludoI3dB164fZlxxy6H86no7EGaixjlSb5Kbar4FcQuHcp51mJ/Dt3gwxTttBMvFu82Q41sNuxML4gNjzi9RjMwrijdI/IWcjqbmjhS9gqYtznHXVqdA0YSuWjnTAzLY1Cr9RfI/LP4nTEDi4IK1mwSIX+KltIJhaTbWhJg32w4LXRflBmlGxwCizzHFybRbbog70oSS5M0/Ame2EJpdR1b6wi5Lhhfc1gxb0Ugtwe/LSpJIIvVXBAaV6PEHjvJToZ4heWTV7Zgs+XwtcyTYQSfU5K0s2eTXb8qdbm6h0gkLL8aM3fpt1A6JgvBVqeUaXNb8o0Dcrevy4Xpg/SjrWkbvAiguKt4BZOFYHFHkf34Xx1yrmpnGy7O+7xja7/juWJRzVhjOrVdR20/dpC3KsuV0FqI+9DpfXBw8fQ8OLlE0laQ02DWLSuUyg0C3ybXNvU4qeMe/MdFAv7LUx9fMGGlBodUgTDjO2IHD83H5QmfKpJB59R0cJ9o+UQHyb5/TBvLn3qJOA7sIBBBf1ETBQ2Ei5AuSlyvQy9cz92cUKF+ANOJDneVsYcaTDbaM5DDoMqCFTVHjs3d0PK8vBkERAyZGb9845Ww8QWsSA4HIUS8lPBCt/8aM5cmu9Wl0fCiTzTBWSfyF1lXruN7bV/sb6VuRMVIu83qw9RRKaH2q5LoxFW72MKl6L4oqG6vtBGRotCKHfh690m8kad05b6v7w/YmH8Vi/MfUJlp5K9mzM1gkYsru+gjIO0Kqc989ugzdHt67NgF95w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(54906003)(8676002)(36756003)(2906002)(40460700003)(81166007)(316002)(82310400005)(110136005)(4326008)(70586007)(356005)(70206006)(7696005)(26005)(508600001)(966005)(8936002)(83380400001)(6666004)(5660300002)(36860700001)(336012)(186003)(426003)(16526019)(2616005)(86362001)(47076005)(1076003)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2022 15:41:03.3301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1e2ad81-a90a-45fb-aa2c-08da1c9ada0a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3567 Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Newer AMD CPUs support more physical address bits. That is the MCA_ADDR registers on Scalable MCA systems contain the ErrorAddr in bits [56:0] instead of [55:0]. Hence the existing LSB field from bits [61:56] in MCA_ADDR must be moved around to accommodate the larger ErrorAddr size. MCA_CONFIG[McaLsbInStatusSupported] indicates this change. If set, the LSB field will be found in MCA_STATUS rather than MCA_ADDR. Each logical CPU has unique MCA bank in hardware and is not shared with other logical CPUs. Additionally on SMCA systems, each feature bit may be different for each bank within same logical CPU. Check for MCA_CONFIG[McaLsbInStatusSupported] for each MCA bank and for each CPU. Additionally, all MCA banks do not support maximum ErrorAddr bits in MCA_ADDR. Some banks might support fewer bits but the remaining bits are marked as reserved. Signed-off-by: Smita Koralahalli Reviewed-by: Yazen Ghannam Link: https://lkml.kernel.org/r/20220225193342.215780-4-Smita.KoralahalliChannabasappa@amd.com Signed-off-by: Borislav Petkov Signed-off-by: Yazen Ghannam --- v2: Declared lsb_in_status in existing mce_bank[] struct. Moved struct mce_bank[] declaration from core.c -> internal.h v3: Rebased on the latest tip tree. No functional changes. v4: No change. v5: Extend comment for smca_extract_err_addr if AddrLsb is found in MCA_STATUS registers. --- arch/x86/kernel/cpu/mce/amd.c | 11 ++++++++++ arch/x86/kernel/cpu/mce/core.c | 11 ++++------ arch/x86/kernel/cpu/mce/internal.h | 32 +++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index f809eacac523..4f2744324d9b 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -722,6 +722,17 @@ bool amd_mce_is_memory_error(struct mce *m) return m->bank == 4 && xec == 0x8; } +void smca_feature_init(void) +{ + unsigned int bank; + u64 mca_cfg; + + for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) { + rdmsrl(MSR_AMD64_SMCA_MCx_CONFIG(bank), mca_cfg); + this_cpu_ptr(mce_banks_array)[bank].lsb_in_status = !!(mca_cfg & BIT(8)); + } +} + static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) { struct mce m; diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 39614c19da25..99e3ff9607a3 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -67,13 +67,7 @@ DEFINE_PER_CPU(unsigned, mce_exception_count); DEFINE_PER_CPU_READ_MOSTLY(unsigned int, mce_num_banks); -struct mce_bank { - u64 ctl; /* subevents to enable */ - - __u64 init : 1, /* initialise bank? */ - __reserved_1 : 63; -}; -static DEFINE_PER_CPU_READ_MOSTLY(struct mce_bank[MAX_NR_BANKS], mce_banks_array); +DEFINE_PER_CPU_READ_MOSTLY(struct mce_bank[MAX_NR_BANKS], mce_banks_array); #define ATTR_LEN 16 /* One object for each MCE bank, shared by all CPUs */ @@ -1935,6 +1929,9 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c) mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR); mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA); mce_flags.amd_threshold = 1; + + if (mce_flags.smca) + smca_feature_init(); } } diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index 64dbae6b8a09..0f4934fb3d93 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -177,6 +177,22 @@ struct mce_vendor_flags { extern struct mce_vendor_flags mce_flags; +struct mce_bank { + u64 ctl; /* subevents to enable */ + + __u64 init : 1, /* initialise bank? */ + + /* + * (AMD) MCA_CONFIG[McaLsbInStatusSupported]: This bit indicates + * the LSB field is found in MCA_STATUS, when set. + */ + lsb_in_status : 1, + + __reserved_1 : 62; +}; + +DECLARE_PER_CPU_READ_MOSTLY(struct mce_bank[MAX_NR_BANKS], mce_banks_array); + enum mca_msr { MCA_CTL, MCA_STATUS, @@ -190,7 +206,9 @@ 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. */ +/* If MCA_CONFIG[McaLsbInStatusSupported] is set, extract ErrAddr in bits + * [56:0], else in bits [55:0] of MCA_ADDR. + */ static __always_inline void smca_extract_err_addr(struct mce *m) { u8 lsb; @@ -198,14 +216,22 @@ static __always_inline void smca_extract_err_addr(struct mce *m) if (!mce_flags.smca) return; - lsb = (m->addr >> 56) & 0x3f; + if (this_cpu_ptr(mce_banks_array)[m->bank].lsb_in_status) { + lsb = (m->status >> 24) & 0x3f; - m->addr &= GENMASK_ULL(55, lsb); + m->addr &= GENMASK_ULL(56, lsb); + } else { + lsb = (m->addr >> 56) & 0x3f; + + m->addr &= GENMASK_ULL(55, lsb); + } } +void smca_feature_init(void); #else static inline bool amd_filter_mce(struct mce *m) { return false; } static inline void smca_extract_err_addr(struct mce *m) { } +static inline void smca_feature_init(void) { } #endif #ifdef CONFIG_X86_ANCIENT_MCE