From patchwork Tue Jul 30 18:29:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13747715 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2076.outbound.protection.outlook.com [40.107.237.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8878378276; Tue, 30 Jul 2024 18:30:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722364219; cv=fail; b=UbPfJ58JXYOkUQNVnmtVe+4BquDRPQ1xt3Xg0gKmoNB749U9AwOj25OebQQ/joyXzcAWf/WRzNgIQuKayOzAC0zO2CeSsTVJszGa134zYjgPwdrn5vJlYrS/cqQmXnDUfLMvY+VYkwX6Ilb6WviRTRnxAE4VfNnr1skd3RH+eXs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722364219; c=relaxed/simple; bh=FhG2EaK89ZCaeaJMR/EkMCZ2Fx1B3Lncn96hLUxg7Bc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lAAeZcJo3ACWlMnyvbZolCaq2l0WY9zD6u3VUrmTu+5/P1z/q8FCVB7NbPEOukQ621QW4d772kM78cPe6h75NBVzz5spi8arBzTw0inVgtEadKPETuPRgjl4iRe+5zR+15b5hWOY3LKrMK+K1sR/3Yn9s32TatE+Fq/gy8zqY1s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=lqHTWQDd; arc=fail smtp.client-ip=40.107.237.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="lqHTWQDd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XGvqdhjxeXVru9OZZgXn+4TJF75tE+86ubSxFD4xCW6tiZCXMPFo0RWTXDPWE6cbpxFyGnDNcaF9gf1rZaROAjlhiFRfoDldNK+3Zf/kLdmqdUGqCqNxCKmNXdFuvKcbWJjYhXuGYMf7RrzHJYNp3X5oV/5SRanaoX88YCXVTE4ZrW4K1F6YeUMmTN1e3jvG/EdvAi7CmPcgSmjCQyiSb68WtY1PgxmHURjnQXhihkOtbI8sQw94kFdWJMwSc/ObpKzoPf/whrkDs7lo+RGNYiJlp0C3XZzZVR/xRU2q/LPb1Wd02oeugZUGEaP7fmCtmTCUvfSPni4WuGlR+3qGIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=MPFqe9F+rCoO3WkMPy5xiZAq79F7uQHDhquXHSOBObI=; b=i7QrTRVDw4QeL0kA3Sxs5mntRJ6NvnHVXVE7I1iu202dx3gycI6aDyaNvgDMoM2ijPyw0nQrDaA1JggpDT5LhtbUnV2rOfWWSi6csTN9hWGTcr1aTQZydFt0w0Fi0gH/LNWtAMIT5977MnfOx5J23FJJH6ob2+xLN6pKODSyJpXLOMOTkn4b1SsVGqHnGI9+XCTNdM49rVkCPn2wUaR0XoVltKuYAJAoLNXVoVI52tLaOArSfALjn6I3LtLCbh/OOy5CAhUjI6BiHm3U26CK/MggqbXc4fDeldDboYE/N2FSUrrqsMM1l+j9qcQNFm+LJ7AjmjVM3E4fqh3Rmo1bOg== 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 (0) 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=MPFqe9F+rCoO3WkMPy5xiZAq79F7uQHDhquXHSOBObI=; b=lqHTWQDdry6sMu2vYHGRE0Jb0agfzZsBtsILwfiUPxzhjfIygZDoJYwHKCmSpANgtti2Hl9KuZFmKF4NOFgez+vxpfsROPEcah/FmuPDKRV5jXLvNv7VLdSmGJzy0Ny8bBlgRYAACcfX9bBJ64Dd8Dvhk8n7DHQZpSBTi+w+ATA= Received: from SA0PR11CA0012.namprd11.prod.outlook.com (2603:10b6:806:d3::17) by SJ2PR12MB8737.namprd12.prod.outlook.com (2603:10b6:a03:545::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Tue, 30 Jul 2024 18:30:13 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:d3:cafe::c7) by SA0PR11CA0012.outlook.office365.com (2603:10b6:806:d3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.34 via Frontend Transport; Tue, 30 Jul 2024 18:30:13 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 30 Jul 2024 18:30:12 +0000 Received: from quartz-7b1chost.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.2507.39; Tue, 30 Jul 2024 13:30:09 -0500 From: Yazen Ghannam To: CC: , , , , , Yazen Ghannam , Borislav Petkov Subject: [PATCH v3 1/3] x86/mce: Rename mce_setup() to mce_prep_record() Date: Tue, 30 Jul 2024 13:29:56 -0500 Message-ID: <20240730182958.4117158-2-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730182958.4117158-1-yazen.ghannam@amd.com> References: <20240730182958.4117158-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|SJ2PR12MB8737:EE_ X-MS-Office365-Filtering-Correlation-Id: 21e4d367-7d7e-492a-7cbb-08dcb0c5a6a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: f7Uc7nAMEGhbo7MqFd5vhA9CwS5+q0fC69yiE9GSq0PZn7a8k43+odFRrQe1oR8Nrwa+bT30FbLV/4Qfd3/G9hA30ThjTbASMN+pe09AK3fHn8bMnefvMK0mLUm3pxFAZlfftEQR2Mvo6PHSSPk1C1dmzoMf2X64xBGni/DQ6A65gLxJvNwuGvJ/1T+yS+hDX6Li9QKDStVIll9xkkCUxgrfxvJUz0hlTZO7AvWhT8DKI6OkMgWSLdNLcCGTOVy9bdktBzKayUcZtqQT+/agr1dc35lFkI0745loGUEC4IneFF7YI3auKiIK0sjQ7LCSTbmPGF+WaJm9qdcfi68an0gHrp2Rn3+5lzJyvISmskI3oZGknwj/zinedrMcNIM+Rmx3M834zAgZyP8d8gVc7dYlrQGVkCUEeMoGtcEA4gahiZi9LMknfnX1E1Y4YeSuW8l3VlmB4w50vNe+8FpbjpXsTM4IQeyTtsXJoBHSYUgQ2Nop8qP3smYYPMcYLdNkhrosptZBogirP8uBO87Als/Xr+woNPdpmNNiGHC3d0BSgwrgs9UK8RjDHv3herv0m+t3vNjTmfQABEryK5P3arPA8+wsnQVCp4/l0kN6v06XfJVljmZX9UgIJ177olhRV+wqMeSyUQ6sd+UJCtuRi3TxxPWCC3fJGFdtyYmGgGn708fptZPjmbgcSwTog7kRbzcOxowB1lodiYBtpEBQzzyyzP0G2NYojT0orc+QJr60A65aiYflXvs6RXbTjnncssyP37/47HPjga2Yjzw2oW3nB2ZwEpPBsvluI5IBmPkU5XX624KKKpgPGNLAOhcma9JL6wsgg7HD0TAyKWAEUrmvKiNpigasJJngHpSq052UIZvVzsi9HWzNeWrIQU6SSwcFYEoziSQPgqtYa4afFlvR5ec4jpdjMIoHAjVIdpvURCduLiXKc+4R2FNfa2jNLgABed1BAHupLE4H/HIKy0ZQvbhmJRPwHkE4Q4wUxnEOY5wbo4nzSQ3CRuWH1Z1TFkBH1iIWvtFHBBaLBRmYwZN4aWhh5PPtB67MArUSMAEwpL7IDuULd17hfcXb3gk+3P5RvmXcC83oSEsNwCnVvk0pDSLIQwQabJY2dKQb+YWAVjHQFvP5QLx6EszcDMSBIOuPXQRR2wd4YKNx1bTWQm6xzqgQQo7Ts0FzaTYsGcejNYo1c3Z91Bv6Q61jhGKLiBQyA9rjfVtMADT2cfJ+yxtyH9oX4i7JGmz1wbZVS61hx2Z1E4CTM5qDnQe7zw0BXBAyvaBUQKo8eLDoa3qjZKc4UId12y2VSui+IuxFhZKiiEwrJx7MHv7J/VUa257UqebG7H3fCeYiiCak82H9TTP7IRrjNwZbxKAh04UcawvXpIS9LWaDspzdosbBnV9r 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:(13230040)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 18:30:12.9633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21e4d367-7d7e-492a-7cbb-08dcb0c5a6a1 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8737 There is no MCE "setup" done in mce_setup(). Rather this function initializes and prepares an MCE record. Rename the function to highlight what it does. No functional change is intended. Suggested-by: Borislav Petkov Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20240624212008.663832-4-yazen.ghannam@amd.com v2->v3: * No change. v1->v2: * No change. arch/x86/include/asm/mce.h | 2 +- arch/x86/kernel/cpu/mce/amd.c | 2 +- arch/x86/kernel/cpu/mce/apei.c | 4 ++-- arch/x86/kernel/cpu/mce/core.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 3ad29b128943..3b9970117a0f 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -221,7 +221,7 @@ static inline int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) { return -EINVAL; } #endif -void mce_setup(struct mce *m); +void mce_prep_record(struct mce *m); void mce_log(struct mce *m); DECLARE_PER_CPU(struct device *, mce_device); diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 9a0133ef7e20..14bf8c232e45 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -780,7 +780,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) { struct mce m; - mce_setup(&m); + mce_prep_record(&m); m.status = status; m.misc = misc; diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 7f7309ff67d0..8f509c8a4e98 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -44,7 +44,7 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) else lsb = PAGE_SHIFT; - mce_setup(&m); + mce_prep_record(&m); m.bank = -1; /* Fake a memory read error with unknown channel */ m.status = MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | MCI_STATUS_MISCV | 0x9f; @@ -97,7 +97,7 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) if (ctx_info->reg_arr_size < 48) return -EINVAL; - mce_setup(&m); + mce_prep_record(&m); m.extcpu = -1; m.socketid = -1; diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index b85ec7a4ec9e..dd5192ef52e0 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -118,7 +118,7 @@ static struct irq_work mce_irq_work; BLOCKING_NOTIFIER_HEAD(x86_mce_decoder_chain); /* Do initial initialization of a struct mce */ -void mce_setup(struct mce *m) +void mce_prep_record(struct mce *m) { memset(m, 0, sizeof(struct mce)); m->cpu = m->extcpu = smp_processor_id(); @@ -436,11 +436,11 @@ static noinstr void mce_wrmsrl(u32 msr, u64 v) static noinstr void mce_gather_info(struct mce *m, struct pt_regs *regs) { /* - * Enable instrumentation around mce_setup() which calls external + * Enable instrumentation around mce_prep_record() which calls external * facilities. */ instrumentation_begin(); - mce_setup(m); + mce_prep_record(m); instrumentation_end(); m->mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS); From patchwork Tue Jul 30 18:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13747714 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2048.outbound.protection.outlook.com [40.107.244.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEC6F1662F7; Tue, 30 Jul 2024 18:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722364218; cv=fail; b=sAAM+euGR9hsyFYZVvLpM9TOvWI7pyLf8RogP03y2meLp4YYMU3ebIqvixDnHQ3/06Ki4SwC11lUTzVx6JZBqkif3O6MO3sL3jot20vp7CEdOpHuWI3bxzvXTVDpmEBnG10cusUwhxFo4PHk9EweMq7b4oKUY/8HMbmUgXNVr6k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722364218; c=relaxed/simple; bh=p5+6VkTmMKg3gndnexO04YTKHYMfKfFd/L2f3Vc5YT8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MefsGR33/ghfN5Hn6ABnuVbKWe/E0LHqdVaqX17XwS+HwUeiST71FvHqQzP9hT7G0v6OOJel7+vLrnetrYHLvk4WBapnzm0ookvNkJzZRpBJ59Ycf++xbCFaE5/7fI6U6NGiQuJ5+oBFmamqiKuiohZVySC7M+O8Cp6yIDufw0c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PpFRhiOm; arc=fail smtp.client-ip=40.107.244.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PpFRhiOm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SbnNsYPUxzEZ7yvQUqRHhVWKkbAkQT+gYSzmMWCsaD2ZmPlLZ3PO6uGa9peoZrbk60zPCpscCvx/pKMv3D67dmuTtt/cX6ZJsXSfn2uXt7P1a7xON0kh0M4C2DJz1/Zfljrdr12lsJ7SP3O2BUlEc+OBAtzykfGSy4+mVOc6C4rWZ2ibEVUFtqSUlj0xKjqOyLAeXidlUhiKbHSll3yeIzpF2HpMg98TPQe1Pg0rAi2JO8Zo7l89kqEDbP62UC9t08kboq0bICj1sUvo4Tx9ArfxTVPn7vzaxuRpdho9l6JKq7ZD6vxjBrsJ2Nga9s9arj0mZMQ1t4vKWq5lCzOHWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=fcXXFJ7akCeBJaR2OkVi9BAZI+MrbVLCmIFcPyWEkJI=; b=PjFsm5I5rK50vRiLThhDU5XMyef5LTj2vOo3p15GoCD5MQdEWI4/Z20WMkTNJatlHak6cQX9uSG+0lTOAkJYORrv/aBLSJOud0aocOJ+FdAI07o9rLnJ+gl1y8220dVHyOSn2iQaLrTyNxfXPZd/Frv/yfbXrZGM4G0HuGKejBvCNoT5IJTKHiBMR0gheTzPNgvqQDBylUag+6MjWlW9D912YJUDSsnsLf/o+VLM2yVtIT7UssIJCy6cBDPtxnnXWNKXHWFkaTFZe/i6x4dvVqQxsT+S2JX1hbKUR7/9jE195O81vvAD6V0WujDO64NDeBZc+fbwti8IPu4Il6lX/g== 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 (0) 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=fcXXFJ7akCeBJaR2OkVi9BAZI+MrbVLCmIFcPyWEkJI=; b=PpFRhiOmgSW6ozX3GURFlhi/XweOyf5o9cMgivkKCD53AM5hTPEvdZeVMYeHKQv34muxyZHTl/qTKvt2eDKpUK90YGe0vq6mhtghJBIraSvzWu5LGZrgXgQDmpqUwKW56U0+e+FqDGQzThr9+sT78zrItDL9Zv3dZcKRO1ybPHQ= Received: from SA0PR11CA0018.namprd11.prod.outlook.com (2603:10b6:806:d3::23) by PH7PR12MB6859.namprd12.prod.outlook.com (2603:10b6:510:1b5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Tue, 30 Jul 2024 18:30:13 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:d3:cafe::b2) by SA0PR11CA0018.outlook.office365.com (2603:10b6:806:d3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.34 via Frontend Transport; Tue, 30 Jul 2024 18:30:13 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 30 Jul 2024 18:30:13 +0000 Received: from quartz-7b1chost.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.2507.39; Tue, 30 Jul 2024 13:30:10 -0500 From: Yazen Ghannam To: CC: , , , , , Yazen Ghannam Subject: [PATCH v3 2/3] x86/mce: Define mce_prep_record() helpers for common and per-CPU fields Date: Tue, 30 Jul 2024 13:29:57 -0500 Message-ID: <20240730182958.4117158-3-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730182958.4117158-1-yazen.ghannam@amd.com> References: <20240730182958.4117158-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|PH7PR12MB6859:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b74e8b0-dc71-46e2-ef64-08dcb0c5a6f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: su5vDcc0274DRDRHGw+clI6B3DAioQDsiGR5+YScuaHxma9R/d9pBKTYAZiWL18ciJos0r04ZGS4gj8FFfu7hpKps/mKDLtuEHXOUIb295D0ShTgJjJZdbVB5osgluFVHE3DSTcrbyZcHTbrrYESDsjYRh+3SUFOnGujwdMYIvMIBeCLn9IjQxa7vujrMvPEHZx+sugDdaL7vRpdz2drc6Xo7N1fTFgRNEdMNjqcH/SVU5zgam/YAv2FHAW7jmi3pIxDtYTE5MYKULypCyFJxPT8/m+kkVt89UpN3FprecSQY4BREq2pI5GJxYajglIvUxfIHrYnvi2FJ7ZS3Nu9r+2iQAGr9kWXoG9/q1cQ/QWYxb+P/MakR/YvHneLSj9L9/uY5LVJdyEXY93y+itJwD6XJn/zkWbj2igxXxXE3fGH1j9HXxVXFbE9c3wXacY38qCyXVOr+wnJEZNaNvjD46G1lC70FuY9Na6bX2vA/ZzrWLOzEjlMv6eYDhabfZYttuGdpcqoTha63w9zTQNXMWaGpwlsbLwasm23Dw1mq0Nn6pNpH1HKsFnroiH+JPDEBLTlWP2/4QQ58VoAHbe/wTxpKs5Uh9f0XJ9ZrBhVQDz/cJW/uzMFU8GWpH3jD9xWXSPWlLxKaAtwbUNjvTyDdQSWUjDm6Je8j9V0xI1nhNgh0nu4tEn0PS1cOzgE5MSB+O+LrwmphVErB5REcFJnblmDhjQ/LqXrNWvF1lMkmQHv805OdfqIs8ID/UbN5N/5x5K+isDsNTAI2+3GyGy6NrjBN/kVGoeSZOKMbe3Fb0b8mQe1uYl97uPVf/EnNUONU8AQA/GYhQvhstXmNFHaE8+yhKd5uDleOp/Xthq+MhSay6n6RwaArfNLRlI6twXDZgaznmOrioQ1jj20hZL+gJ4QS0YyX9TZPAR8D89aEeKzPFr55AH0EqQbHQgY3CJu1B5uwVIMLzsIrFZyfH7346I6tw3VRdulMRCeStuYdEeGmoIkyW4YkZ5IRYc8Lt0aDDBVEvZQHj4lDT1BRDoGBSFUT/+li8VZG68Iwdpe1dYXc3wp4bBnARM6oTRU1qENZLzKi2+Ur4STl1a+IcwdnQVT0aKqU9vlDk/VTAqsY0tORC+2mVEw//ykxTAJHFCaFNC2nZaROHYMeYJr/OAy+/vi+XTC5MmAv+ocGC+CeFhrkyai0ua9p3IBDbBH0qYQJnxvHDqZf68o2V9ycD3OhNGMPcPWguC8bWCn3U/4FhGt3X1Tpxe1OX19hSl96rhV41ilSXy49+We/gjD7HR5PLDL0a625LdgdXzhi6Eogt2GkDHLrnbLOAFK9+m9LUfr+9EIEv5kCsANHjJrzgGcTDPy9GGg9rPNt6cji9H3OgT/vTI7GSCxDr5YplIRG/yENEx/mAzNQu7x85pj/smqEw== 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:(13230040)(376014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 18:30:13.5102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b74e8b0-dc71-46e2-ef64-08dcb0c5a6f4 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6859 Generally, MCA information for an error is gathered on the CPU that reported the error. In this case, CPU-specific information from the running CPU will be correct. However, this will be incorrect if the MCA information is gathered while running on a CPU that didn't report the error. One example is creating an MCA record using mce_prep_record() for errors reported from ACPI. Split mce_prep_record() so that there is a helper function to gather common, i.e. not CPU-specific, information and another helper for CPU-specific information. Leave mce_prep_record() defined as-is for the common case when running on the reporting CPU. Get MCG_CAP in the global helper even though the register is per-CPU. This value is not already cached per-CPU like other values. And it does not assist with any per-CPU decoding or handling. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20240624212008.663832-5-yazen.ghannam@amd.com v2->v3: * Use topology_*() helpers (Nikolay). v1->v2: * No change. arch/x86/kernel/cpu/mce/core.c | 34 ++++++++++++++++++++---------- arch/x86/kernel/cpu/mce/internal.h | 2 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index dd5192ef52e0..2a938f429c4d 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -117,20 +117,32 @@ static struct irq_work mce_irq_work; */ BLOCKING_NOTIFIER_HEAD(x86_mce_decoder_chain); -/* Do initial initialization of a struct mce */ -void mce_prep_record(struct mce *m) +void mce_prep_record_common(struct mce *m) { memset(m, 0, sizeof(struct mce)); - m->cpu = m->extcpu = smp_processor_id(); + + m->cpuid = cpuid_eax(1); + m->cpuvendor = boot_cpu_data.x86_vendor; + m->mcgcap = __rdmsr(MSR_IA32_MCG_CAP); /* need the internal __ version to avoid deadlocks */ - m->time = __ktime_get_real_seconds(); - m->cpuvendor = boot_cpu_data.x86_vendor; - m->cpuid = cpuid_eax(1); - m->socketid = cpu_data(m->extcpu).topo.pkg_id; - m->apicid = cpu_data(m->extcpu).topo.initial_apicid; - m->mcgcap = __rdmsr(MSR_IA32_MCG_CAP); - m->ppin = cpu_data(m->extcpu).ppin; - m->microcode = boot_cpu_data.microcode; + m->time = __ktime_get_real_seconds(); +} + +void mce_prep_record_per_cpu(unsigned int cpu, struct mce *m) +{ + m->cpu = cpu; + m->extcpu = cpu; + m->apicid = cpu_data(cpu).topo.initial_apicid; + m->microcode = cpu_data(cpu).microcode; + m->ppin = topology_ppin(cpu); + m->socketid = topology_physical_package_id(cpu); +} + +/* Do initial initialization of a struct mce */ +void mce_prep_record(struct mce *m) +{ + mce_prep_record_common(m); + mce_prep_record_per_cpu(smp_processor_id(), m); } DEFINE_PER_CPU(struct mce, injectm); diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index 01f8f03969e6..43c7f3b71df5 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -261,6 +261,8 @@ enum mca_msr { /* Decide whether to add MCE record to MCE event pool or filter it out. */ extern bool filter_mce(struct mce *m); +void mce_prep_record_common(struct mce *m); +void mce_prep_record_per_cpu(unsigned int cpu, struct mce *m); #ifdef CONFIG_X86_MCE_AMD extern bool amd_filter_mce(struct mce *m); From patchwork Tue Jul 30 18:29:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13747713 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2043.outbound.protection.outlook.com [40.107.92.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0CB6167D98; Tue, 30 Jul 2024 18:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722364218; cv=fail; b=MiPS0Xu9IVUTQxQE/JXgOZQGEVOyTRSTfWwthQvibxy1+h5NPM2LKi/tiVBi0Frd5Hl5U9n5FbRyteRIfdRu8RJZ+hVd1wtEHTOnimQTximGRbyoPSfkEJSSBQxayhrLLx2Cg0Bd2rwGxpHUnOjZgeAaz1o2iioX5jVEFGDcwmY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722364218; c=relaxed/simple; bh=nr+SnmkeYtFzmGo8CLk8Oh1B7Ch9zqH1n2SqOBAD9+k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MEjwjt8JT/thwQMLs4T1CmOvRaeeal6wwuYqW45L9uyTbgip3oZ4NSKEipF8ACvEtU2TKq9ZRmusP6eqhZDBUMs9tR5rinwMpIUUVlAnUdJ5tAdDCtWga6JvORWvh82tpV8DBPTqi/WZzMJcHwfRFNVaeFfCqSrvgFhATMZxItY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=1ULHZuvL; arc=fail smtp.client-ip=40.107.92.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="1ULHZuvL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i91g5LPb5ib/MpND0hy86Far+jZcKhgPk/fwYt6LYr+YS4lKzgk9X4s0IJ2MUmM8URIo1lZWClBLzoA5xP2sLj6OW5m1nCwa21QQtWyK3sniLW4+kZcl7BUzCCi7PEg6L3NPrHcgs+NaG+TQ++LHJfzJ4ZI+UOoZocZn+AgRTcvjl0a1gUln2hqKchQyVsoCwIDg6Ir1vOlKqLEeKyv78BYoEa839aNW1IgZY2E0kEsBPxfOhLGwBRfrs4o6aSWftnj2X5OGIVgP3rtYW+SAouB824GB5r63rfCmdzACGAoep/aoYI3tH+pA2trj6+M8nd5Mgk3UBgS8AoBU4s8vMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DkHH+fnoWUA/OotvOLz14CCnzJupFLA6QF7QMnoceT0=; b=ZOo6LCGowN5iH3lyws1/WVzkV2ihj7hEh8T787olrJDErskMxgzQI28xs3bwXwVzZqXXq3ANULq9Vjd7umL8ySdOaCn4AKBHS4fEKVR7ge73cHn3+BZuIcbt8s42F1vXk8MYO/Ri5ze4ZhRU5R1qSYHavdNn27bTdihvhU7uTwiLTDEDyh3VSTCF2x8OjJHljXjZAgKbIHuxDGsoLmmiTPJZhjuN2lVrSjyPlIegav7L6DVQMcpjoGVJqWzeUxS3BELFTPW4pYnqWWfyg+l8vbIGXo61wE8DfndEES0WnRBF2qsAqBha22rQlGW43/VkaRLkjC1bjB8tiO5B6tCpOA== 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 (0) 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=DkHH+fnoWUA/OotvOLz14CCnzJupFLA6QF7QMnoceT0=; b=1ULHZuvLioVVVdkiCM/v6i7/ZtFTGl/J0DdsdUPueHKeJln205xKFqAjlG+VR5qho8Iy/izRF5QMZOcZxnHmhJ+LT33dS4yf/5eRVnoJKJ6lsm3wwBt+tyQkDqmG8f1FnWUKHYhXsI12P56jH5ykxPhTAv81E5LNV3aNs2lM200= Received: from SA0PR11CA0003.namprd11.prod.outlook.com (2603:10b6:806:d3::8) by SA0PR12MB4383.namprd12.prod.outlook.com (2603:10b6:806:94::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Tue, 30 Jul 2024 18:30:14 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2603:10b6:806:d3:cafe::75) by SA0PR11CA0003.outlook.office365.com (2603:10b6:806:d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.34 via Frontend Transport; Tue, 30 Jul 2024 18:30:14 +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; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7828.19 via Frontend Transport; Tue, 30 Jul 2024 18:30:14 +0000 Received: from quartz-7b1chost.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.2507.39; Tue, 30 Jul 2024 13:30:10 -0500 From: Yazen Ghannam To: CC: , , , , , Yazen Ghannam Subject: [PATCH v3 3/3] x86/mce: Use mce_prep_record() helpers for apei_smca_report_x86_error() Date: Tue, 30 Jul 2024 13:29:58 -0500 Message-ID: <20240730182958.4117158-4-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730182958.4117158-1-yazen.ghannam@amd.com> References: <20240730182958.4117158-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|SA0PR12MB4383:EE_ X-MS-Office365-Filtering-Correlation-Id: 423d9cbc-4017-4f15-3ab0-08dcb0c5a741 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: iuLpXye8L7vITzn4CageqxOJSPKcXg3pgFfaSAyHBZTl7yS55wDAJ0a9gsAPNMChhDwOhp8Zn16YlLFBonxkFu9TSTiY7XtrFXoroYY7yzx+rjCbpaaQuwu6pmDzDrDZ2twAlQl70fnsegd1X+v1AYlXWeM+omcCwWbnQDPIxkMCkMf4dAXypqLESfrNJTzZlFKO7ynZTkmHP+e0pubH5qBuSY9TneBpPKzGy1YzJ0ZuHZWZWWfTLru9eFFmOjdMLgHB4UVV0qRNG/8MQZYqASpLePxGXjJhTM7DJ70mtKu1lQdXX8tzA7qpE2VTgqR5tdCQoOEyHY3y/qE5rAG/wKGv1giOWBiDg1brKi/KJvjSoIJg7qvt7bsHHwhv/wEJt6p60NOD9eeBBWXjgDXogMOzV6CSkcPBCuy1IGMR76/2BkiL+BPCUzCjBa7UtDZIMX0Mi4BGTg11UfRr19s08reBhlBMnlO5ncr7i7VlxWSER2WUo/7D8Rkr2NEjWPF+9XNOXtIE/3sDgh+NM+Bt+lde29RgmHBP/D9bFVwSeEPJQSa+o3/opEJsk+DEkhltI/fWQNPNkebbaxpUZALKVC+1nhrBLNC2xkIrhi/k6DX7eRWMZ+ycqDDr9RCiLf2dhlJwsOCNcfmLI0Lf1tCXn9RJ3peAIlk9go3puf8zbqZaI0I3C9ZKoz7aTaLvdhiHHgyMz0TzmhZhicfXt0pN9jP+u2A0N0aPOftOp/+loT06SefXD3jH947q4v9SbgvaYPEv6M+qT4Qm4x06XnQtvhgmFkc5nRbDGNowQwiCRZYOl+4G5mUXlHBmsQVZjDhpQMejZrhC+tC6Wt++X5y4DCvl2Bb2j8Z1fWwsOgaLm/Hcxct7+j3LMg8qPp9jsBU+5Ti2T8ITqkEi8rllMDpXVYyzOado4OylF1Ekn1UJu0eMhJnB6/jka4JVUZAmai20nxmtJvgF54q8RhjckNHavOZdXGiR0Q5a7mFvt9F1+boqc5HV8ZGEOaaRSQwF2FrSK28kJQLETwMC5LooxgsiSjxKmaPJTryucV10s38wu82GzGNe/7QxiFrNjbIMDHSIQami8EoR+QSpbKZBg3M7VTmKROephmFpradNpa8IKEiodso2Ch/le36ZNQp2MPW63/ADnJe1mltxtI/OaEwKnOxl7D7mnSvSZ3jMjZc/sYzNT5osRvuJmCgf+EcgK8IASgourLNyUnmyoxOqLVP1Be9Y5Rk9+6iRCOr4Sg7pj7pAs0FjEo+lH4wilIjHoBlKc+Cn6Ki1SFj5MGjX+pfcVXbxdQridICK8ImbtL4xfuTfq7MIy/rniH4x39tVgB3M9wVnTg9PZ/FixQAfwPmEPln/AZvCsCek7c8n4QjspLbdcbfIOE+hLmvzkmQU4SgG52EAHjOJ/N26Gc0uGBeRNQ== 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:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 18:30:14.0102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 423d9cbc-4017-4f15-3ab0-08dcb0c5a741 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: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4383 Current AMD systems can report MCA errors using the ACPI Boot Error Record Table (BERT). The BERT entries for MCA errors will be an x86 Common Platform Error Record (CPER) with an MSR register context that matches the MCAX/SMCA register space. However, the BERT will not necessarily be processed on the CPU that reported the MCA errors. Therefore, the correct CPU number needs to be determined and the information saved in struct mce. Use the newly defined mce_prep_record_*() helpers to get the correct data. Also, add an explicit check to verify that a valid CPU number was found from the APIC ID search. Signed-off-by: Yazen Ghannam --- Link: https://lkml.kernel.org/r/20240624212008.663832-6-yazen.ghannam@amd.com v2->v3: * Drop topology export changes from v2. * Use boolean for match search (Boris). v1->v2: * Rebased on topology export changes from patches 1 and 2. arch/x86/kernel/cpu/mce/apei.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 8f509c8a4e98..3885fe05f01e 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -66,6 +66,7 @@ EXPORT_SYMBOL_GPL(apei_mce_report_mem_error); int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) { const u64 *i_mce = ((const u64 *) (ctx_info + 1)); + bool apicid_found = false; unsigned int cpu; struct mce m; @@ -97,20 +98,19 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) if (ctx_info->reg_arr_size < 48) return -EINVAL; - mce_prep_record(&m); - - m.extcpu = -1; - m.socketid = -1; - for_each_possible_cpu(cpu) { if (cpu_data(cpu).topo.initial_apicid == lapic_id) { - m.extcpu = cpu; - m.socketid = cpu_data(m.extcpu).topo.pkg_id; + apicid_found = true; break; } } - m.apicid = lapic_id; + if (!apicid_found) + return -EINVAL; + + mce_prep_record_common(&m); + mce_prep_record_per_cpu(cpu, &m); + m.bank = (ctx_info->msr_addr >> 4) & 0xFF; m.status = *i_mce; m.addr = *(i_mce + 1);