From nobody Tue Dec 16 13:35:04 2025 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013036.outbound.protection.outlook.com [40.93.196.36]) (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 DDB1932ED50; Tue, 4 Nov 2025 14:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268164; cv=fail; b=Da2pjMnqHLAygjyWGHivXh8Y/0IUC6lsbbMSH++TOb+4K229ua1SNgY0m9bb9S2adaglzpWUZHMJRZ1LgCHx9wsjbeLnQsRYHQDqGhmEXN56W32i97lvTHOsmlnlhgtBL870C3F01r++maubRAluTiL+pFoMstPZZVe5HU1wgD0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268164; c=relaxed/simple; bh=i9kJU4x7/ywoptEY/gZp/99cal6XlkpSJoRNyqLdd3o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Uj9fPBeVLzePxrmQBsGh710gNA8R2Dk9p7tVhKsWSgDFmtJRguXp1/2RzU+B3h7G2QsOzG6xQ5KJR6N74623KPywYXjWPscJenG0VWAx+PmTMlo7zUjoe88qc9wp8+YGdlUoWp7t4kFoQ33pYH/f7iVIEg8T9+OLchR9MxKySDE= 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=Oz9VLhkO; arc=fail smtp.client-ip=40.93.196.36 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="Oz9VLhkO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OSeXq/v58DlTnpF1wIfD19TBOUNKpuwPbFS1gMDnxnMYmn6O5PvDHSRFXpiaS7PNTqO/fGAd+jUbahCS/EQFghRaPpx/wWf2/5S7er/dpCZNxEsqYRzDr+tsaEhKQa0K+QTUjes91LmNLRsjdRN/CU0fMtybjGxx9W3stWWghuTagpYGOiHUBQQJjvUvhBXOhHK2dLTcnB3Qnv15Kb8i5+Ktf3yHVltMBPYieCMzWvLVVJWaECMIkRgqaL2yq200KAB4EzsaZA0KVGBd+Wubku+ZTCgg/l8HwjoYbJVN3Dj1xO0sMYh3gITgr355pJZ0uH1SxTn5sTFshkp3ttjtzw== 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=1PuLC7h1opB7XQduXmGE+0GqzkFETv/uc052TSVpax4=; b=GSznKwN4zv/7cp8vPylcfLyL5LqVwW2v5ptMzbKQu6WUCpXI4qZQFLt5fwo0aKTgURDCrFl86UtBGsg0+sWDvFwNSe2/JB8eXRjj6V05PkZzuNNmtWvJURh5IqvabHKa5m9RQgcazj1vkzPwSxhrsAoPazxH3LTi7BkTzfd7b8yBeCYSTe6PQZSLdSkwxs4SlMPN0iAIf0yB9bZQPKNd5IOoIYEJhXEjpY9jGVg7F94pNhqh6JARgS1mlUDiqgLW9W9SUGx8Vw1frod4u2wx04Vrgx/kZF64PfoGxu4CtohFUx6uSF1lx9hg4a64yCCttz6StdMJXo0DJiMQ2SxzyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=1PuLC7h1opB7XQduXmGE+0GqzkFETv/uc052TSVpax4=; b=Oz9VLhkOR12kUHs8zMJqudPAhL96+T9OOL6pnA4cmlbUaTSD5NQhjEu4DXacdhgxusPG5UoqfLnRXSzk5gyGGGkPALZd5dQa2RJeogGco4zglb9tOinmm6l8Gy8uhzJfq9PnN9fDdFZyiZ19R+EplApfLNGx4C4MO0yGNbT/yHo= Received: from DM6PR06CA0096.namprd06.prod.outlook.com (2603:10b6:5:336::29) by CY5PR12MB6057.namprd12.prod.outlook.com (2603:10b6:930:2e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.15; Tue, 4 Nov 2025 14:55:57 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::7) by DM6PR06CA0096.outlook.office365.com (2603:10b6:5:336::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9298.7 via Frontend Transport; Tue, 4 Nov 2025 14:55:56 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:55:56 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:51 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:38 +0000 Subject: [PATCH v8 1/8] x86/mce: Unify AMD THR handler with MCA Polling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-1-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|CY5PR12MB6057:EE_ X-MS-Office365-Filtering-Correlation-Id: ed9cfb52-21a0-4cfb-7c27-08de1bb24292 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?d2JQbU9PSjJmM3A5WVhwaityQ09kZWcxOUlBbTNZc1A2YVNEcVU3b3dQbWMr?= =?utf-8?B?N3NuNmU4emx3SlpINGxnNjZ0VCtrRGxzS2I1dmh1eEFicFI2aHRLd2svUVQ1?= =?utf-8?B?TlBpL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vYzZ1d0pIQU5ReTlaam0zL1ZVZjJEc29U?= =?utf-8?B?MTlTaXYzRmwzcmNHTjdIZWRMc1ZKbVpuWDhWbFkwSUREL2o4V1lQQm1UdEtk?= =?utf-8?B?OWswSWJyRnhjVTVhNzJxNnZCMFNzZytlTlNSc1laUkUrZTgzaElNNHgvQUV2?= =?utf-8?B?WU5xd01sak9HT0dsb055K1FETlVtTmR5TXRnSWNGMlFTbmxNWUFPcDI2MUNM?= =?utf-8?Q?jYmk=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:55:56.7401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed9cfb52-21a0-4cfb-7c27-08de1bb24292 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6057 AMD systems optionally support an MCA thresholding interrupt. The interrupt should be used as another signal to trigger MCA polling. This is similar to how the Intel Corrected Machine Check interrupt (CMCI) is handled. AMD MCA thresholding is managed using the MCA_MISC registers within an MCA bank. The OS will need to modify the hardware error count field in order to reset the threshold limit and rearm the interrupt. Management of the MCA_MISC register should be done as a follow up to the basic MCA polling flow. It should not be the main focus of the interrupt handler. Furthermore, future systems will have the ability to send an MCA thresholding interrupt to the OS even when the OS does not manage the feature, i.e. MCA_MISC registers are Read-as-Zero/Locked. Call the common MCA polling function when handling the MCA thresholding interrupt. This will allow the OS to find any valid errors whether or not the MCA thresholding feature is OS-managed. Also, this allows the common MCA polling options and kernel parameters to apply to AMD systems. Add a callback to the MCA polling function to check and reset any threshold blocks that have reached their threshold limit. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-1-5c139a4062cb@am= d.com =20 v7->v8: * No change. =20 v6->v7: * No change. =20 v5->v6: * Move bank/block reset code to new helper. =20 v4->v5: * No change. =20 v3->v4: * No change. =20 v2->v3: * Add tags from Qiuxu and Tony. =20 v1->v2: * Start collecting per-CPU items in a struct. * Keep and use mce_flags.amd_threshold. arch/x86/kernel/cpu/mce/amd.c | 51 +++++++++++++++++++--------------------= ---- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index d6906442f49b..ac6a98aa7bc2 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -54,6 +54,12 @@ =20 static bool thresholding_irq_en; =20 +struct mce_amd_cpu_data { + mce_banks_t thr_intr_banks; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct mce_amd_cpu_data, mce_amd_data); + static const char * const th_names[] =3D { "load_store", "insn_fetch", @@ -556,6 +562,7 @@ prepare_threshold_block(unsigned int bank, unsigned int= block, u32 addr, if (!b.interrupt_capable) goto done; =20 + __set_bit(bank, this_cpu_ptr(&mce_amd_data)->thr_intr_banks); b.interrupt_enable =3D 1; =20 if (!mce_flags.smca) { @@ -896,12 +903,7 @@ static void amd_deferred_error_interrupt(void) log_error_deferred(bank); } =20 -static void log_error_thresholding(unsigned int bank, u64 misc) -{ - _log_error_deferred(bank, misc); -} - -static void log_and_reset_block(struct threshold_block *block) +static void reset_block(struct threshold_block *block) { struct thresh_restart tr; u32 low =3D 0, high =3D 0; @@ -915,23 +917,14 @@ static void log_and_reset_block(struct threshold_bloc= k *block) if (!(high & MASK_OVERFLOW_HI)) return; =20 - /* Log the MCE which caused the threshold event. */ - log_error_thresholding(block->bank, ((u64)high << 32) | low); - - /* Reset threshold block after logging error. */ memset(&tr, 0, sizeof(tr)); tr.b =3D block; threshold_restart_block(&tr); } =20 -/* - * Threshold interrupt handler will service THRESHOLD_APIC_VECTOR. The int= errupt - * goes off when error_count reaches threshold_limit. - */ -static void amd_threshold_interrupt(void) +static void amd_reset_thr_limit(unsigned int bank) { - struct threshold_bank **bp =3D this_cpu_read(threshold_banks), *thr_bank; - unsigned int bank, cpu =3D smp_processor_id(); + struct threshold_bank **bp =3D this_cpu_read(threshold_banks); struct threshold_block *block, *tmp; =20 /* @@ -939,24 +932,26 @@ static void amd_threshold_interrupt(void) * handler is installed at boot time, but on a hotplug event the * interrupt might fire before the data has been initialized. */ - if (!bp) + if (!bp || !bp[bank]) return; =20 - for (bank =3D 0; bank < this_cpu_read(mce_num_banks); ++bank) { - if (!(per_cpu(bank_map, cpu) & BIT_ULL(bank))) - continue; - - thr_bank =3D bp[bank]; - if (!thr_bank) - continue; + list_for_each_entry_safe(block, tmp, &bp[bank]->miscj, miscj) + reset_block(block); +} =20 - list_for_each_entry_safe(block, tmp, &thr_bank->miscj, miscj) - log_and_reset_block(block); - } +/* + * Threshold interrupt handler will service THRESHOLD_APIC_VECTOR. The int= errupt + * goes off when error_count reaches threshold_limit. + */ +static void amd_threshold_interrupt(void) +{ + machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->thr_intr_= banks); } =20 void amd_clear_bank(struct mce *m) { + amd_reset_thr_limit(m->bank); + mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0); } =20 --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013012.outbound.protection.outlook.com [40.107.201.12]) (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 336A032E75A; Tue, 4 Nov 2025 14:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268162; cv=fail; b=XtlOU31xAeROk26nGv93LscU2lS6vVLyx0U3eZdDLLUN08UDfQU7zwOnuoqQYFsIczSujFPJbw2YG+nQ2LYp5pt5qS8zc90CsUoxUek8EAXd/iaTqgbrLDQO9IYuJ5w7rxNmerkwxBPvlbUh3+0HpnzYWgtfFqIv71MAgiJ3yV0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268162; c=relaxed/simple; bh=1hgU//1Ywyt8KjRhC07xChNP3cWmoPufOpYBpO9QvsE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=qC3OPcQZuv9daNpbUJVkvP0r18pNYou+0LzZZ4t+ta3jGTPqz3NgAJDsZQWCGGOBszWBcDZFS+FfGcz6FDxbKomksmLPXMbiwr9jE4zyb/cYBnQySun995XCK3kaeCilFy8jbfT5Spf8+C0k0xPK+55nLry7xuTJBnkLVonSX5g= 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=CsBZiM4C; arc=fail smtp.client-ip=40.107.201.12 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="CsBZiM4C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uzZu3OMneJ5/Kjhed2xupEix9pjbOYUdr89Z/QmH/WxRkoVMfTZsKMgbznoobsZfdX9XfUjn+R3BJ/KdNqRlErWUB5nUWbBq/pFUSctbApyV4B0vFnyj528abn1ZWYWB7ohwXyq1QrMlzTLLNtgViSsxxSHYYYFO4jfSd/P/86LxcpPYMnfowccy4Z5LWRbMJpPLl+rEtd241+0+LUOccaXS99P13gkqFtFxv50+lkmW372ooVrQxbvMrBye20FkpGr9AGDkzyu9y7DuQtP6LoM9lWCyEeDvCWNDr4YoMFp/cPcu2k6HtiKzmTGkmxlW998R8rrpV9B0lpu9Hclbww== 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=6osGcKJQtHqc12vZqDP0ztpUSofFSKoggee8bfrIQ3M=; b=qb5s1GtqkIfT9bDBcGBQ5fQHDFA/NQu4Mf4Ouxf9DaxG53pB5BU7VgiHoBC7pJbYa62aq2yyN6YhHfj4ZlNWZ0mBFE2d8FJ95KsuFab7seB0OaAT/y8FVbcfUJIO/1PR1yOkj0PAoTdv1hoplR39u1xhOBGtRqfaCIjwsty7jGhmecJ6PwDxrEbiFLNzM28rWkh8DRcD0vuEOVqMGN02yrX5isCTSIIHZLZXjdadVDLYJxXRI5JpWZo6XFmY61LgXYnaxk3Ato9v4qrnNbv3/9wDW0EllnXzslWXgpFpVCH6mPu4Z38rdDgSq2/Wmsei/w7qQj/auBwl/0hw0C7AUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=6osGcKJQtHqc12vZqDP0ztpUSofFSKoggee8bfrIQ3M=; b=CsBZiM4C0qogYR7PxKFOgpNd04ZYPHJBZT/3yW2J3ANqVArBs5fjbMGQpIbXR8LmN7cxBTQBgeGy97ICbowfkaTsxodDD2YphJUM+ZjI5jPnmhN+DVCNji78LWob3NUzRq+WWW5cC8LocI4RSRcWFCLzcR0hjw2H7W7oPEOqYEg= Received: from DM6PR06CA0101.namprd06.prod.outlook.com (2603:10b6:5:336::34) by PH0PR12MB8822.namprd12.prod.outlook.com (2603:10b6:510:28d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Tue, 4 Nov 2025 14:55:57 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::d5) by DM6PR06CA0101.outlook.office365.com (2603:10b6:5:336::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9275.16 via Frontend Transport; Tue, 4 Nov 2025 14:55:20 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:55:57 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:51 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:39 +0000 Subject: [PATCH v8 2/8] x86/mce: Unify AMD DFR handler with MCA Polling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-2-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|PH0PR12MB8822:EE_ X-MS-Office365-Filtering-Correlation-Id: 912b796b-e036-4aba-1671-08de1bb242e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?UTI2Y043YTRJOEVOeHExS3haUzF2STEzUUpCQVFpOGRzUkdaKzFvWllBemZ4?= =?utf-8?B?TzBEeDNlcis0YlBwVkZUUnpKd1B4cHppZmxvdWdtbDdZd0hkRzdqUDluNklQ?= =?utf-8?B?ck9mMEtZYnRzakNxK0pEQmRmbGI2dzlzRDRra3hGQVRpbWd2UUdOYm5tZDlM?= =?utf-8?B?dW1TVGRRb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vbXh2Zkpl?= =?utf-8?B?OENCdzJpbm90QWJLOW8xdWRFekNQMUhYUlFtdUREOTVtRWlmYWRYQkZPSDds?= =?utf-8?B?MGw3eVhZeXZPckIyeE1KV0tjMHpValMwVjBEUlE0dHA0MEh3S3ZGV2VjMjMz?= =?utf-8?Q?c2njQ/gK7KFn8/q181z1Lxe5W?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:55:57.2769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 912b796b-e036-4aba-1671-08de1bb242e4 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8822 AMD systems optionally support a deferred error interrupt. The interrupt should be used as another signal to trigger MCA polling. This is similar to how other MCA interrupts are handled. Deferred errors do not require any special handling related to the interrupt, e.g. resetting or rearming the interrupt, etc. However, Scalable MCA systems include a pair of registers, MCA_DESTAT and MCA_DEADDR, that should be checked for valid errors. This check should be done whenever MCA registers are polled. Currently, the deferred error interrupt does this check, but the MCA polling function does not. Call the MCA polling function when handling the deferred error interrupt. This keeps all "polling" cases in a common function. Add an SMCA status check helper. This will do the same status check and register clearing that the interrupt handler has done. And it extends the common polling flow to find AMD deferred errors. Clear the MCA_DESTAT register at the end of the handler rather than the beginning. This maintains the procedure that the 'status' register must be cleared as the final step. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-2-5c139a4062cb@am= d.com =20 v7->v8: * Simplify code flow and comments. (Boris) =20 v6->v7: * Rework DFR error handling to avoid reporting bogus errors. * Clear MCA_DESTAT at the end of handler. (Nikolay) * Link: https://lore.kernel.org/r/20250915010010.3547-1-spasswolf@web.de =20 v5->v6: * Move status clearing code to new helper. =20 v4->v5: * No change. =20 v3->v4: * Add kflag for checking DFR registers. =20 v2->v3: * Add tags from Qiuxu and Tony. =20 v1->v2: * Keep code comment. * Log directly from helper function rather than pass values. =20 Link: https://lore.kernel.org/r/20250213-wip-mca-updates-v2-13-3636547fe05f@a= md.com =20 v2->v3: * Add tags from Qiuxu and Tony. =20 v1->v2: * Keep code comment. * Log directly from helper function rather than pass values. arch/x86/include/asm/mce.h | 6 +++ arch/x86/kernel/cpu/mce/amd.c | 111 +++++--------------------------------= ---- arch/x86/kernel/cpu/mce/core.c | 31 +++++++++++- 3 files changed, 49 insertions(+), 99 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 31e3cb550fb3..7d6588195d56 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -165,6 +165,12 @@ */ #define MCE_IN_KERNEL_COPYIN BIT_ULL(7) =20 +/* + * Indicates that handler should check and clear Deferred error registers + * rather than common ones. + */ +#define MCE_CHECK_DFR_REGS BIT_ULL(8) + /* * This structure contains all data related to the MCE log. Also * carries a signature to make it easier to find from external diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index ac6a98aa7bc2..d9f9ee7db5c8 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -56,6 +56,7 @@ static bool thresholding_irq_en; =20 struct mce_amd_cpu_data { mce_banks_t thr_intr_banks; + mce_banks_t dfr_intr_banks; }; =20 static DEFINE_PER_CPU_READ_MOSTLY(struct mce_amd_cpu_data, mce_amd_data); @@ -300,8 +301,10 @@ static void smca_configure(unsigned int bank, unsigned= int cpu) * APIC based interrupt. First, check that no interrupt has been * set. */ - if ((low & BIT(5)) && !((high >> 5) & 0x3)) + if ((low & BIT(5)) && !((high >> 5) & 0x3)) { + __set_bit(bank, this_cpu_ptr(&mce_amd_data)->dfr_intr_banks); high |=3D BIT(5); + } =20 this_cpu_ptr(mce_banks_array)[bank].lsb_in_status =3D !!(low & BIT(8)); =20 @@ -792,37 +795,6 @@ bool amd_mce_usable_address(struct mce *m) return false; } =20 -static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) -{ - struct mce_hw_err err; - struct mce *m =3D &err.m; - - mce_prep_record(&err); - - m->status =3D status; - m->misc =3D misc; - m->bank =3D bank; - m->tsc =3D rdtsc(); - - if (m->status & MCI_STATUS_ADDRV) { - m->addr =3D addr; - - smca_extract_err_addr(m); - } - - if (mce_flags.smca) { - rdmsrq(MSR_AMD64_SMCA_MCx_IPID(bank), m->ipid); - - if (m->status & MCI_STATUS_SYNDV) { - rdmsrq(MSR_AMD64_SMCA_MCx_SYND(bank), m->synd); - rdmsrq(MSR_AMD64_SMCA_MCx_SYND1(bank), err.vendor.amd.synd1); - rdmsrq(MSR_AMD64_SMCA_MCx_SYND2(bank), err.vendor.amd.synd2); - } - } - - mce_log(&err); -} - DEFINE_IDTENTRY_SYSVEC(sysvec_deferred_error) { trace_deferred_error_apic_entry(DEFERRED_ERROR_VECTOR); @@ -832,75 +804,10 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_deferred_error) apic_eoi(); } =20 -/* - * Returns true if the logged error is deferred. False, otherwise. - */ -static inline bool -_log_error_bank(unsigned int bank, u32 msr_stat, u32 msr_addr, u64 misc) -{ - u64 status, addr =3D 0; - - rdmsrq(msr_stat, status); - if (!(status & MCI_STATUS_VAL)) - return false; - - if (status & MCI_STATUS_ADDRV) - rdmsrq(msr_addr, addr); - - __log_error(bank, status, addr, misc); - - wrmsrq(msr_stat, 0); - - return status & MCI_STATUS_DEFERRED; -} - -static bool _log_error_deferred(unsigned int bank, u32 misc) -{ - if (!_log_error_bank(bank, mca_msr_reg(bank, MCA_STATUS), - mca_msr_reg(bank, MCA_ADDR), misc)) - return false; - - /* - * Non-SMCA systems don't have MCA_DESTAT/MCA_DEADDR registers. - * Return true here to avoid accessing these registers. - */ - if (!mce_flags.smca) - return true; - - /* Clear MCA_DESTAT if the deferred error was logged from MCA_STATUS. */ - wrmsrq(MSR_AMD64_SMCA_MCx_DESTAT(bank), 0); - return true; -} - -/* - * We have three scenarios for checking for Deferred errors: - * - * 1) Non-SMCA systems check MCA_STATUS and log error if found. - * 2) SMCA systems check MCA_STATUS. If error is found then log it and also - * clear MCA_DESTAT. - * 3) SMCA systems check MCA_DESTAT, if error was not found in MCA_STATUS,= and - * log it. - */ -static void log_error_deferred(unsigned int bank) -{ - if (_log_error_deferred(bank, 0)) - return; - - /* - * Only deferred errors are logged in MCA_DE{STAT,ADDR} so just check - * for a valid error. - */ - _log_error_bank(bank, MSR_AMD64_SMCA_MCx_DESTAT(bank), - MSR_AMD64_SMCA_MCx_DEADDR(bank), 0); -} - /* APIC interrupt handler for deferred errors */ static void amd_deferred_error_interrupt(void) { - unsigned int bank; - - for (bank =3D 0; bank < this_cpu_read(mce_num_banks); ++bank) - log_error_deferred(bank); + machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->dfr_intr_= banks); } =20 static void reset_block(struct threshold_block *block) @@ -952,6 +859,14 @@ void amd_clear_bank(struct mce *m) { amd_reset_thr_limit(m->bank); =20 + /* Clear MCA_DESTAT for all deferred errors even those logged in MCA_STAT= US. */ + if (m->status & MCI_STATUS_DEFERRED) + mce_wrmsrq(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0); + + /* Don't clear MCA_STATUS if MCA_DESTAT was used exclusively. */ + if (m->kflags & MCE_CHECK_DFR_REGS) + return; + mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0); } =20 diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 460e90a1a0b1..4aff14e04287 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -687,7 +687,10 @@ static noinstr void mce_read_aux(struct mce_hw_err *er= r, int i) m->misc =3D mce_rdmsrq(mca_msr_reg(i, MCA_MISC)); =20 if (m->status & MCI_STATUS_ADDRV) { - m->addr =3D mce_rdmsrq(mca_msr_reg(i, MCA_ADDR)); + if (m->kflags & MCE_CHECK_DFR_REGS) + m->addr =3D mce_rdmsrq(MSR_AMD64_SMCA_MCx_DEADDR(i)); + else + m->addr =3D mce_rdmsrq(mca_msr_reg(i, MCA_ADDR)); =20 /* * Mask the reported address by the reported granularity. @@ -714,6 +717,29 @@ static noinstr void mce_read_aux(struct mce_hw_err *er= r, int i) =20 DEFINE_PER_CPU(unsigned, mce_poll_count); =20 +/* + * We have three scenarios for checking for Deferred errors: + * + * 1) Non-SMCA systems check MCA_STATUS and log error if found. + * 2) SMCA systems check MCA_STATUS. If error is found then log it and also + * clear MCA_DESTAT. + * 3) SMCA systems check MCA_DESTAT, if error was not found in MCA_STATUS,= and + * log it. + */ +static bool smca_should_log_poll_error(struct mce *m) +{ + if (m->status & MCI_STATUS_VAL) + return true; + + m->status =3D mce_rdmsrq(MSR_AMD64_SMCA_MCx_DESTAT(m->bank)); + if ((m->status & MCI_STATUS_VAL) && (m->status & MCI_STATUS_DEFERRED)) { + m->kflags |=3D MCE_CHECK_DFR_REGS; + return true; + } + + return false; +} + /* * Newer Intel systems that support software error * recovery need to make additional checks. Other @@ -740,6 +766,9 @@ static bool should_log_poll_error(enum mcp_flags flags,= struct mce_hw_err *err) { struct mce *m =3D &err->m; =20 + if (mce_flags.smca) + return smca_should_log_poll_error(m); + /* If this entry is not valid, ignore it. */ if (!(m->status & MCI_STATUS_VAL)) return false; --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012069.outbound.protection.outlook.com [52.101.53.69]) (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 751A933290A; Tue, 4 Nov 2025 14:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268170; cv=fail; b=O9SbWi+qyIC2SMEtJWiwGJEXr93x2qM1trjz8EEQTNL9hHl1EcgLBLlIpU9C1S1obIXKzRF8Tgs4g6WA/pf3s2FVYv6Ea/4rBj33CKiuHkGrPdM4Z7NSY5+cZiRcN+jlVwNtfIbsDpqI9xQcipcyEjDK7Lgyl8ZlvHKgnxALSsc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268170; c=relaxed/simple; bh=XANYXjGICx5CHYuFLmzvYFYO4YU9kwwvRm3qhZdSVNA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=f0CG87O8dchWnxaWuZDSKkwECiSLHChSzuVdbbaFUR/KPjANxp9+jjS+eJ0Ry08aUcw3qVt8nzN2R79EkO/UWYSZd4Cusymgp3RT+cu5PGHVnIb71xENPzSL8iTM5MirmUfedjau/abVtMrgDxd/IWU+vtCFzWeK5W8ZseLqaYA= 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=24E1Fojf; arc=fail smtp.client-ip=52.101.53.69 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="24E1Fojf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ISR4fpQSDL8nQvo5LNZQRgYHomgsxrwz8MlJ1HErxehcVwHgd8Ej6Bj8JlglmbSON5eUHoxYUK3TiO6r29v2ZclQlBab8Tw4cQHOeScr+e5/ryL7hPpEwLgMkMnpHf1IGNS83GUC3tBC9CDdfW0d1kaMRunJfFgsSJC1rpWwKNC3GOXttB+DGeuux4v0iERtdErWt0/BZvflou4kHg4QZjLhAaGAqqHwEsgdLBpV9sf2cJ/YB1+Xr8b339ao3qa4EouxyHenX8rBCuboDqYgtzm9KXklvUfzKZzEKnHtjvjIeiE4/IUTt64fEYTlNkXhxnUrc2iOSBwia7+7w04bsA== 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=pEYe3YXvmtgdbe6TIq26dQ/JiGwwxPDqLF6u6iKlaXc=; b=HkyYo1FOE2Vr3o25Cfk/T0DI3sk4QgS7g05IQLZXuWwpTOPNUseUAT2xooygIhd1/b596kflwJSxAfy60z1bRIi1l9sZe8RwZ6Goz/wztBWINt2jCDtHM7dB6BZXkC5rQ0uromilm+Uk3d18cLCdPPoFYu5fs855tYXBP5k1qzy7vR7CR/BQslXweeIHnbegshyBMsSIDjNZ7HANknXavKETPJSe9TLgatoZYUFR4SxZ0zw9woMx7VCUiMTaBrLB+jWlnZFW4MrP8a1qC4VkdcnUDw1/LesJUA4i2Hs3ulJ9MJfr3gjXeaLnjXTGZBCkDixB+59HGVrOZG6RBDXnsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=pEYe3YXvmtgdbe6TIq26dQ/JiGwwxPDqLF6u6iKlaXc=; b=24E1Fojfeo/0vVmy1V2hXxFMELS/f4CcZeWZuSQ+msv1fGwuLSDqOGNmy3IfXr71A6z9NWt7z4+4h8g94xQG1xYZ4o4ZWlhbjQriUEAcFGAHXAinSq3GzcTUvBb5ED+viSiQ1aIzD25ylgBmCW9SjAaawSFitgYR17JuciPtq4U= Received: from DM6PR06CA0081.namprd06.prod.outlook.com (2603:10b6:5:336::14) by SJ0PR12MB8091.namprd12.prod.outlook.com (2603:10b6:a03:4d5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Tue, 4 Nov 2025 14:55:58 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::64) by DM6PR06CA0081.outlook.office365.com (2603:10b6:5:336::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9298.7 via Frontend Transport; Tue, 4 Nov 2025 14:55:56 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:55:57 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:52 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:40 +0000 Subject: [PATCH v8 3/8] x86/mce/amd: Enable interrupt vectors once per-CPU on SMCA systems Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-3-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|SJ0PR12MB8091:EE_ X-MS-Office365-Filtering-Correlation-Id: 24fcc305-4b96-48c4-90fe-08de1bb24339 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MFd0cE1oSEJwYUI2cm5jd1dDck12SjNsemJYZUlNaVF0dlVodkZob2dzRXhY?= =?utf-8?B?RVFXelg1TklmczRC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OMVlFcThsWlZv?= =?utf-8?B?cnJOYTY3Z1hBaG9JbzFIYW91MVRhQW1LRTBYTG5TUURpKzd3UlFTaGo3bVZG?= =?utf-8?B?SUxRUExKU1BoUERBYWxBMDR6cldHVVFOZkhqaTdhSkpOQzA4M2VYRU4vWXIr?= =?utf-8?B?V01DUzVSY2hrSkJjbVJuam1mRU80WkhlK1pjZDZCTWVoR0NtY0Q3aC9PNEo2?= =?utf-8?B?a0I1akR0dHhpdVFDWG9IQ3l1ZHBtaHU5aDBxakQ3SzlqS0p3M0hMaW1MTVNl?= =?utf-8?Q?9+R75DV/5CuX9xfNI5Jz3hqAQ?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:55:57.8367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24fcc305-4b96-48c4-90fe-08de1bb24339 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8091 Scalable MCA systems have a per-CPU register that gives the APIC LVT offset for the thresholding and deferred error interrupts. Currently, this register is read once to set up the deferred error interrupt and then read again for each thresholding block. Furthermore, the APIC LVT registers are configured each time, but they only need to be configured once per-CPU. Move the APIC LVT setup to the early part of CPU init, so that the registers are set up once. Also, this ensures that the kernel is ready to service the interrupts before the individual error sources (each MCA bank) are enabled. Apply this change only to SMCA systems to avoid breaking any legacy behavior. The deferred error interrupt is technically advertised by the SUCCOR feature. However, this was first made available on SMCA systems. Therefore, only set up the deferred error interrupt on SMCA systems and simplify the code. Guidance from hardware designers is that the LVT offsets provided from the platform should be used. The kernel should not try to enforce specific values. However, the kernel should check that an LVT offset is not reused for multiple sources. Therefore, remove the extra checking and value enforcement from the MCE code. The "reuse/conflict" case is already handled in setup_APIC_eilvt(). Tested-by: Tony Luck Reviewed-by: Tony Luck Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-3-5c139a4062cb@am= d.com =20 v7->v8: * No change. =20 v6->v7: * No change. =20 v5->v6: * Applied "bools to flags" and other fixups from Boris. =20 v4->v5: * Added back to set. * Updated commit message with more details. =20 v3->v4: * Dropped from set. =20 v2->v3: * Add tags from Tony. =20 v1->v2: * Use new per-CPU struct. * Don't set up interrupt vectors. arch/x86/kernel/cpu/mce/amd.c | 121 ++++++++++++++++++--------------------= ---- 1 file changed, 53 insertions(+), 68 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index d9f9ee7db5c8..117165c357b7 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -43,9 +43,6 @@ /* Deferred error settings */ #define MSR_CU_DEF_ERR 0xC0000410 #define MASK_DEF_LVTOFF 0x000000F0 -#define MASK_DEF_INT_TYPE 0x00000006 -#define DEF_LVT_OFF 0x2 -#define DEF_INT_TYPE_APIC 0x2 =20 /* Scalable MCA: */ =20 @@ -57,6 +54,10 @@ static bool thresholding_irq_en; struct mce_amd_cpu_data { mce_banks_t thr_intr_banks; mce_banks_t dfr_intr_banks; + + u32 thr_intr_en: 1, + dfr_intr_en: 1, + __resv: 30; }; =20 static DEFINE_PER_CPU_READ_MOSTLY(struct mce_amd_cpu_data, mce_amd_data); @@ -271,6 +272,7 @@ void (*deferred_error_int_vector)(void) =3D default_def= erred_error_interrupt; =20 static void smca_configure(unsigned int bank, unsigned int cpu) { + struct mce_amd_cpu_data *data =3D this_cpu_ptr(&mce_amd_data); u8 *bank_counts =3D this_cpu_ptr(smca_bank_counts); const struct smca_hwid *s_hwid; unsigned int i, hwid_mcatype; @@ -301,8 +303,8 @@ static void smca_configure(unsigned int bank, unsigned = int cpu) * APIC based interrupt. First, check that no interrupt has been * set. */ - if ((low & BIT(5)) && !((high >> 5) & 0x3)) { - __set_bit(bank, this_cpu_ptr(&mce_amd_data)->dfr_intr_banks); + if ((low & BIT(5)) && !((high >> 5) & 0x3) && data->dfr_intr_en) { + __set_bit(bank, data->dfr_intr_banks); high |=3D BIT(5); } =20 @@ -377,6 +379,14 @@ static bool lvt_off_valid(struct threshold_block *b, i= nt apic, u32 lo, u32 hi) { int msr =3D (hi & MASK_LVTOFF_HI) >> 20; =20 + /* + * On SMCA CPUs, LVT offset is programmed at a different MSR, and + * the BIOS provides the value. The original field where LVT offset + * was set is reserved. Return early here: + */ + if (mce_flags.smca) + return false; + if (apic < 0) { pr_err(FW_BUG "cpu %d, failed to setup threshold interrupt " "for bank %d, block %d (MSR%08X=3D0x%x%08x)\n", b->cpu, @@ -385,14 +395,6 @@ static bool lvt_off_valid(struct threshold_block *b, i= nt apic, u32 lo, u32 hi) } =20 if (apic !=3D msr) { - /* - * On SMCA CPUs, LVT offset is programmed at a different MSR, and - * the BIOS provides the value. The original field where LVT offset - * was set is reserved. Return early here: - */ - if (mce_flags.smca) - return false; - pr_err(FW_BUG "cpu %d, invalid threshold interrupt offset %d " "for bank %d, block %d (MSR%08X=3D0x%x%08x)\n", b->cpu, apic, b->bank, b->block, b->address, hi, lo); @@ -473,41 +475,6 @@ static int setup_APIC_mce_threshold(int reserved, int = new) return reserved; } =20 -static int setup_APIC_deferred_error(int reserved, int new) -{ - if (reserved < 0 && !setup_APIC_eilvt(new, DEFERRED_ERROR_VECTOR, - APIC_EILVT_MSG_FIX, 0)) - return new; - - return reserved; -} - -static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c) -{ - u32 low =3D 0, high =3D 0; - int def_offset =3D -1, def_new; - - if (rdmsr_safe(MSR_CU_DEF_ERR, &low, &high)) - return; - - def_new =3D (low & MASK_DEF_LVTOFF) >> 4; - if (!(low & MASK_DEF_LVTOFF)) { - pr_err(FW_BUG "Your BIOS is not setting up LVT offset 0x2 for deferred e= rror IRQs correctly.\n"); - def_new =3D DEF_LVT_OFF; - low =3D (low & ~MASK_DEF_LVTOFF) | (DEF_LVT_OFF << 4); - } - - def_offset =3D setup_APIC_deferred_error(def_offset, def_new); - if ((def_offset =3D=3D def_new) && - (deferred_error_int_vector !=3D amd_deferred_error_interrupt)) - deferred_error_int_vector =3D amd_deferred_error_interrupt; - - if (!mce_flags.smca) - low =3D (low & ~MASK_DEF_INT_TYPE) | DEF_INT_TYPE_APIC; - - wrmsr(MSR_CU_DEF_ERR, low, high); -} - static u32 get_block_address(u32 current_addr, u32 low, u32 high, unsigned int bank, unsigned int block, unsigned int cpu) @@ -543,12 +510,10 @@ static u32 get_block_address(u32 current_addr, u32 lo= w, u32 high, return addr; } =20 -static int -prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr, - int offset, u32 misc_high) +static int prepare_threshold_block(unsigned int bank, unsigned int block, = u32 addr, + int offset, u32 misc_high) { unsigned int cpu =3D smp_processor_id(); - u32 smca_low, smca_high; struct threshold_block b; int new; =20 @@ -568,18 +533,10 @@ prepare_threshold_block(unsigned int bank, unsigned i= nt block, u32 addr, __set_bit(bank, this_cpu_ptr(&mce_amd_data)->thr_intr_banks); b.interrupt_enable =3D 1; =20 - if (!mce_flags.smca) { - new =3D (misc_high & MASK_LVTOFF_HI) >> 20; - goto set_offset; - } - - /* Gather LVT offset for thresholding: */ - if (rdmsr_safe(MSR_CU_DEF_ERR, &smca_low, &smca_high)) - goto out; - - new =3D (smca_low & SMCA_THR_LVT_OFF) >> 12; + if (mce_flags.smca) + goto done; =20 -set_offset: + new =3D (misc_high & MASK_LVTOFF_HI) >> 20; offset =3D setup_APIC_mce_threshold(offset, new); if (offset =3D=3D new) thresholding_irq_en =3D true; @@ -587,7 +544,6 @@ prepare_threshold_block(unsigned int bank, unsigned int= block, u32 addr, done: mce_threshold_block_init(&b, offset); =20 -out: return offset; } =20 @@ -678,6 +634,32 @@ static void amd_apply_cpu_quirks(struct cpuinfo_x86 *c) mce_banks[0].ctl =3D 0; } =20 +/* + * Enable the APIC LVT interrupt vectors once per-CPU. This should be done= before hardware is + * ready to send interrupts. + * + * Individual error sources are enabled later during per-bank init. + */ +static void smca_enable_interrupt_vectors(void) +{ + struct mce_amd_cpu_data *data =3D this_cpu_ptr(&mce_amd_data); + u64 mca_intr_cfg, offset; + + if (!mce_flags.smca || !mce_flags.succor) + return; + + if (rdmsrq_safe(MSR_CU_DEF_ERR, &mca_intr_cfg)) + return; + + offset =3D (mca_intr_cfg & SMCA_THR_LVT_OFF) >> 12; + if (!setup_APIC_eilvt(offset, THRESHOLD_APIC_VECTOR, APIC_EILVT_MSG_FIX, = 0)) + data->thr_intr_en =3D 1; + + offset =3D (mca_intr_cfg & MASK_DEF_LVTOFF) >> 4; + if (!setup_APIC_eilvt(offset, DEFERRED_ERROR_VECTOR, APIC_EILVT_MSG_FIX, = 0)) + data->dfr_intr_en =3D 1; +} + /* cpu init entry point, called from mce.c with preempt off */ void mce_amd_feature_init(struct cpuinfo_x86 *c) { @@ -689,10 +671,16 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) =20 mce_flags.amd_threshold =3D 1; =20 + smca_enable_interrupt_vectors(); + for (bank =3D 0; bank < this_cpu_read(mce_num_banks); ++bank) { - if (mce_flags.smca) + if (mce_flags.smca) { smca_configure(bank, cpu); =20 + if (!this_cpu_ptr(&mce_amd_data)->thr_intr_en) + continue; + } + disable_err_thresholding(c, bank); =20 for (block =3D 0; block < NR_BLOCKS; ++block) { @@ -713,9 +701,6 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) offset =3D prepare_threshold_block(bank, block, address, offset, high); } } - - if (mce_flags.succor) - deferred_error_interrupt_enable(c); } =20 void smca_bsp_init(void) --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012006.outbound.protection.outlook.com [40.93.195.6]) (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 B06F732E73A; Tue, 4 Nov 2025 14:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268163; cv=fail; b=scG5cgCqQPJ2TLNHxo4Zbd3gk2KOHIvNNQQKcVS0taR5ndXvD0ZgO+fnYw81DYFhEF3rQOWN4dHBIBBQ02kbjpl28I+nWw1OiT+znEJ0zfqWr2irlpT1CaYKf2Uz/xAqrmR1SkciSCKuL9bJCrPSFZe8eucP5SY7IZ1KTXyoqa0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268163; c=relaxed/simple; bh=hTWpumJFsUqB1Jfr3KBfXEpmKLe17uM6UWTPQrRjqLI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=jDFHfBskmwC0lwc0aVJgp+OAeOSJiVTCGG94zJ3pT/2iR3vSLBO8br5zcGJwzVcLNpwCy6CkGeEmjE8I8VerfdOKPHLoc7Cxl8bol0PfexYqIg4l4Klka6zjUkE7IGKzibDufibphzXsQt+WLRskswlQJ6ltm7irnhbSlN7NBFE= 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=5UetMOGZ; arc=fail smtp.client-ip=40.93.195.6 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="5UetMOGZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TwF/O+6oa2EOZPVHcxZMCgKMk1EScWtnLdD9gACXBP7nFDvkqPP58Sis9yVscmNFoK1RlgC3+2d1LaGR8gO1xtiqmnwRAnWQMj25qkCcPNIpgMiJCiRcAbNZlAMi+Kkoj1qWEj77oMQfYLwQGqNYq9ET7acoNY1O+esbRHm/hJisQV1ElfTFOHz1dkfN+NtlUAHixQvW0vep7VCAiLRqGZ7/S7lfkP17SxQGm6vukzgW9ws02GNP5b84Dk2OQwECOK37CwFZTR6un8nEJ3aM2ox5c2tMYm3WN0wD3WCEv8Qklq/9hjemoyakK2iUDgUfU8wV96ujFiJJHRuMvpC8RQ== 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=p8uDr4k/B7M10ZgLnJu9RXiehL+lC+7PazjkNrO4toM=; b=FRaLj07349LDXKI6pHONhoyc2kunhSPVFyL6Mw4tlsmnvzu+Ls8ETYVeS8vQfUXDlC9Pj7q9qjMq9oiiyDHgZBKP81pV+jbykxCwF/yQ9g4IGRDNQqEaMORkQ3hyJwb9w3w3FGrypDKSY/AmbZ4Skv0g0KoTz36DaZ5KL3U/iGskLHR6Dd5qQVjszUB3KjyaCyr0tbpe/YHn2mHEKYy15bt/DV9LYc756iI1lB8S5AgngGjImOyoXUBUBor92Uh1iYprMEPo+wlalqosP3YpS/RYazG4dVOIszSDkXmo8TwgDrbnfSpBrWnolBJQ5gG+tGzegOrhBOtgT13TVxZM6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=p8uDr4k/B7M10ZgLnJu9RXiehL+lC+7PazjkNrO4toM=; b=5UetMOGZE5ngNAjD/7t9WdSSHJgPRh+yic05rZcT74H45f5qrzFZ7Z8FIRKQODHqW1kSOrwsal9123ZWMNfoUjKNd4EmfLWKpMTs1epdjq9uxntF1aQed59iHoyGVeM8AQssSyfvl8wFskYup8futauDudM8jPVHDaT+JlKIc5I= Received: from DM6PR06CA0099.namprd06.prod.outlook.com (2603:10b6:5:336::32) by IA0PR12MB7697.namprd12.prod.outlook.com (2603:10b6:208:433::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Tue, 4 Nov 2025 14:55:58 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::55) by DM6PR06CA0099.outlook.office365.com (2603:10b6:5:336::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9275.16 via Frontend Transport; Tue, 4 Nov 2025 14:56:00 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:55:58 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:52 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:41 +0000 Subject: [PATCH v8 4/8] x86/mce/amd: Support SMCA Corrected Error Interrupt Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-4-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|IA0PR12MB7697:EE_ X-MS-Office365-Filtering-Correlation-Id: 914e873c-421a-45e9-725b-08de1bb243b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?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2Q2VHVTVXN0lQN1ExUUJu?= =?utf-8?B?VG5iSWU3eVpCRkhROE0wcnJOKzcwcXZvMGI1MnJsczJWNUZ6cWZKQWdzbVpV?= =?utf-8?B?ZytvUVFzU01rSGllSnl6U1dqdzBsSk8xdDJWSjRUdmR3QVpISk5kT25JazBi?= =?utf-8?B?Zm04bERUQk4rWW50RllJSXRZWW9BWUdPR3pFWm53WWpSeEdNYUd5RTJ0cThT?= =?utf-8?B?VllnL0hQakxrbmQycHpiMTh6cjNONU52L2tKNzZzb1FOQWlXVFkweDJGK0lW?= =?utf-8?B?WnpkdGFvQUduQjZ1MVBKWWM0T2Zobit6ZjhDMUE2RGJNKzIvdDlabUZsRkxT?= =?utf-8?Q?xRUg=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:55:58.6621 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 914e873c-421a-45e9-725b-08de1bb243b7 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7697 AMD systems optionally support MCA thresholding which provides the ability for hardware to send an interrupt when a set error threshold is reached. This feature counts errors of all severities, but it is commonly used to report correctable errors with an interrupt rather than polling. Scalable MCA systems allow the Platform to take control of this feature. In this case, the OS will not see the feature configuration and control bits in the MCA_MISC* registers. The OS will not receive the MCA thresholding interrupt, and it will need to poll for correctable errors. A "corrected error interrupt" will be available on Scalable MCA systems. This will be used in the same configuration where the Platform controls MCA thresholding. However, the Platform will now be able to send the MCA thresholding interrupt to the OS. Check for, and enable, this feature during per-CPU SMCA init. Tested-by: Tony Luck Reviewed-by: Tony Luck Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-4-5c139a4062cb@am= d.com =20 v7->v8: * No change. =20 v6->v7: * No change. =20 v5->v6: * No change. =20 v4->v5: * No change. =20 v3->v4: * Add code comment describing bits. =20 v2->v3: * Add tags from Tony. =20 v1->v2: * Use new per-CPU struct. arch/x86/kernel/cpu/mce/amd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 117165c357b7..6d16b4589eef 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -308,6 +308,23 @@ static void smca_configure(unsigned int bank, unsigned= int cpu) high |=3D BIT(5); } =20 + /* + * SMCA Corrected Error Interrupt + * + * MCA_CONFIG[IntPresent] is bit 10, and tells us if the bank can + * send an MCA Thresholding interrupt without the OS initializing + * this feature. This can be used if the threshold limit is managed + * by the platform. + * + * MCA_CONFIG[IntEn] is bit 40 (8 in the high portion of the MSR). + * The OS should set this to inform the platform that the OS is ready + * to handle the MCA Thresholding interrupt. + */ + if ((low & BIT(10)) && data->thr_intr_en) { + __set_bit(bank, data->thr_intr_banks); + high |=3D BIT(8); + } + this_cpu_ptr(mce_banks_array)[bank].lsb_in_status =3D !!(low & BIT(8)); =20 wrmsr(smca_config, low, high); --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010056.outbound.protection.outlook.com [52.101.193.56]) (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 929E932ED5B; Tue, 4 Nov 2025 14:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268165; cv=fail; b=uv+1FzSYBmWJJXt7DFQtnrKdHTK6Q8vgFPQGv8cEQdUmzIex/K0QOF4w2sa2Su4D3rUPxw6P0nD7/r+jOAJLD65EoJrUKMY9VKC1/cQtzOC9bmrGn5M84jbd5Ios1Zm/BDzsaqlOLk6x3r0zwWz3c/VqZ7JEQg5t+AX8OyjHv5s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268165; c=relaxed/simple; bh=qE9DgStV68W4/+JSiD/FTV2amZjIO0rqbXzrAMtIlf4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=XhSk3X2kRO2KT4cZoi3jS8Iu2/lXO8ln/Ul8/kCVlIm/0dpUu5H64eNn2hB6kDtw/xMbkxCXXA40pmVPzmcc9R8lvtbREAyogD2+DFDvCFTrCd7sZpnJNM3BDgMLWOG1fnUrVxMAq+8stdo3JNCZ7RQ3caHMYGoDoy1zONw9KUM= 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=xLfN+mtD; arc=fail smtp.client-ip=52.101.193.56 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="xLfN+mtD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yd387iBKzVzdiZvuBjgbxvyLSFSgU5w5gFyDFwpYJK+E84S4IxCGVf0mVhl2IgpAOqGyEPlSkqGiwG3zGGeh5M53hwHvL0mP7BhDIEC3fUMgFCjCQiLW10mapjuR5iLMxobBXzVGWzCPdBbwa7K7zn05IgkZHANAY1UluE7lMsiW7DSVL5t8PE84KdtNj3pZFwMihYISk0bSzx4CRkhhPQOVvprS6X1dEAXIyObmhZwiTYu0YdUqPyQHXJgCqZW8yh8dVhln4t9emkZEOle17Nh0I1gw5KbqkwH1tDrvk0oEfrLbPlUQRgCBgcgido9ZwtY38+G6IbDTovsV5reI4w== 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=CxN1d0LC0vfsfMLp9fixBT59rHWy6m4AyVF5VyM5szs=; b=C+AVaYarsuIR24nYvyK/X487enma3NvMoaGYVKFpxIo4K/cJt9u4/3dG8cHZ3z8pCb7zG1F3i9Ze7yhpxSc8/8MVQmw7+lDYOXWS5zUNwEdPcecbExGzB4qZ8uvpUxWVJhE8GqibpEVNBnjspf4Q/T7l0kDE43unzEYdqgOcA+6c/mscq95XeVQePov3X+V1mQ9jKiRB7GhyVZoqBD0zlvlbbMae3DV7OhYfu9AK5dZpsLmSZxQQpj0kF02TNYlHwzei71ZPMU+/O4hBmkoLe3xOHRGUWnR/SXbxE/emUjwv+rXVDTjqcpuLjSnr+9KTvCQyvXqSfjuZBf9I1IziuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=CxN1d0LC0vfsfMLp9fixBT59rHWy6m4AyVF5VyM5szs=; b=xLfN+mtDZWuNyireYzATs07Ki2G9d/bfgifgGzUAtbYAhEajpyFcZFTVcb92QynB/S09IZzWt6TQOYdF+yvCTH1c/DcsShdPB+1Xr9megPZKXcsVQOFed9ys6VlD7XRB1XbkrGlBiCauJy2KROueXh0Qnabxvj8w5iy0aidqJ0o= Received: from DM6PR06CA0095.namprd06.prod.outlook.com (2603:10b6:5:336::28) by CH3PR12MB8236.namprd12.prod.outlook.com (2603:10b6:610:121::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.7; Tue, 4 Nov 2025 14:55:59 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::c9) by DM6PR06CA0095.outlook.office365.com (2603:10b6:5:336::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9298.7 via Frontend Transport; Tue, 4 Nov 2025 14:55:57 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:55:59 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:53 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:42 +0000 Subject: [PATCH v8 5/8] x86/mce/amd: Remove redundant reset_block() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-5-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|CH3PR12MB8236:EE_ X-MS-Office365-Filtering-Correlation-Id: 60e94b27-e8b2-4d42-0abf-08de1bb2441a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VjluaGFMaVVNTnJWZ0lZSWdPVEZBYUlXd0lJU2lQQUVZdm1RZnU1czg5RkUy?= =?utf-8?B?QW5hL1F2R3J0K2JWNjYzT2RCN1IyNGk0ZlZEUUhhZi9VRGNScVBrQ0pqVnhs?= =?utf-8?B?bnRTME1TRFVXN1Q4bzlQSW81MVU2QkpaQjJrL0Y0c2tnSlhSalF1S2VEZ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TTF6VkgybURKRXhGTXZ1eU9yRGxvREtHbTBTWjN4?= =?utf-8?B?VDVQZzlxYThzMlRER3JHb3NNOE5kaDl6eHBlbHJxWWQvQzc0T0Nva0lwdFQv?= =?utf-8?B?UkhWYjFObFl4Y01DRSsyclRmL0UyaURRWXhNSWJRcDNiWE51dTVVTnNTRzc3?= =?utf-8?Q?S/4M=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:55:59.3068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60e94b27-e8b2-4d42-0abf-08de1bb2441a 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8236 Many of the checks in reset_block() are done again in the block reset function. So drop the redundant checks. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-5-5c139a4062cb@am= d.com =20 v7->v8: * No change. =20 v6->v7: * No change. =20 v5->v6: * No change. =20 v4->v5: * No change. =20 v3->v4: * New in v4. arch/x86/kernel/cpu/mce/amd.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 6d16b4589eef..af2221bcba96 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -812,29 +812,11 @@ static void amd_deferred_error_interrupt(void) machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->dfr_intr_= banks); } =20 -static void reset_block(struct threshold_block *block) -{ - struct thresh_restart tr; - u32 low =3D 0, high =3D 0; - - if (!block) - return; - - if (rdmsr_safe(block->address, &low, &high)) - return; - - if (!(high & MASK_OVERFLOW_HI)) - return; - - memset(&tr, 0, sizeof(tr)); - tr.b =3D block; - threshold_restart_block(&tr); -} - static void amd_reset_thr_limit(unsigned int bank) { struct threshold_bank **bp =3D this_cpu_read(threshold_banks); struct threshold_block *block, *tmp; + struct thresh_restart tr; =20 /* * Validate that the threshold bank has been initialized already. The @@ -844,8 +826,12 @@ static void amd_reset_thr_limit(unsigned int bank) if (!bp || !bp[bank]) return; =20 - list_for_each_entry_safe(block, tmp, &bp[bank]->miscj, miscj) - reset_block(block); + memset(&tr, 0, sizeof(tr)); + + list_for_each_entry_safe(block, tmp, &bp[bank]->miscj, miscj) { + tr.b =3D block; + threshold_restart_block(&tr); + } } =20 /* --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011025.outbound.protection.outlook.com [40.93.194.25]) (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 6A01E3314C4; Tue, 4 Nov 2025 14:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.25 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268166; cv=fail; b=kcA3NYa5c1eXouwQfBWCBqL3LThu+W4neXPgXEmKYxFKHWiN66pLN1Q3uZF8QyUBx9BKMFDMYjYDCVj+420SQD3xb7dpwxifBWagWqeErH2BfGwtGouJ/oFPF0cyf8ca7gYDczeogKyNvg6K0J8WAf3QfLU1AA1nTJkBdhCMJlM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268166; c=relaxed/simple; bh=Xw4VNqTifHdCF0yWzwXjUtwdLt0AILxM0atG9EPi1t4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=BBSNheWMxetat4s9LvRTj1Yo7ek6d8YdVHJ6rByFTfL2Ia8UtoFx9WFPZd2bGclMY7q/AXAIwLjVaCA4+FPgIrgVL3enirtY2W9KxlmqwtgwuhH+f2u5gD3Cne1t+7eVxWIndTdx+sOW+7g7YsgxJC0Op+M2g9kSmLerC7TZfcs= 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=feQnPfjP; arc=fail smtp.client-ip=40.93.194.25 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="feQnPfjP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i6xkdr6H6BhWXzDMLIh7BojxOF6zTK3R5WTi7tXCf4Twtsa6nGrsbPmb7EOlhc2a8PjEhkL4yqLsryKtJbajf56l5YehfQWSWgnY2ExHhTpg1x4XmH0je6UzzW3ZqcjdVdhyL6T9BNlCsX6W7xF6ZijL8AOApaqBs95MVLg8j7rhuAP/IPufRpJWO96M0FGz6EYB78okaSkWY+9LCeclBz4Axf7t428Dpl7iTDzgxb2RQ2SEtAUgYX9i5AG2IGGQE2S4nDoZZsbgD4ct1r22d8nWc+XbPNSF5wufe1I3v22gEspMoHMg5v7MO6VPCrtUBdKqljAL/sdq3tIVZsp4Jw== 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=8ncxfpE72B+L8aJxSlHjDOPr5ZPB8T1rIcnio/u2mOI=; b=L8cFqvmFALUlQPefOIVg6CO60I9vfODEyjEr4bUwS3u18VLoPHil57ugnfZrPzVWEmia0uD6iALsBSnuI3WjLZ9V8wpfQDzuZjeo21TqGwz+AjJWJMwHy4m9Mf4f1z64oNH92m89WYWSV/IhUoTyWQY1zIkh1ufMvuesjIw+W46A1DnMY7ogcI9DOlC7LOKrfCKVLDp/g8BAP3ZHRvtG1CpZULe1ZPSVCfUUzeN3y9iGG9YHeFkVRJZzYtCdb5NUFlI8DIxhD+7d/wPIlZB7JBJPGx8YcxScH6/wd+ecgUuYMehQ39hS0JX1Wt7of9MZxkk5xRGnj3V7PiQrB4pelA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=8ncxfpE72B+L8aJxSlHjDOPr5ZPB8T1rIcnio/u2mOI=; b=feQnPfjPkC9KKbeWQYnkXBuC2BI7pcW1foE2ouUvhaoheUpQoFnUpYuM9Q/RfCpZp+fRH+dbf1/UAxPz1TchVwL+jdwfebEZ9cpXR65jU00bKg865McIpucwATg02AlYMlO3WgxzazQyhgRbwgxRuOehxUwal/oI1g/hw3euEx8= Received: from DM6PR06CA0081.namprd06.prod.outlook.com (2603:10b6:5:336::14) by SJ2PR12MB8110.namprd12.prod.outlook.com (2603:10b6:a03:4fc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Tue, 4 Nov 2025 14:56:00 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::db) by DM6PR06CA0081.outlook.office365.com (2603:10b6:5:336::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9298.7 via Frontend Transport; Tue, 4 Nov 2025 14:55:58 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:55:59 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:54 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:43 +0000 Subject: [PATCH v8 6/8] x86/mce/amd: Define threshold restart function for banks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-6-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|SJ2PR12MB8110:EE_ X-MS-Office365-Filtering-Correlation-Id: 28d31c22-b0a2-4380-ebf0-08de1bb2445b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Zzc2c3gwSTRTeGg3bHNYOVlYZUZ4enN1TVF6WFRRZDJnTmRnaWpMaHFVUHQ4?= =?utf-8?B?RDg0MkNoSmZteGN4Sk0vWVAzak9xdXIyQ0traFpJSVpDbmRhUWtKMjA4SDcx?= =?utf-8?B?eWl6K1VNVHhVaktITk5jakN4RXZtbE4wN1ExT3dCVmROdzVsSzlJVDdHSzd3?= =?utf-8?B?Zk1QN01HWkFmWnpkbnhFcjk5YzRiaW9YbmdPYWtjblQ2dFRjU3pxVFc2YXFv?= =?utf-8?B?Yk5jbEhRMzBVSkZscTRCSDFnZXNMbDRteGpGbzhuVzM3UllZQm5sQmlYMFha?= =?utf-8?B?ZVA2bU1tRzhpMjBTN2xzTy9DRFdCOGZhK1lSRm8wUHFLRTVUODhwd1RHYzkx?= =?utf-8?B?SnhCTDF0UlhoOUgzd1E2TVRkdkV5TmMzOGp5cGgwbE9hYzRWYURwZjFoQnhU?= =?utf-8?B?aGNWdTVsMkhFemtRT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)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:55:59.7402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28d31c22-b0a2-4380-ebf0-08de1bb2445b 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8110 Prepare for CMCI storm support by moving the common bank/block iterator code to a helper function. Include a parameter to switch the interrupt enable. This will be used by the CMCI storm handling function. Reviewed-by: Nikolay Borisov Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-6-5c139a4062cb@am= d.com =20 v7->v8: * No change. =20 v6->v7: * Add tag from Nikolay. =20 v5->v6: * No change. =20 v4->v5: * No change. =20 v3->v4: * New in v4. arch/x86/kernel/cpu/mce/amd.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index af2221bcba96..940d1a033569 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -471,6 +471,24 @@ static void threshold_restart_block(void *_tr) wrmsr(tr->b->address, lo, hi); } =20 +static void threshold_restart_bank(unsigned int bank, bool intr_en) +{ + struct threshold_bank **thr_banks =3D this_cpu_read(threshold_banks); + struct threshold_block *block, *tmp; + struct thresh_restart tr; + + if (!thr_banks || !thr_banks[bank]) + return; + + memset(&tr, 0, sizeof(tr)); + + list_for_each_entry_safe(block, tmp, &thr_banks[bank]->miscj, miscj) { + tr.b =3D block; + tr.b->interrupt_enable =3D intr_en; + threshold_restart_block(&tr); + } +} + static void mce_threshold_block_init(struct threshold_block *b, int offset) { struct thresh_restart tr =3D { @@ -814,24 +832,7 @@ static void amd_deferred_error_interrupt(void) =20 static void amd_reset_thr_limit(unsigned int bank) { - struct threshold_bank **bp =3D this_cpu_read(threshold_banks); - struct threshold_block *block, *tmp; - struct thresh_restart tr; - - /* - * Validate that the threshold bank has been initialized already. The - * handler is installed at boot time, but on a hotplug event the - * interrupt might fire before the data has been initialized. - */ - if (!bp || !bp[bank]) - return; - - memset(&tr, 0, sizeof(tr)); - - list_for_each_entry_safe(block, tmp, &bp[bank]->miscj, miscj) { - tr.b =3D block; - threshold_restart_block(&tr); - } + threshold_restart_bank(bank, true); } =20 /* --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011034.outbound.protection.outlook.com [52.101.52.34]) (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 407F6331A49; Tue, 4 Nov 2025 14:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268169; cv=fail; b=NBLsmTD0ZVRT8gO0sPs9oN9jcd/pzi1Yk00wqc1eAW7vKzpGOUqgt1daUtaaG91FAXSkfh7i9MEvQ/X65brlPqIhE6Vs+ef2wv6XX5Q1z/gy9rSTCImAlLQvqqfJiz6MMY92IzGKb5pbqC/zlw8ZAxFJaz5aDqmDvgDmlZKUkHw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268169; c=relaxed/simple; bh=KC179zWMp7Y1zf2XVqVHCis2TJcJ955LHL04kJ5SIv4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fvw/lUZ6BSO/xEOB59P1MJ4MdBl+QLu9MIJWjU2lIoy1kbeobL3Q5FtEiVkiyKBDXhlM9R2vAS1KSv98SRho2HyzNMc91D17fXtcgmqZfnnCIYCzD2SjHlaPhFT+s5ViWMMLfffu0BBEvl+I2ZsQfT9N6/HPNzdAaQe/gMsi57Y= 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=Me8HQGs0; arc=fail smtp.client-ip=52.101.52.34 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="Me8HQGs0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aoS2L+ttousdNl8W7HigPPxMqerR53O+Af73TL88sW1RyuJrk64hSgQlQWBCc4yZi+98V2CDuPW1fS/hRmm1cCKWlhliSHFWr1LGfjApQRVaC7OlfvItZw14CI64gEForOPMvK8P5CiIy4boIntazhYCU4rCDHk6Wn6wNDdRBJn/5ypVJPgl9PB2NSnuddtzIsxW6xMx8K1ykvY/BPdU0pqs2YMjRNOjgiVZwjXYc8sOlfVpaBmYpAANN1JsOVsVUpEdyhULdrJOW4t4OJUS2uRF2tycTdNb9504ZaScrWLib0MKdu5ml7YsoiPKbeqwF2G7su5MPemhb6/myUsOdQ== 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=ETWkDEu1tftNq40qbldxcqb8L5DxqTCYSBTj6budbBU=; b=tlOSFhgQyJcBGUMJqwud2MHESZx42FIJlBCd/kTI9g+BweAC3dimL5JhRk8kfg0q/nE8wRXvoPQh5u+KhMeVV7wc+6IKrSSL9FoLBnImMdkVMAQeIpFJ5ultQtCRcWzva1KdZp2KyP9Lq35Xtca3R5nxjc88y7DAMP/mPTtjEt1issbt7+Ns6+NIpqaEs8kSvdyH35s3t1UqU5Rl7qMo/SzjVG1NKi0dVtLmL6/VoUG32jZSKAMSgW/VQxS3EUQ1Fwbzz9QOmmfm2H787htm+W8LvDYT4A+66lJOuJvKH+qJORI6ItgxHm4graLw9E5xU8DZZr+p/1rE9Nv3+zAq6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=ETWkDEu1tftNq40qbldxcqb8L5DxqTCYSBTj6budbBU=; b=Me8HQGs0LdClQqsSYE8pYL3NrT8hbhEgGDpIYCBikpbiARD08REhW5Qbdl6OBOBeF3J0QpGpA3S325u/WoRxJRTf1sSp6Zf5bNxSIsZaDiTYVhn75QDQBJMuDg0T+yNcGyV9BMxJk3wdX1Z3uu7Fs1XsbK+UQDelYeNFN/IR85k= Received: from DM6PR06CA0101.namprd06.prod.outlook.com (2603:10b6:5:336::34) by PH8PR12MB7446.namprd12.prod.outlook.com (2603:10b6:510:216::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Tue, 4 Nov 2025 14:56:01 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::2f) by DM6PR06CA0101.outlook.office365.com (2603:10b6:5:336::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9275.16 via Frontend Transport; Tue, 4 Nov 2025 14:55:24 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:56:00 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:54 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:44 +0000 Subject: [PATCH v8 7/8] x86/mce: Handle AMD threshold interrupt storms Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-7-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|PH8PR12MB7446:EE_ X-MS-Office365-Filtering-Correlation-Id: e69cf17c-e83d-4f59-1a7d-08de1bb244da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?TVZFRHdJUTJlbWJySW81alFzSDlBeFdETElpVGZOcTJ2aUtmRElLamdoMGx5?= =?utf-8?B?a0VMazRQeUV0dnUxYy9sWkZybngrUUdseEZxMWpuODJHYmUxZ2RBMm5tZVR2?= =?utf-8?B?S3ZYQ3RwTngyY0RYZy9IbzkycERzMU9FbmRGeDRXbk5HaTk1MmY0QTFjWTBm?= =?utf-8?B?cVhjNmUzZW9Tci8yYVZxcmxWc2phZmc0WVFLZEpoc0c3Qk5iVkhOMWFCV2ZY?= =?utf-8?B?S1FxMnNCMmRHRUxtdFllOEFoeVhQV2hlWkE4L3FmT2tBK3VadXFoK1pVeVdQ?= =?utf-8?B?MWRrSERkQ2FndXp3U0JHVTNtRXVuUGlpakZ6UHBMRGdGY0l5OExBV2hwRnBM?= =?utf-8?B?VklydmhCcGk2ck1UZG1ZaEJ3d25yaG5mUjNmZ2hxTkZnQzYyQ1NMd0xEQ09w?= =?utf-8?B?QXh2aXh1eE1BWTBKY0JaaDI3SDdjQ3Rjd1dnVGdEbUlVYlhNeDVrMUh2TTlO?= =?utf-8?B?SVZ4UzB4dVR0WUxEdEhQUjMxd2w1QXdHS0ZhWm5WbmhiUFhhVnN5dkNFWUw2?= =?utf-8?B?K2o0Sm9xYXBGMFRyS1BROXRtL245SGd5L1FldUIyOWc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SHB4MzA3ck92WHVEbmZzTGNYUVNlbG9L?= =?utf-8?B?am1vU1ptR2hWMDkxTzNUSmZlOENHeVpwN3FzT2ZLTllnaWZucVBnYzdTaXgy?= =?utf-8?B?YUJpaWdDNlFXRU1reWhHYlp2TWR3OXAyMHZrUk9zMVA1OVpnT0Z2cEVYeVlT?= =?utf-8?B?RUhMK2JYR1ZxVXAwTnRtYWlKcnFmQmIrZHpZTW5aZlZlMitlMlVwQm1yQ2l0?= =?utf-8?B?Qkg1SWtSaEE0ZUNad2tEV0JaTlV5aGp0MlQ4aklYcnVCL2NkUXpjbnlhZDNX?= =?utf-8?B?eWsrdGY2MUhXVlRhRkxXU3BHRmNvME5JMXFhakZBTG5Weml1cWlmc3d0alc1?= =?utf-8?B?Uzh6NmhaTE1xOUFHUDhPOFZRRFpHZGJTRGxvc0I0VTU3dFdvQVNZY2xkbmdO?= =?utf-8?B?cm4za2lKTVRpelc5YnRFN0tuZVIrUGM5Uk1ybGNpRWVtUVZwZ0s2QVdUYmI4?= =?utf-8?B?WFBzZ0ZFbVpPSmMvRnFYaDlHQTlnL21LZlBwTlNxMWJOV2RkYitPMUtzM2gw?= =?utf-8?B?dC9OVWpKT0RtdXl6V201MHlKR09nbTc4T3pMd0ZkWU0vMkIyNmliYXhLU0JX?= =?utf-8?B?UUtWeDNpcEh3SW1sV3lYWVM1RFBUSVBNRlJpanlha0M2M0hsKzhEL2I2ejhP?= =?utf-8?Q?dEP8=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:56:00.5676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e69cf17c-e83d-4f59-1a7d-08de1bb244da 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7446 From: Smita Koralahalli Extend the logic of handling CMCI storms to AMD threshold interrupts. Rely on the similar approach as of Intel's CMCI to mitigate storms per CPU and per bank. But, unlike CMCI, do not set thresholds and reduce interrupt rate on a storm. Rather, disable the interrupt on the corresponding CPU and bank. Re-enable back the interrupts if enough consecutive polls of the bank show no corrected errors (30, as programmed by Intel). Turning off the threshold interrupts would be a better solution on AMD systems as other error severities will still be handled even if the threshold interrupts are disabled. Also, AMD systems currently allow banks to be managed by both polling and interrupts. So don't modify the polling banks set after a storm ends. [Tony: Small tweak because mce_handle_storm() isn't a pointer now] [Yazen: Rebase and simplify] Reviewed-by: Qiuxu Zhuo Signed-off-by: Smita Koralahalli Signed-off-by: Tony Luck Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-7-5c139a4062cb@am= d.com =20 v7->v8: * No change. =20 v6->v7: * Don't modify polling banks. =20 v5->v6: * No change. =20 v4->v5: * No change. =20 v3->v4: * Simplify based on new patches in this set. =20 v2->v3: * Add tag from Qiuxu. =20 v1->v2: * New in v2, but based on older patch. * Rebased on current set and simplified. * Kept old tags. arch/x86/kernel/cpu/mce/amd.c | 5 +++++ arch/x86/kernel/cpu/mce/internal.h | 2 ++ arch/x86/kernel/cpu/mce/threshold.c | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 940d1a033569..ec5417586b8b 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -830,6 +830,11 @@ static void amd_deferred_error_interrupt(void) machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->dfr_intr_= banks); } =20 +void mce_amd_handle_storm(unsigned int bank, bool on) +{ + threshold_restart_bank(bank, on); +} + static void amd_reset_thr_limit(unsigned int bank) { threshold_restart_bank(bank, true); diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/i= nternal.h index b0e00ec5cc8c..9920ee5fb34c 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -267,6 +267,7 @@ void mce_prep_record_per_cpu(unsigned int cpu, struct m= ce *m); #ifdef CONFIG_X86_MCE_AMD void mce_threshold_create_device(unsigned int cpu); void mce_threshold_remove_device(unsigned int cpu); +void mce_amd_handle_storm(unsigned int bank, bool on); extern bool amd_filter_mce(struct mce *m); bool amd_mce_usable_address(struct mce *m); void amd_clear_bank(struct mce *m); @@ -299,6 +300,7 @@ void smca_bsp_init(void); #else static inline void mce_threshold_create_device(unsigned int cpu) { } static inline void mce_threshold_remove_device(unsigned int cpu) { } +static inline void mce_amd_handle_storm(unsigned int bank, bool on) { } static inline bool amd_filter_mce(struct mce *m) { return false; } static inline bool amd_mce_usable_address(struct mce *m) { return false; } static inline void amd_clear_bank(struct mce *m) { } diff --git a/arch/x86/kernel/cpu/mce/threshold.c b/arch/x86/kernel/cpu/mce/= threshold.c index f4a007616468..22930a8fcf9e 100644 --- a/arch/x86/kernel/cpu/mce/threshold.c +++ b/arch/x86/kernel/cpu/mce/threshold.c @@ -63,6 +63,9 @@ static void mce_handle_storm(unsigned int bank, bool on) case X86_VENDOR_INTEL: mce_intel_handle_storm(bank, on); break; + case X86_VENDOR_AMD: + mce_amd_handle_storm(bank, on); + break; } } =20 @@ -85,7 +88,8 @@ void cmci_storm_end(unsigned int bank) { struct mca_storm_desc *storm =3D this_cpu_ptr(&storm_desc); =20 - __clear_bit(bank, this_cpu_ptr(mce_poll_banks)); + if (!mce_flags.amd_threshold) + __clear_bit(bank, this_cpu_ptr(mce_poll_banks)); storm->banks[bank].history =3D 0; storm->banks[bank].in_storm_mode =3D false; =20 --=20 2.51.2 From nobody Tue Dec 16 13:35:04 2025 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010047.outbound.protection.outlook.com [52.101.56.47]) (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 952A93321D2; Tue, 4 Nov 2025 14:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268169; cv=fail; b=nYRhDle8aRDF2XTezpCAJwjQcSA43jDBxrRGkx4PhATulf50gUzSHSBeFhxJHU03DDMC6V11t7YtSOFXwgo4digb9HWdH9XpdDXi1yO1OyTTebMMhw+phIn5t43tF792ZAPi2zPWnCK88xu1kZ6+bQBFaGizCeRtWfG4E6/1AfA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762268169; c=relaxed/simple; bh=Fa2sov21IiuO257jrVAGTFrhKIZsBFv0RXrVzKbDDwQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=NdofGZKvh5dehqgQqamYSUizZmFWHbhPBjU3KUHc7BbImSVzb+ooarYE5SchOQhf+HuVAkDAyxYMrA3m8S2wecBq+AQZtGeunoV2Lh/6vvwLiIH4sfv9BgeNzTV2OE6xpOZ/SQvUdgGo1Ivk5EsddiPgDLhM2p/KNJHTEUI7kJg= 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=ABi67jMW; arc=fail smtp.client-ip=52.101.56.47 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="ABi67jMW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EJzBdg8TmnVSAwPitAeSog/aKlyWIP/uobde8at74hctUsec305zQ3/9HTutO6fWVrd9LfKbSbM4KwcTcts1ZW1KXYEZ+XPynOVzLqIuZq6VAH/QU0coo3lXm3SZ7vN7UPPLRIICMF0ZIbjFAN2Y+ivwo00xbFp2oHruKqDdRrWwWBeq9SwpG/NnAQ3ld7oQ3F1LteYNO3PTbjCKwCcacg81U+a4k5nknZxNZs00VARye0WWQNgAlY/SL6BInxhKpoBWW9Ql7JXQXN8tRXxZNseVv5ygJeOWjLWpBzpVqOGNWx5mFoacSm9mukl1J8DMEYykU/y+IgF1LBbq8JhDpg== 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=mUjOw3pc7h+hw75dOg/Bg/0mysNfbA8ZeZu4ow1sRkA=; b=mc+Gzd0eSDWJ44l27meTfAKJ+ThoVUwDrY0ne5S5Imhpb01vht45XtTlSqzq+zUMrnkwzUsWZXwkR98h0pJwL+ZKl1seV2X94K7K1SnoOWrhsorxSfMJM0Z73RKg1x1hqRnD3lfAGJn0i61oS0+xVVDzx9W8fUDRYQbYCxO/Nm7MI+8/n7/KnE+HIAAV+YwRyh8EkeE8LC+vXuoCGYJkIIK+5KJq4q07qJ2CAnExN64hG0IZB9Em4aXLIKGFid+uflWnExr/qn6kmvju+C0COAVLD0lN9gY/UGlTYakML+Iap30XYN8JJxHe3lZGrkb4HSvgIo0oLHb/aOtwGushNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=mUjOw3pc7h+hw75dOg/Bg/0mysNfbA8ZeZu4ow1sRkA=; b=ABi67jMWtgxU4poaLEQJd85AzdUs/Xc4LuDhkD7AX24Ap3mCylN7Qb2HqZAKte5yvA0rfgMNU1Je2AIUAFwsBMhzemyHWgm86+KBiT3cKsRpIlmi4HY0RqMCyiFhvOpttl3C1OgQ83RQV4waa8y3xTJxOazCQ3JNZ0IS1dH7LEQ= Received: from DM6PR06CA0088.namprd06.prod.outlook.com (2603:10b6:5:336::21) by SJ2PR12MB8738.namprd12.prod.outlook.com (2603:10b6:a03:548::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Tue, 4 Nov 2025 14:56:03 +0000 Received: from DS2PEPF0000343A.namprd02.prod.outlook.com (2603:10b6:5:336:cafe::b1) by DM6PR06CA0088.outlook.office365.com (2603:10b6:5:336::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9298.7 via Frontend Transport; Tue, 4 Nov 2025 14:56:01 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DS2PEPF0000343A.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.6 via Frontend Transport; Tue, 4 Nov 2025 14:56:01 +0000 Received: from [127.0.1.1] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 4 Nov 2025 06:55:55 -0800 From: Yazen Ghannam Date: Tue, 4 Nov 2025 14:55:45 +0000 Subject: [PATCH v8 8/8] x86/mce: Save and use APEI corrected threshold limit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20251104-wip-mca-updates-v8-8-66c8eacf67b9@amd.com> References: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> In-Reply-To: <20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com> To: , Tony Luck , "Rafael J. Wysocki" , Len Brown CC: , , , Qiuxu Zhuo , Nikolay Borisov , Bert Karwatzki , , Yazen Ghannam X-Mailer: b4 0.15-dev-9b767 X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343A:EE_|SJ2PR12MB8738:EE_ X-MS-Office365-Filtering-Correlation-Id: 7af1eef4-99e5-4976-ea31-08de1bb24585 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?K2JsbkZDaWJzaXlSeVUrSWFtMlI5NEFrRTZzd0xDbkZHcERGT0g3a2NRZVgw?= =?utf-8?B?NUxXL2dxZDRkSHFuNkFsTWQrQ1Z6UGhxSEVkelhZTUdTcnRRQ0lXQU5ydndC?= =?utf-8?B?aVhUcjN4YlQyZHhpVFVNRkh1UFJIUXNXT1NSNmI3cHFkVjFBRGo3bW1JZ2Fa?= =?utf-8?B?aW05WEovZVpmbit4U0tsYStzVys2bnZQb2Z1T2d6dlI5dE04U1hYTktOeTF0?= =?utf-8?B?NVFqOXh6amljSXYrQ29jZWhGTFg3c005SXFKaDhSL05OYk92QURxeFhiZDE3?= =?utf-8?B?ci9XTWszNTBmMklseWl4MUc4TUkvaHM5NHlGeHJ0QTNGNjBDMW1GOVRlVDRx?= =?utf-8?B?VEN0MmJmUmQ1cnBWamJkNUVFdVg5SFYxT25uZ0dsdHRDNkt5L0ppTWgwUHlE?= =?utf-8?B?ZERRVGNlSmVSbllQdG5GbFY0N3NBRmFSazc5Nm1EK214NmN3dVhPTStOb2tQ?= =?utf-8?B?OUV5cFlJSFUwaE80Z0gralBZYjRlRnpZTEw4KzI3amtxSXZvNlVFYWFKUkJ6?= =?utf-8?B?cDVrTkw1TFdoMlJ6RVVEdGpSTUx3bUFBSUdocmE4TS9uL3BobG82VGw4NkR5?= =?utf-8?B?QWpLZGx2WS9td1g2NUdTVGV3WlVjTVhqaGgzRTlMVC8vWDkxRkM3N2RqcjBz?= =?utf-8?B?NUMvVENETjVERUhqanpDMnNVOWZmeE4vYkw4TFBNekZZSWd4K2luN01TeVBp?= =?utf-8?B?RjB4cUtBRnFkNjlKYzRNSWRkNGN5a1ByQ0xBODljb09HRjM1MWtoU28xTC8v?= =?utf-8?B?WldUSFRtY3dhVGhXc1ZkSHFXOXNveERSdVY1a2tzYjVEdDFCU2dRSDV6RWIz?= =?utf-8?B?c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UThHdllF?= =?utf-8?B?bDBWT29CZFMzd3ZMcE9TdXJIc0lEQUE5TjQvVGczc0kvZmUvZFZLWWVqeWEz?= =?utf-8?B?WWpBdk80M29DdktIakE3R3FkeW05Szd5bm5DQldpWmRYaWhMNXJjVmFhbmQx?= =?utf-8?B?NW11emlUWC81ajVId1c3cFBhNTdORG1BdWZlZlowNnlHYkQ4cy9OQm9NUG5D?= =?utf-8?B?UmFwTEM2REhRL3hzTnp4Zi9kbHNJeE1ka3RKczN2MnV0U29VWkRwN3pwVDBX?= =?utf-8?B?QkMraGRLSlE5SmNWZDhuZE41Y09adWIvVEgwM2FWcVQ2VVpvYkpoQjViSjJG?= =?utf-8?B?eGh6SHV4VEFkMDl0cUUvMnpQbG1pUG1ZdHBDaHBzdUJzT1NiUHhaSkRWS0Rv?= =?utf-8?Q?igdU=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2025 14:56:01.6930 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7af1eef4-99e5-4976-ea31-08de1bb24585 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8738 The MCA threshold limit generally is not something that needs to change during runtime. It is common for a system administrator to decide on a policy for their managed systems. If MCA thresholding is OS-managed, then the threshold limit must be set at every boot. However, many systems allow the user to set a value in their BIOS. And this is reported through an APEI HEST entry even if thresholding is not in FW-First mode. Use this value, if available, to set the OS-managed threshold limit. Users can still override it through sysfs if desired for testing or debug. APEI is parsed after MCE is initialized. So reset the thresholding blocks later to pick up the threshold limit. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20251016-wip-mca-updates-v7-8-5c139a4062cb@am= d.com =20 v7->v8: * Change pr_info() string. (Boris) =20 v6->v7: * No change. =20 v5->v6: * No change. =20 v4->v5: * No change. =20 v3->v4: * New in v4. arch/x86/include/asm/mce.h | 6 ++++++ arch/x86/kernel/acpi/apei.c | 2 ++ arch/x86/kernel/cpu/mce/amd.c | 18 ++++++++++++++++-- arch/x86/kernel/cpu/mce/internal.h | 2 ++ arch/x86/kernel/cpu/mce/threshold.c | 13 +++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 7d6588195d56..1cfbfff0be3f 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -308,6 +308,12 @@ DECLARE_PER_CPU(struct mce, injectm); /* Disable CMCI/polling for MCA bank claimed by firmware */ extern void mce_disable_bank(int bank); =20 +#ifdef CONFIG_X86_MCE_THRESHOLD +void mce_save_apei_thr_limit(u32 thr_limit); +#else +static inline void mce_save_apei_thr_limit(u32 thr_limit) { } +#endif /* CONFIG_X86_MCE_THRESHOLD */ + /* * Exception handler */ diff --git a/arch/x86/kernel/acpi/apei.c b/arch/x86/kernel/acpi/apei.c index 0916f00a992e..e21419e686eb 100644 --- a/arch/x86/kernel/acpi/apei.c +++ b/arch/x86/kernel/acpi/apei.c @@ -19,6 +19,8 @@ int arch_apei_enable_cmcff(struct acpi_hest_header *hest_= hdr, void *data) if (!cmc->enabled) return 0; =20 + mce_save_apei_thr_limit(cmc->notify.error_threshold_value); + /* * We expect HEST to provide a list of MC banks that report errors * in firmware first mode. Otherwise, return non-zero value to diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index ec5417586b8b..53385e6aa230 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -489,6 +489,18 @@ static void threshold_restart_bank(unsigned int bank, = bool intr_en) } } =20 +/* Try to use the threshold limit reported through APEI. */ +static u16 get_thr_limit(void) +{ + u32 thr_limit =3D mce_get_apei_thr_limit(); + + /* Fallback to old default if APEI limit is not available. */ + if (!thr_limit) + return THRESHOLD_MAX; + + return min(thr_limit, THRESHOLD_MAX); +} + static void mce_threshold_block_init(struct threshold_block *b, int offset) { struct thresh_restart tr =3D { @@ -497,7 +509,7 @@ static void mce_threshold_block_init(struct threshold_b= lock *b, int offset) .lvt_off =3D offset, }; =20 - b->threshold_limit =3D THRESHOLD_MAX; + b->threshold_limit =3D get_thr_limit(); threshold_restart_block(&tr); }; =20 @@ -1076,7 +1088,7 @@ static int allocate_threshold_blocks(unsigned int cpu= , struct threshold_bank *tb b->address =3D address; b->interrupt_enable =3D 0; b->interrupt_capable =3D lvt_interrupt_supported(bank, high); - b->threshold_limit =3D THRESHOLD_MAX; + b->threshold_limit =3D get_thr_limit(); =20 if (b->interrupt_capable) { default_attrs[2] =3D &interrupt_enable.attr; @@ -1087,6 +1099,8 @@ static int allocate_threshold_blocks(unsigned int cpu= , struct threshold_bank *tb =20 list_add(&b->miscj, &tb->miscj); =20 + mce_threshold_block_init(b, (high & MASK_LVTOFF_HI) >> 20); + err =3D kobject_init_and_add(&b->kobj, &threshold_ktype, tb->kobj, get_na= me(cpu, bank, b)); if (err) goto out_free; diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/i= nternal.h index 9920ee5fb34c..a31cf984619c 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -67,6 +67,7 @@ void mce_track_storm(struct mce *mce); void mce_inherit_storm(unsigned int bank); bool mce_get_storm_mode(void); void mce_set_storm_mode(bool storm); +u32 mce_get_apei_thr_limit(void); #else static inline void cmci_storm_begin(unsigned int bank) {} static inline void cmci_storm_end(unsigned int bank) {} @@ -74,6 +75,7 @@ static inline void mce_track_storm(struct mce *mce) {} static inline void mce_inherit_storm(unsigned int bank) {} static inline bool mce_get_storm_mode(void) { return false; } static inline void mce_set_storm_mode(bool storm) {} +static inline u32 mce_get_apei_thr_limit(void) { return 0; } #endif =20 /* diff --git a/arch/x86/kernel/cpu/mce/threshold.c b/arch/x86/kernel/cpu/mce/= threshold.c index 22930a8fcf9e..0d13c9ffcba0 100644 --- a/arch/x86/kernel/cpu/mce/threshold.c +++ b/arch/x86/kernel/cpu/mce/threshold.c @@ -13,6 +13,19 @@ =20 #include "internal.h" =20 +static u32 mce_apei_thr_limit; + +void mce_save_apei_thr_limit(u32 thr_limit) +{ + mce_apei_thr_limit =3D thr_limit; + pr_info("HEST corrected error threshold limit: %u\n", thr_limit); +} + +u32 mce_get_apei_thr_limit(void) +{ + return mce_apei_thr_limit; +} + static void default_threshold_interrupt(void) { pr_err("Unexpected threshold interrupt at vector %x\n", --=20 2.51.2