Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp57779lfv; Tue, 12 Apr 2022 17:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFUOIgo52anJypR3l1A81v3TJRPBbGLinueD/AnB97eQDvB30Oe94lNE/6ZBHjeOh73YLr X-Received: by 2002:a17:903:2347:b0:158:8973:b174 with SMTP id c7-20020a170903234700b001588973b174mr5396085plh.62.1649808563092; Tue, 12 Apr 2022 17:09:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1649808563; cv=pass; d=google.com; s=arc-20160816; b=aRmRUcMctfDfuVL2Lzcw2Y6RuPXa8Tp0cxcPoxd4EEpWfna+jT00vHBmhklu6WxaC+ xEcPfDbFzbIvAA6Mku+WHkT+ubvKQy/DGtErch5BS2gqTHqKYS0xyPeGyU8fB34PN2GM rAGxYOJCMdmPahzUWb6mjmfp5HFT7fnrELYQICRxeF/uEMpKlJrxGUwNOaEQqby4jDjG rov31CPAbw8MItHpCX1eqzEh7XVvXhZ6o94K1iWVL6Ju/OFomq76sKx+SjudsQ1dyuwf 83X4z8hK5eMqPQIyT0xej0PiUr28qpsGKRMzTT+TYQd5EAeRR5Q8K7cdXpK/1Aw1ye7d /GpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bptFFi8iUmgDZBG1ZuTcPbI+ZXweWm79vVr7677tibo=; b=qH0ldVwmmZfgz8VUQVlUaIRtqjBHY5oog30uLiECOeXaNZo1tb8UVIUzeyXmKpO/0O 19Zon86Z8STi3CmxU0Xg6WPvzJiLNCt0s7HiV7GhYJBtCabAhYEwyFFoVLCBSYdu8+PW i8nOCEVebEvD7k5qyVOAsTR0ivm5WTeg6mIiRofYcmacrfsNQPvsZaNaF90tnFytJpfP 0g1wwQWMiZm52rg9N1kWJXpdzdE+S56tWMk88JlyJJ8ldoEJ/GmlWvk5Izgn1KBQ7EPQ +mNZ1gZZoD/3o9MXmN7e9s0Z9FK6LNMPi/lJ81BuFbc+ZYT4OwD/c81eJEX63lSQBBsS mXeQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=2L75fkHL; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i5-20020a63a845000000b0038234dbb532si4213865pgp.378.2022.04.12.17.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 17:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=2L75fkHL; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8CFBE160FCA; Tue, 12 Apr 2022 15:27:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357231AbiDLPnp (ORCPT + 99 others); Tue, 12 Apr 2022 11:43:45 -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 Content-Type: text/plain 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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 -- 2.17.1