From patchwork Thu May 30 21:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13680854 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2081.outbound.protection.outlook.com [40.107.96.81]) (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 CCF761F947; Thu, 30 May 2024 21:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103811; cv=fail; b=d/6onFZXof1aKKprJXY66tDSjoBl78gbNsEZCAK3SoMW+Lbqae6BQdekM6Gaiyxta4hjy23lDa0j6EAiedtqLDuSjfJucuiIxShLYpLk0aPRopK1YenQRXCaCJwSDcg01YA17R0+0YY6FVX9Rvdzn7xOug9w6uqTQdn9J1mcY/A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103811; c=relaxed/simple; bh=ALjRfBgubzhtx0bSiDl+onL9pVySlknUpMMbgMplpGM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tYZFVTX7j+oGNE+qesO5GTjM/5VJhcuuqzsDbsoj//QHYJR3cg1jlaePYRMNMC24kZ8czjTTv1CfTOmjVmmc3V5UlfAxg2CjqFXwl95cbbqaPiTrhfNRT2fvDMajaz5EYg036y4SYH++2a5tn6nq/Sbe4TiHAvt6gcRPviAxWic= 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=yWID3+iA; arc=fail smtp.client-ip=40.107.96.81 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="yWID3+iA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VHZqzq9LHbe6/W5F7kDGztpINmO/RFkZkwx7cZ+1pVX8EISMonv+o52Baz1gvGbZuQeEzCU9t6W8X0NrU2HD7nhZZGSRMaNxzP+yMThSNUChxO2/7LFx97hbVIhCFH7zzCguINdHx/mkMmS3ukePhfEtLS6755Vu7KR6RJBQZVdGp+qCuCiJXtVbMzXrLtiiUBeAdHpFlpKemFaHruAItyIUAXc1ljyOiOzcHKd14iUbta9CxW0uKF5y3vUFmFrRj3XfWqciJucFmRIqgboeXSXiBCnCt6iIHDlA3zOVZeBBXQJ/dmwniZtbdGrVDBah4IBulV3wAPB4UPuxnip7lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ld7BPP7s0h8hMyWzsFLhhrotOPlnRwDvk8y3L2q6AzU=; b=Kp9VDWsMKp8gFWFn5ZfW53WjqPLr/QTWrd58WaznnivfN1Ca8xBLGcK2Vqppp96aB/hF4buecdx4AUkFs87U453VU5OFkau6/Ov5bEAavJPbwN4AY6Zb+KN5cOs9ELtyk6a5nj63s80qDmZeV6aa6PJ7xN7Y9noHp2QuPCnDrajX7JYZpzT+iwY7jzPV15v2VXslxx+n3/r1Q1uQTK14TY8q0+i0/Wni5hpBqEqBBxMbRX23m47c6MK+Wnm46YIFKG+SycwaXrSgvqymP5P9eyUVwfHmER/z07Yz5gEWEDE1kujqICeb3IbjPJyo2x9+Z8aAutEhJEsXCM70+khK4A== 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=ld7BPP7s0h8hMyWzsFLhhrotOPlnRwDvk8y3L2q6AzU=; b=yWID3+iA9Rc0ywg3lrNIH6bM21WZp1xj0Nk8Nvn+/yB4qDKb4YRL+7g9jppKcb5QJu2GHTINAY5heDFcPvX2mRfr5UFNRsiJ4geXd1PFQy7BkrjwU6n8AwbOb+KQOk7xriDcnjlUqT/vguSSD0Yd157L9fChRbNeiOvdvTSvEfI= Received: from PH7P220CA0114.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32d::8) by LV8PR12MB9229.namprd12.prod.outlook.com (2603:10b6:408:191::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Thu, 30 May 2024 21:16:44 +0000 Received: from CY4PEPF0000E9D8.namprd05.prod.outlook.com (2603:10b6:510:32d:cafe::e7) by PH7P220CA0114.outlook.office365.com (2603:10b6:510:32d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21 via Frontend Transport; Thu, 30 May 2024 21:16:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D8.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 21:16:43 +0000 Received: from titanite-d354host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 May 2024 16:16:41 -0500 From: Avadhut Naik To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH 1/4] x86/mce: Add wrapper for struct mce to export vendor specific info Date: Thu, 30 May 2024 16:16:17 -0500 Message-ID: <20240530211620.1829453-2-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530211620.1829453-1-avadhut.naik@amd.com> References: <20240530211620.1829453-1-avadhut.naik@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D8:EE_|LV8PR12MB9229:EE_ X-MS-Office365-Filtering-Correlation-Id: 62ff66f5-e043-456d-8451-08dc80edce0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: 3yujy1l0M+slM3cvP8ggTX25Y4DoenxBJtnQJhLdhfZRI0quRmdwiCNIggxstJz0z9UHFZmPvSUjR+zMwvw5w8UOb3/UpdlV9yd0wOyWiVABf+WnyPZFCpUJhYA4eR4fgCM0tVOBVzUxVqwbRBnmMRHtiEuqYCZNxzUmwFBAOQ2UCZWgI7KHVOt6r2zvHNcCK1FvqCMlpejKAwG3TMhqqd7llsWTRL4l8j6hB11Uu7RU6O4TWqBfEdYTCx+JKjbQDR4LH/IfJ64vFNURsIbQv0vBr5Po+oSGKvLH40ErAuXkKPh+uymnJLnZPY8Aq4Cb2W5TBkce/d7gInLWcB/VEXNYoQywhikcI0p85ErO78dRE36z1IISSMoh13zpt4LT2SeUQET/cqtV0V60j9RJGAzwjdfK8lHeSb30Bzq3FdcR2mQqToaX0bIv280+li5EVUvkGeUm6Gj93sCfd/0zV1xXZjKsi24vrDDHl9d15uKzQBCHYvo7XBxcrekdKG/KqO93gwNJvvK4h6uEcEpTB2tWOjhlVmvGyaWeTwAixmcM7av2/Tu0wJuEQ0XI1Smkv0Ce9JKsQ/LB1AhfUDN/I5xAu1JTIAkOPrk5CbWkb3svuEQ568C2u0OUOxETRh1bzKeGQdAAGMALn5bddtPson60oT3UN3L3VdhcDFTNgeO8kKb8+b+0wDR7gPGXBroS/4MoipaQSCF7B2zCB+l2bmV3LjBuoEQUArUuAEvlfyc1ko/Hki+LbFhqipnQkjxPY04/u6rf+pY7vZbbwMqU1j9M64IxGkrw6Hq61TYbR3j4Qm1t1nekBRzcaOn5LXNZGw/dYeqnK/WiqgPI62OJ1kXtfqNcc3TiLEedEek7uHZfPK/eG9cqlX1uG0qlUNbRbtKajVU+5V+xPmqBb3k0pZAwPbiCcN2UzYz/CwUejo4O6+dk/5ISYXP8wKuEAcMI3V03tkCSsRbTtW0TIE/GovzB6xFkwis3T3pdgCSUBJIVnHLDyolQl+osR/fEESrXxpRX4Y15kFE+toTxioPKXwq8TCtqvHZcK3+tN8q6qq4ddWeQ8yFMO1Vw8dK8mephvSL5LCxWNwgX2VbADBHKqSS//T315Ugl0xw6bwT+vpn9msmCYlGfVYmSsYpA+xYWkAecUmyePPHPAsUA7e2SL0BD6btTCVwnAnJ43BFN8QiPwtxRP055NjnL3rOvc84Xp0CiOQ6cGNG7VN8QxTrKHekEaTraysMs20iHMxnX2m6/snoiOrKe/rfNMVvkpOkU49LU4IUFLA9/nTm4SDvMqMto/miwYyGi8VgbPTyraqOoTGNEZOdUhNLiIIBKGo8+hW/qwjpvo8YXgZ9YZsc485hdvQMXr5oSEEFKZ43pEp0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(7416005)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 21:16:43.1230 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62ff66f5-e043-456d-8451-08dc80edce0a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9229 From: Avadhut Naik Currently, exporting new additional machine check error information involves adding new fields for the same at the end of the struct mce. This additional information can then be consumed through mcelog or tracepoint. However, as new MSRs are being added (and will be added in the future) by CPU vendors on their newer CPUs with additional machine check error information to be exported, the size of struct mce will balloon on some CPUs, unnecessarily, since those fields are vendor-specific. Moreover, different CPU vendors may export the additional information in varying sizes. The problem particularly intensifies since struct mce is exposed to userspace as part of UAPI. It's bloating through vendor-specific data should be avoided to limit the information being sent out to userspace. Add a new structure mce_hw_err to wrap the existing struct mce. The same will prevent its ballooning since vendor-specifc data, if any, can now be exported through a union within the wrapper structure and through __dynamic_array in mce_record tracepoint. Furthermore, new internal kernel fields can be added to the wrapper struct without impacting the user space API. Note: Some Checkpatch checks have been ignored to maintain coding style. [Yazen: Add last commit message paragraph. Rebase on other MCA updates.] Suggested-by: Borislav Petkov (AMD) Signed-off-by: Avadhut Naik Signed-off-by: Yazen Ghannam --- arch/x86/include/asm/mce.h | 6 +- arch/x86/kernel/cpu/mce/apei.c | 46 ++++--- arch/x86/kernel/cpu/mce/core.c | 168 +++++++++++++----------- arch/x86/kernel/cpu/mce/dev-mcelog.c | 2 +- arch/x86/kernel/cpu/mce/genpool.c | 20 +-- arch/x86/kernel/cpu/mce/inject.c | 4 +- arch/x86/kernel/cpu/mce/internal.h | 4 +- drivers/acpi/acpi_extlog.c | 2 +- drivers/acpi/nfit/mce.c | 2 +- drivers/edac/i7core_edac.c | 2 +- drivers/edac/igen6_edac.c | 2 +- drivers/edac/mce_amd.c | 2 +- drivers/edac/pnd2_edac.c | 2 +- drivers/edac/sb_edac.c | 2 +- drivers/edac/skx_common.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- drivers/ras/amd/fmpm.c | 2 +- drivers/ras/cec.c | 2 +- include/trace/events/mce.h | 42 +++--- 19 files changed, 173 insertions(+), 141 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 3b9970117a0f..83923d8a43b0 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -187,6 +187,10 @@ enum mce_notifier_prios { MCE_PRIO_HIGHEST = MCE_PRIO_CEC }; +struct mce_hw_err { + struct mce m; +}; + struct notifier_block; extern void mce_register_decode_chain(struct notifier_block *nb); extern void mce_unregister_decode_chain(struct notifier_block *nb); @@ -222,7 +226,7 @@ static inline int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, #endif void mce_prep_record(struct mce *m); -void mce_log(struct mce *m); +void mce_log(struct mce_hw_err *err); DECLARE_PER_CPU(struct device *, mce_device); /* Maximum number of MCA banks per CPU. */ diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 0cbadfaf2400..4cd6312423c6 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -28,9 +28,12 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) { - struct mce m; + struct mce_hw_err err; + struct mce *m = &err.m; int lsb; + memset(&err, 0, sizeof(struct mce_hw_err)); + if (!(mem_err->validation_bits & CPER_MEM_VALID_PA)) return; @@ -44,22 +47,22 @@ void apei_mce_report_mem_error(int severity, struct cper_sec_mem_err *mem_err) else lsb = PAGE_SHIFT; - mce_prep_record(&m); - m.bank = -1; + mce_prep_record(m); + m->bank = -1; /* Fake a memory read error with unknown channel */ - m.status = MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | MCI_STATUS_MISCV | 0x9f; - m.misc = (MCI_MISC_ADDR_PHYS << 6) | lsb; + m->status = MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | MCI_STATUS_MISCV | 0x9f; + m->misc = (MCI_MISC_ADDR_PHYS << 6) | lsb; if (severity >= GHES_SEV_RECOVERABLE) - m.status |= MCI_STATUS_UC; + m->status |= MCI_STATUS_UC; if (severity >= GHES_SEV_PANIC) { - m.status |= MCI_STATUS_PCC; - m.tsc = rdtsc(); + m->status |= MCI_STATUS_PCC; + m->tsc = rdtsc(); } - m.addr = mem_err->physical_addr; - mce_log(&m); + m->addr = mem_err->physical_addr; + mce_log(&err); } EXPORT_SYMBOL_GPL(apei_mce_report_mem_error); @@ -67,7 +70,10 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) { const u64 *i_mce = ((const u64 *) (ctx_info + 1)); unsigned int cpu; - struct mce m; + struct mce_hw_err err; + struct mce *m = &err.m; + + memset(&err, 0, sizeof(struct mce_hw_err)); if (!boot_cpu_has(X86_FEATURE_SMCA)) return -EINVAL; @@ -105,18 +111,18 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) if (!cpu_possible(cpu)) return -EINVAL; - mce_prep_record_common(&m); - mce_prep_record_per_cpu(cpu, &m); + mce_prep_record_common(m); + mce_prep_record_per_cpu(cpu, m); - m.bank = (ctx_info->msr_addr >> 4) & 0xFF; - m.status = *i_mce; - m.addr = *(i_mce + 1); - m.misc = *(i_mce + 2); + m->bank = (ctx_info->msr_addr >> 4) & 0xFF; + m->status = *i_mce; + m->addr = *(i_mce + 1); + m->misc = *(i_mce + 2); /* Skipping MCA_CONFIG */ - m.ipid = *(i_mce + 4); - m.synd = *(i_mce + 5); + m->ipid = *(i_mce + 4); + m->synd = *(i_mce + 5); - mce_log(&m); + mce_log(&err); return 0; } diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index a4e2bcf4109c..2f93c825e0fc 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -88,7 +88,7 @@ struct mca_config mca_cfg __read_mostly = { .monarch_timeout = -1 }; -static DEFINE_PER_CPU(struct mce, mces_seen); +static DEFINE_PER_CPU(struct mce_hw_err, hw_errs_seen); static unsigned long mce_need_notify; /* @@ -148,9 +148,9 @@ void mce_prep_record(struct mce *m) DEFINE_PER_CPU(struct mce, injectm); EXPORT_PER_CPU_SYMBOL_GPL(injectm); -void mce_log(struct mce *m) +void mce_log(struct mce_hw_err *err) { - if (!mce_gen_pool_add(m)) + if (!mce_gen_pool_add(err)) irq_work_queue(&mce_irq_work); } EXPORT_SYMBOL_GPL(mce_log); @@ -171,8 +171,10 @@ void mce_unregister_decode_chain(struct notifier_block *nb) } EXPORT_SYMBOL_GPL(mce_unregister_decode_chain); -static void __print_mce(struct mce *m) +static void __print_mce(struct mce_hw_err *err) { + struct mce *m = &err->m; + pr_emerg(HW_ERR "CPU %d: Machine Check%s: %Lx Bank %d: %016Lx\n", m->extcpu, (m->mcgstatus & MCG_STATUS_MCIP ? " Exception" : ""), @@ -214,9 +216,11 @@ static void __print_mce(struct mce *m) m->microcode); } -static void print_mce(struct mce *m) +static void print_mce(struct mce_hw_err *err) { - __print_mce(m); + struct mce *m = &err->m; + + __print_mce(err); if (m->cpuvendor != X86_VENDOR_AMD && m->cpuvendor != X86_VENDOR_HYGON) pr_emerg_ratelimited(HW_ERR "Run the above through 'mcelog --ascii'\n"); @@ -251,7 +255,7 @@ static const char *mce_dump_aux_info(struct mce *m) return NULL; } -static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) +static noinstr void mce_panic(const char *msg, struct mce_hw_err *final, char *exp) { struct llist_node *pending; struct mce_evt_llist *l; @@ -282,20 +286,22 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) pending = mce_gen_pool_prepare_records(); /* First print corrected ones that are still unlogged */ llist_for_each_entry(l, pending, llnode) { - struct mce *m = &l->mce; + struct mce_hw_err *err = &l->err; + struct mce *m = &err->m; if (!(m->status & MCI_STATUS_UC)) { - print_mce(m); + print_mce(err); if (!apei_err) apei_err = apei_write_mce(m); } } /* Now print uncorrected but with the final one last */ llist_for_each_entry(l, pending, llnode) { - struct mce *m = &l->mce; + struct mce_hw_err *err = &l->err; + struct mce *m = &err->m; if (!(m->status & MCI_STATUS_UC)) continue; - if (!final || mce_cmp(m, final)) { - print_mce(m); + if (!final || mce_cmp(m, &final->m)) { + print_mce(err); if (!apei_err) apei_err = apei_write_mce(m); } @@ -303,12 +309,12 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) if (final) { print_mce(final); if (!apei_err) - apei_err = apei_write_mce(final); + apei_err = apei_write_mce(&final->m); } if (exp) pr_emerg(HW_ERR "Machine check: %s\n", exp); - memmsg = mce_dump_aux_info(final); + memmsg = mce_dump_aux_info(&final->m); if (memmsg) pr_emerg(HW_ERR "Machine check: %s\n", memmsg); @@ -323,9 +329,9 @@ static noinstr void mce_panic(const char *msg, struct mce *final, char *exp) * panic. */ if (kexec_crash_loaded()) { - if (final && (final->status & MCI_STATUS_ADDRV)) { + if (final && (final->m.status & MCI_STATUS_ADDRV)) { struct page *p; - p = pfn_to_online_page(final->addr >> PAGE_SHIFT); + p = pfn_to_online_page(final->m.addr >> PAGE_SHIFT); if (p) SetPageHWPoison(p); } @@ -574,13 +580,13 @@ EXPORT_SYMBOL_GPL(mce_is_correctable); static int mce_early_notifier(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = (struct mce *)data; + struct mce_hw_err *err = (struct mce_hw_err *)data; - if (!m) + if (!err) return NOTIFY_DONE; /* Emit the trace record: */ - trace_mce_record(m); + trace_mce_record(err); set_bit(0, &mce_need_notify); @@ -597,7 +603,8 @@ static struct notifier_block early_nb = { static int uc_decode_notifier(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce_hw_err *err = (struct mce_hw_err *)data; + struct mce *mce = &err->m; unsigned long pfn; if (!mce || !mce_usable_address(mce)) @@ -624,13 +631,13 @@ static struct notifier_block mce_uc_nb = { static int mce_default_notifier(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = (struct mce *)data; + struct mce_hw_err *err = (struct mce_hw_err *)data; - if (!m) + if (!err) return NOTIFY_DONE; - if (mca_cfg.print_all || !m->kflags) - __print_mce(m); + if (mca_cfg.print_all || !(err->m.kflags)) + __print_mce(err); return NOTIFY_DONE; } @@ -770,13 +777,16 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) { struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); u32 status_reg; - struct mce m; + struct mce_hw_err err; + struct mce *m = &err.m; int i; - mce_gather_info(&m, NULL); + memset(&err, 0, sizeof(struct mce_hw_err)); + + mce_gather_info(m, NULL); if (flags & MCP_TIMESTAMP) - m.tsc = rdtsc(); + m->tsc = rdtsc(); for (i = 0; i < this_cpu_read(mce_num_banks); i++) { if (!mce_banks[i].ctl || !test_bit(i, *b)) @@ -784,12 +794,10 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) status_reg = mca_msr_reg(i, MCA_STATUS); - m.misc = 0; - m.addr = 0; - m.bank = i; + m->bank = i; barrier(); - m.status = mce_rdmsrl(status_reg); + m->status = mce_rdmsrl(status_reg); /* * Update storm tracking here, before checking for the @@ -799,28 +807,28 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) * storm status. */ if (!mca_cfg.cmci_disabled) - mce_track_storm(&m); + mce_track_storm(m); - if (!log_poll_error(flags, &m, &status_reg)) + if (!log_poll_error(flags, m, &status_reg)) continue; if (flags & MCP_DONTLOG) goto clear_it; - mce_read_aux(&m, i); - m.severity = mce_severity(&m, NULL, NULL, false); + mce_read_aux(m, i); + m->severity = mce_severity(m, NULL, NULL, false); /* * Don't get the IP here because it's unlikely to * have anything to do with the actual error location. */ - if (mca_cfg.dont_log_ce && !mce_usable_address(&m)) + if (mca_cfg.dont_log_ce && !mce_usable_address(m)) goto clear_it; if (flags & MCP_QUEUE_LOG) - mce_gen_pool_add(&m); + mce_gen_pool_add(&err); else - mce_log(&m); + mce_log(&err); clear_it: reset_thr_limit(i); @@ -1058,6 +1066,7 @@ static noinstr int mce_timed_out(u64 *t, const char *msg) static void mce_reign(void) { int cpu; + struct mce_hw_err *err = NULL; struct mce *m = NULL; int global_worst = 0; char *msg = NULL; @@ -1068,11 +1077,13 @@ static void mce_reign(void) * Grade the severity of the errors of all the CPUs. */ for_each_possible_cpu(cpu) { - struct mce *mtmp = &per_cpu(mces_seen, cpu); + struct mce_hw_err *etmp = &per_cpu(hw_errs_seen, cpu); + struct mce *mtmp = &etmp->m; if (mtmp->severity > global_worst) { global_worst = mtmp->severity; - m = &per_cpu(mces_seen, cpu); + err = &per_cpu(hw_errs_seen, cpu); + m = &err->m; } } @@ -1084,7 +1095,7 @@ static void mce_reign(void) if (m && global_worst >= MCE_PANIC_SEVERITY) { /* call mce_severity() to get "msg" for panic */ mce_severity(m, NULL, &msg, true); - mce_panic("Fatal machine check", m, msg); + mce_panic("Fatal machine check", err, msg); } /* @@ -1101,11 +1112,11 @@ static void mce_reign(void) mce_panic("Fatal machine check from unknown source", NULL, NULL); /* - * Now clear all the mces_seen so that they don't reappear on + * Now clear all the hw_errs_seen so that they don't reappear on * the next mce. */ for_each_possible_cpu(cpu) - memset(&per_cpu(mces_seen, cpu), 0, sizeof(struct mce)); + memset(&per_cpu(hw_errs_seen, cpu), 0, sizeof(struct mce_hw_err)); } static atomic_t global_nwo; @@ -1309,12 +1320,13 @@ static noinstr bool mce_check_crashing_cpu(void) } static __always_inline int -__mc_scan_banks(struct mce *m, struct pt_regs *regs, struct mce *final, +__mc_scan_banks(struct mce_hw_err *err, struct pt_regs *regs, struct mce *final, unsigned long *toclear, unsigned long *valid_banks, int no_way_out, int *worst) { struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); struct mca_config *cfg = &mca_cfg; + struct mce *m = &err->m; int severity, i, taint = 0; for (i = 0; i < this_cpu_read(mce_num_banks); i++) { @@ -1370,7 +1382,7 @@ __mc_scan_banks(struct mce *m, struct pt_regs *regs, struct mce *final, * done in #MC context, where instrumentation is disabled. */ instrumentation_begin(); - mce_log(m); + mce_log(err); instrumentation_end(); if (severity > *worst) { @@ -1440,8 +1452,9 @@ static void kill_me_never(struct callback_head *cb) set_mce_nospec(pfn); } -static void queue_task_work(struct mce *m, char *msg, void (*func)(struct callback_head *)) +static void queue_task_work(struct mce_hw_err *err, char *msg, void (*func)(struct callback_head *)) { + struct mce *m = &err->m; int count = ++current->mce_count; /* First call, save all the details */ @@ -1455,11 +1468,12 @@ static void queue_task_work(struct mce *m, char *msg, void (*func)(struct callba /* Ten is likely overkill. Don't expect more than two faults before task_work() */ if (count > 10) - mce_panic("Too many consecutive machine checks while accessing user data", m, msg); + mce_panic("Too many consecutive machine checks while accessing user data", + err, msg); /* Second or later call, make sure page address matches the one from first call */ if (count > 1 && (current->mce_addr >> PAGE_SHIFT) != (m->addr >> PAGE_SHIFT)) - mce_panic("Consecutive machine checks to different user pages", m, msg); + mce_panic("Consecutive machine checks to different user pages", err, msg); /* Do not call task_work_add() more than once */ if (count > 1) @@ -1508,8 +1522,14 @@ noinstr void do_machine_check(struct pt_regs *regs) int worst = 0, order, no_way_out, kill_current_task, lmce, taint = 0; DECLARE_BITMAP(valid_banks, MAX_NR_BANKS) = { 0 }; DECLARE_BITMAP(toclear, MAX_NR_BANKS) = { 0 }; - struct mce m, *final; + struct mce_hw_err *final; + struct mce_hw_err err; char *msg = NULL; + struct mce *m; + + memset(&err, 0, sizeof(struct mce_hw_err)); + + m = &err.m; if (unlikely(mce_flags.p5)) return pentium_machine_check(regs); @@ -1547,13 +1567,13 @@ noinstr void do_machine_check(struct pt_regs *regs) this_cpu_inc(mce_exception_count); - mce_gather_info(&m, regs); - m.tsc = rdtsc(); + mce_gather_info(m, regs); + m->tsc = rdtsc(); - final = this_cpu_ptr(&mces_seen); - *final = m; + final = this_cpu_ptr(&hw_errs_seen); + final->m = *m; - no_way_out = mce_no_way_out(&m, &msg, valid_banks, regs); + no_way_out = mce_no_way_out(m, &msg, valid_banks, regs); barrier(); @@ -1562,15 +1582,15 @@ noinstr void do_machine_check(struct pt_regs *regs) * Assume the worst for now, but if we find the * severity is MCE_AR_SEVERITY we have other options. */ - if (!(m.mcgstatus & MCG_STATUS_RIPV)) + if (!(m->mcgstatus & MCG_STATUS_RIPV)) kill_current_task = 1; /* * Check if this MCE is signaled to only this logical processor, * on Intel, Zhaoxin only. */ - if (m.cpuvendor == X86_VENDOR_INTEL || - m.cpuvendor == X86_VENDOR_ZHAOXIN) - lmce = m.mcgstatus & MCG_STATUS_LMCES; + if (m->cpuvendor == X86_VENDOR_INTEL || + m->cpuvendor == X86_VENDOR_ZHAOXIN) + lmce = m->mcgstatus & MCG_STATUS_LMCES; /* * Local machine check may already know that we have to panic. @@ -1581,12 +1601,12 @@ noinstr void do_machine_check(struct pt_regs *regs) */ if (lmce) { if (no_way_out) - mce_panic("Fatal local machine check", &m, msg); + mce_panic("Fatal local machine check", &err, msg); } else { order = mce_start(&no_way_out); } - taint = __mc_scan_banks(&m, regs, final, toclear, valid_banks, no_way_out, &worst); + taint = __mc_scan_banks(&err, regs, &final->m, toclear, valid_banks, no_way_out, &worst); if (!no_way_out) mce_clear_state(toclear); @@ -1601,7 +1621,7 @@ noinstr void do_machine_check(struct pt_regs *regs) no_way_out = worst >= MCE_PANIC_SEVERITY; if (no_way_out) - mce_panic("Fatal machine check on current CPU", &m, msg); + mce_panic("Fatal machine check on current CPU", &err, msg); } } else { /* @@ -1613,8 +1633,8 @@ noinstr void do_machine_check(struct pt_regs *regs) * make sure we have the right "msg". */ if (worst >= MCE_PANIC_SEVERITY) { - mce_severity(&m, regs, &msg, true); - mce_panic("Local fatal machine check!", &m, msg); + mce_severity(m, regs, &msg, true); + mce_panic("Local fatal machine check!", &err, msg); } } @@ -1632,16 +1652,16 @@ noinstr void do_machine_check(struct pt_regs *regs) goto out; /* Fault was in user mode and we need to take some action */ - if ((m.cs & 3) == 3) { + if ((m->cs & 3) == 3) { /* If this triggers there is no way to recover. Die hard. */ BUG_ON(!on_thread_stack() || !user_mode(regs)); - if (!mce_usable_address(&m)) - queue_task_work(&m, msg, kill_me_now); + if (!mce_usable_address(m)) + queue_task_work(&err, msg, kill_me_now); else - queue_task_work(&m, msg, kill_me_maybe); + queue_task_work(&err, msg, kill_me_maybe); - } else if (m.mcgstatus & MCG_STATUS_SEAM_NR) { + } else if (m->mcgstatus & MCG_STATUS_SEAM_NR) { /* * Saved RIP on stack makes it look like the machine check * was taken in the kernel on the instruction following @@ -1653,8 +1673,8 @@ noinstr void do_machine_check(struct pt_regs *regs) * not occur there. Mark the page as poisoned so it won't * be added to free list when the guest is terminated. */ - if (mce_usable_address(&m)) { - struct page *p = pfn_to_online_page(m.addr >> PAGE_SHIFT); + if (mce_usable_address(m)) { + struct page *p = pfn_to_online_page(m->addr >> PAGE_SHIFT); if (p) SetPageHWPoison(p); @@ -1669,13 +1689,13 @@ noinstr void do_machine_check(struct pt_regs *regs) * corresponding exception handler which would do that is the * proper one. */ - if (m.kflags & MCE_IN_KERNEL_RECOV) { + if (m->kflags & MCE_IN_KERNEL_RECOV) { if (!fixup_exception(regs, X86_TRAP_MC, 0, 0)) - mce_panic("Failed kernel mode recovery", &m, msg); + mce_panic("Failed kernel mode recovery", &err, msg); } - if (m.kflags & MCE_IN_KERNEL_COPYIN) - queue_task_work(&m, msg, kill_me_never); + if (m->kflags & MCE_IN_KERNEL_COPYIN) + queue_task_work(&err, msg, kill_me_never); } out: diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c index a05ac0716ecf..4a0e3bb4a4fb 100644 --- a/arch/x86/kernel/cpu/mce/dev-mcelog.c +++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c @@ -36,7 +36,7 @@ static DECLARE_WAIT_QUEUE_HEAD(mce_chrdev_wait); static int dev_mce_log(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; unsigned int entry; if (mce->kflags & MCE_HANDLED_CEC) diff --git a/arch/x86/kernel/cpu/mce/genpool.c b/arch/x86/kernel/cpu/mce/genpool.c index 4284749ec803..3337ea5c428d 100644 --- a/arch/x86/kernel/cpu/mce/genpool.c +++ b/arch/x86/kernel/cpu/mce/genpool.c @@ -31,15 +31,15 @@ static LLIST_HEAD(mce_event_llist); */ static bool is_duplicate_mce_record(struct mce_evt_llist *t, struct mce_evt_llist *l) { + struct mce_hw_err *err1, *err2; struct mce_evt_llist *node; - struct mce *m1, *m2; - m1 = &t->mce; + err1 = &t->err; llist_for_each_entry(node, &l->llnode, llnode) { - m2 = &node->mce; + err2 = &node->err; - if (!mce_cmp(m1, m2)) + if (!mce_cmp(&err1->m, &err2->m)) return true; } return false; @@ -73,9 +73,9 @@ struct llist_node *mce_gen_pool_prepare_records(void) void mce_gen_pool_process(struct work_struct *__unused) { + struct mce_hw_err *err; struct llist_node *head; struct mce_evt_llist *node, *tmp; - struct mce *mce; head = llist_del_all(&mce_event_llist); if (!head) @@ -83,8 +83,8 @@ void mce_gen_pool_process(struct work_struct *__unused) head = llist_reverse_order(head); llist_for_each_entry_safe(node, tmp, head, llnode) { - mce = &node->mce; - blocking_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); + err = &node->err; + blocking_notifier_call_chain(&x86_mce_decoder_chain, 0, err); gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node)); } } @@ -94,11 +94,11 @@ bool mce_gen_pool_empty(void) return llist_empty(&mce_event_llist); } -int mce_gen_pool_add(struct mce *mce) +int mce_gen_pool_add(struct mce_hw_err *err) { struct mce_evt_llist *node; - if (filter_mce(mce)) + if (filter_mce(&err->m)) return -EINVAL; if (!mce_evt_pool) @@ -110,7 +110,7 @@ int mce_gen_pool_add(struct mce *mce) return -ENOMEM; } - memcpy(&node->mce, mce, sizeof(*mce)); + memcpy(&node->err, err, sizeof(*err)); llist_add(&node->llnode, &mce_event_llist); return 0; diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index 8d18074534ff..4709c8137b09 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -502,6 +502,7 @@ static void prepare_msrs(void *info) static void do_inject(void) { + struct mce_hw_err err; u64 mcg_status = 0; unsigned int cpu = i_mce.extcpu; u8 b = i_mce.bank; @@ -517,7 +518,8 @@ static void do_inject(void) i_mce.status |= MCI_STATUS_SYNDV; if (inj_type == SW_INJ) { - mce_log(&i_mce); + err.m = i_mce; + mce_log(&err); return; } diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index d28c6233f400..5d9008eb7108 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -26,12 +26,12 @@ extern struct blocking_notifier_head x86_mce_decoder_chain; struct mce_evt_llist { struct llist_node llnode; - struct mce mce; + struct mce_hw_err err; }; void mce_gen_pool_process(struct work_struct *__unused); bool mce_gen_pool_empty(void); -int mce_gen_pool_add(struct mce *mce); +int mce_gen_pool_add(struct mce_hw_err *err); int mce_gen_pool_init(void); struct llist_node *mce_gen_pool_prepare_records(void); diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index ca87a0939135..4864191918db 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c @@ -134,7 +134,7 @@ static int print_extlog_rcd(const char *pfx, static int extlog_print(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; int bank = mce->bank; int cpu = mce->extcpu; struct acpi_hest_generic_status *estatus, *tmp; diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c index d48a388b796e..b917988db794 100644 --- a/drivers/acpi/nfit/mce.c +++ b/drivers/acpi/nfit/mce.c @@ -13,7 +13,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; struct acpi_nfit_desc *acpi_desc; struct nfit_spa *nfit_spa; diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c index 91e0a88ef904..d1e47cba0ff2 100644 --- a/drivers/edac/i7core_edac.c +++ b/drivers/edac/i7core_edac.c @@ -1810,7 +1810,7 @@ static void i7core_check_error(struct mem_ctl_info *mci, struct mce *m) static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; struct i7core_dev *i7_dev; struct mem_ctl_info *mci; diff --git a/drivers/edac/igen6_edac.c b/drivers/edac/igen6_edac.c index cdd8480e7368..2c112d4d842b 100644 --- a/drivers/edac/igen6_edac.c +++ b/drivers/edac/igen6_edac.c @@ -911,7 +911,7 @@ static int ecclog_nmi_handler(unsigned int cmd, struct pt_regs *regs) static int ecclog_mce_handler(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; char *type; if (mce->kflags & MCE_HANDLED_CEC) diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c index 8130c3dc64da..c5fae99de781 100644 --- a/drivers/edac/mce_amd.c +++ b/drivers/edac/mce_amd.c @@ -792,7 +792,7 @@ static const char *decode_error_status(struct mce *m) static int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = (struct mce *)data; + struct mce *m = &((struct mce_hw_err *)data)->m; unsigned int fam = x86_family(m->cpuid); int ecc; diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c index 2afcd148fcf8..e2fb2d75af04 100644 --- a/drivers/edac/pnd2_edac.c +++ b/drivers/edac/pnd2_edac.c @@ -1366,7 +1366,7 @@ static void pnd2_unregister_mci(struct mem_ctl_info *mci) */ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; struct mem_ctl_info *mci; struct dram_addr daddr; char *type; diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c index 26cca5a9322d..0c4e45245153 100644 --- a/drivers/edac/sb_edac.c +++ b/drivers/edac/sb_edac.c @@ -3255,7 +3255,7 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci, static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; struct mem_ctl_info *mci; char *type; diff --git a/drivers/edac/skx_common.c b/drivers/edac/skx_common.c index 27996b7924c8..7de89c24e06f 100644 --- a/drivers/edac/skx_common.c +++ b/drivers/edac/skx_common.c @@ -633,7 +633,7 @@ static bool skx_error_in_mem(const struct mce *m) int skx_mce_check_error(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *mce = (struct mce *)data; + struct mce *mce = &((struct mce_hw_err *)data)->m; struct decoded_addr res; struct mem_ctl_info *mci; char *type; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c index 1adc81a55734..d8cd44eb7e73 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -3824,7 +3824,7 @@ static struct amdgpu_device *find_adev(uint32_t node_id) static int amdgpu_bad_page_notifier(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = (struct mce *)data; + struct mce *m = &((struct mce_hw_err *)data)->m; struct amdgpu_device *adev = NULL; uint32_t gpu_id = 0; uint32_t umc_inst = 0, ch_inst = 0; diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c index 271dfad05d68..d3ce41a46ac4 100644 --- a/drivers/ras/amd/fmpm.c +++ b/drivers/ras/amd/fmpm.c @@ -400,7 +400,7 @@ static void retire_dram_row(u64 addr, u64 id, u32 cpu) static int fru_handle_mem_poison(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = (struct mce *)data; + struct mce *m = &((struct mce_hw_err *)data)->m; struct fru_rec *rec; if (!mce_is_memory_error(m)) diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c index e440b15fbabc..be785746f587 100644 --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -534,7 +534,7 @@ static int __init create_debugfs_nodes(void) static int cec_notifier(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = (struct mce *)data; + struct mce *m = &((struct mce_hw_err *)data)->m; if (!m) return NOTIFY_DONE; diff --git a/include/trace/events/mce.h b/include/trace/events/mce.h index f0f7b3cb2041..65aba1afcd07 100644 --- a/include/trace/events/mce.h +++ b/include/trace/events/mce.h @@ -19,9 +19,9 @@ TRACE_EVENT(mce_record, - TP_PROTO(struct mce *m), + TP_PROTO(struct mce_hw_err *err), - TP_ARGS(m), + TP_ARGS(err), TP_STRUCT__entry( __field( u64, mcgcap ) @@ -46,25 +46,25 @@ TRACE_EVENT(mce_record, ), TP_fast_assign( - __entry->mcgcap = m->mcgcap; - __entry->mcgstatus = m->mcgstatus; - __entry->status = m->status; - __entry->addr = m->addr; - __entry->misc = m->misc; - __entry->synd = m->synd; - __entry->ipid = m->ipid; - __entry->ip = m->ip; - __entry->tsc = m->tsc; - __entry->ppin = m->ppin; - __entry->walltime = m->time; - __entry->cpu = m->extcpu; - __entry->cpuid = m->cpuid; - __entry->apicid = m->apicid; - __entry->socketid = m->socketid; - __entry->cs = m->cs; - __entry->bank = m->bank; - __entry->cpuvendor = m->cpuvendor; - __entry->microcode = m->microcode; + __entry->mcgcap = err->m.mcgcap; + __entry->mcgstatus = err->m.mcgstatus; + __entry->status = err->m.status; + __entry->addr = err->m.addr; + __entry->misc = err->m.misc; + __entry->synd = err->m.synd; + __entry->ipid = err->m.ipid; + __entry->ip = err->m.ip; + __entry->tsc = err->m.tsc; + __entry->ppin = err->m.ppin; + __entry->walltime = err->m.time; + __entry->cpu = err->m.extcpu; + __entry->cpuid = err->m.cpuid; + __entry->apicid = err->m.apicid; + __entry->socketid = err->m.socketid; + __entry->cs = err->m.cs; + __entry->bank = err->m.bank; + __entry->cpuvendor = err->m.cpuvendor; + __entry->microcode = err->m.microcode; ), TP_printk("CPU: %d, MCGc/s: %llx/%llx, MC%d: %016Lx, IPID: %016Lx, ADDR: %016Lx, MISC: %016Lx, SYND: %016Lx, RIP: %02x:<%016Lx>, TSC: %llx, PPIN: %llx, vendor: %u, CPUID: %x, time: %llu, socket: %u, APIC: %x, microcode: %x", From patchwork Thu May 30 21:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13680855 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2055.outbound.protection.outlook.com [40.107.92.55]) (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 0EB6D18306F; Thu, 30 May 2024 21:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103821; cv=fail; b=SHyEXsjnkkL+fOLG7sMjJoN6eL8TJzZLUSvPVE5MOIIJ9PJ0u20drcujLIshgSNJDUX+9JaPVEZLYhav4NQTeAkMJErYaObJK2WiqDq6HQBHT+lzgViu08+yQ3o1k7gACl4xKo7ihza5htE5TQJwHrv/TmEyczY4SlCN8EdzLMg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103821; c=relaxed/simple; bh=+XZXUbzi0FSspXhwbEY+GX74EHnfasCv8JcBAl2yKbo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l9/Mcl3qZfY5PL0AUvXM8iRDFSQTkALRmoiGMPVGvBqeY66aRyUVvHEdjZEuQf6GIYboMNQTLfNaIE/FeZJRZo2wucpgoyyRQN3Vg/2Q0d47FCoqyNh4uwjOSl1RlYKBXUX3OyqvJ8LWZsXumwepMRytVUtpz5rrdHhe0q3Yj5Q= 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=FmZri2mc; arc=fail smtp.client-ip=40.107.92.55 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="FmZri2mc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eh947FGuJMQeI1rISXkiEa7DuYyRI82uCO6FWiqEmbopZ67qK5IwesrSwkGjfdriMjWxtKojWgezsQsBMRGK1VEwqXYBvKgo0bJr8DZk4QPPmk7MMDdBib/SEjaQvoLMaMy5tFWzG7ASIhpKQzGqxMYP9YO1jc6woyuF2MXgK0kg7Sp+n+JnCf5tdMojCFz/RI1oKbFPnc6FK1pnfVEGzsHp5zFhuxxQAWkSC9C2swdozEF+swVCRFhZHTqygqxsM7KqgDWVe/IVPzThFwbb1fFPMaUqCHx84h5co2Bod+fheCIdrmBwwkhD6e5FWaFbp37V/l8s/3TOzltEjIymOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T1eCgkt9e8NKW8RNGTTjWmEdP7D58hRwYCotQxuAoh8=; b=T9P3c0ynRlKkLESa+OdVb2xiP+wlS7NHFEFLaiO7mJc3uElSlCbAxffhNiWEnkQ4PoauFy3g9KHGfSLMTQXnp5K6QEGf0ABUPvSBQUZQLfmt4RWK9T9T5LWuqkKGeMSQoNsOA5kpxG1Mr7DJsRDV9VZgV8gPK09LixPc7dZIDReUnjBcyGHdHFvnvJ5xao6WIaUIoZ75WlBigdfESKsYbrYiv8IRkIB9f8b4W6c8t3lFSdSL7nYvdfCRLSXdHQ6cVS9lkRmDDPlOq6zGu9snT3zQ5wpbLDJFs9WLz5JjiDAu+fpyN9nAY33b7IwTJaBJCLe7Nx/Su8z9KlwkKlkhPw== 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=T1eCgkt9e8NKW8RNGTTjWmEdP7D58hRwYCotQxuAoh8=; b=FmZri2mcMiOtPOFaEQBmHRNd7PFCW/bLEsUEB3+1QVA8C4ucrnc1w5vpBOJiwHNn9kkrOMnzFJs0P8jJBkIV3ulpWqEkhh9kRb06lyJNk/EbP3mLDHwAffX+QdHieYaXo5tlY/M/a7HgFRXVS7TXS7TkSt/bAOgKBq9BSZ+3BiQ= Received: from PH0P220CA0016.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:d3::19) by SJ0PR12MB6925.namprd12.prod.outlook.com (2603:10b6:a03:483::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Thu, 30 May 2024 21:16:54 +0000 Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:510:d3:cafe::8c) by PH0P220CA0016.outlook.office365.com (2603:10b6:510:d3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21 via Frontend Transport; Thu, 30 May 2024 21:16:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 21:16:54 +0000 Received: from titanite-d354host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 May 2024 16:16:53 -0500 From: Avadhut Naik To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH 2/4] x86/mce, EDAC/mce_amd: Add support for new MCA_SYND{1,2} registers Date: Thu, 30 May 2024 16:16:18 -0500 Message-ID: <20240530211620.1829453-3-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530211620.1829453-1-avadhut.naik@amd.com> References: <20240530211620.1829453-1-avadhut.naik@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|SJ0PR12MB6925:EE_ X-MS-Office365-Filtering-Correlation-Id: 67804830-6a9d-4dae-40a6-08dc80edd4c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|36860700004|7416005|376005; X-Microsoft-Antispam-Message-Info: xaJTvnS1hDjos6pHZq4TewwkHDR30yHw37+Bbi6HemNW6+9Cx6kAz3dlGIUKRHL4nYIXMJPqLRAa4fxBPrqsPOQpwTYWEGmqQb376ZrKmB0AM3wxh4O8T17I6zncqB1lM8JnswUYpxazvEffeQmOf7bw6EtbPYoz5pbXVrlyLvGEEpP8d8S5Ou8rnmCGij1X4ITAKH9hLg0qBbi2PTQT8+R5foVfhgE3Kjau4Yhf59t1cK0itEgPD1BUDXxJSIEd8e86OII3X3TTSTi1sbYNT9qWeD4nfRlixZkoZZiAiPB2bvsMZXQV5BPJm9G1B+b5yaUOR1ndGDUjjuScc4U8G2dWtItf6jE6HyralKb+aCCSaX9wpctvvf7pYeEwYF/PWxU+JmDp8ZyW6d1g3NAfRaZGszS5Fis/D/L/k2TBuwPkLdkV26GNDtfreYKtBIvBti1fvgjm2+ITzc1IR5hgVfQPg5Ez3P22B70+/rMLDXq+7/wvFjx1nB+H5U60YcDCdiWDMVEH3M0BRsASl023x8ymvQj3V/2v+nbs5t5i/7yHfkhz7PqIBcvWNVm5G1GZzwB7WDnUWJtUFkdaQZ8nmXwmC/yejmOcXgDLl6z+kmGRC2UE+h3KXLQfRzoSg9l/ttXlQDtdKdxRXSdWTT+0XGDadrzp1KeyIVlzdywxufNQeyh1SU5vKHk4fm1L4YN4rvDI6e9eKw1SHYcpJ7KV/4GMxgsY5MUT7OWbrBj3MiRilY55KNoZTZ1Pnbc51YxoJHCVYk5Z69ru/SjVpWlvHYF6L6HTZZOLf6gTgSUsVvAQvxPtlEnxyzjqgWoGiyXr/rJHhqkwa98pUCRFmIlwej2CpdapCF3BjzztLjNpeJF9uh8z706gAGBbKCZ6PHA/QpAuEyCpM5uet38vzENdQFQ/j+gLXkwNeB6NKCFOgIAomI0l4SCBw+F1m1Nz3EgaKTOKhXBSukKn3WPaHCJXwrVF6T062oFNYyVKFDyxLaL0SuefR/8s221uK7OoxKE8no4WKPu0KjVI+j7DxuoC3PLgYXBGN1gTjju9MMJlzKXBqsmzCo8kmf/aKy7DqnxBFFKQqS2it9proQK50BCwMUVvW1n4lss5NgDNVq3pC0MdZYS9xWOjDbj2Zfs5QajqEEXQkhHCoDspD8aTnA754bXSk/R5360n2+XjZx/iJsRO8OWrZg+B0ekxVCQv4HMkoa2WjBvPMjhuaQc4/c9Yib2g/rOst9AXuVB00T78GCfCYdzJJ0iSm5hge/a0gArj5Abk3XZ3Cy8+sJNqNja+K7QBxJJik7e0DCg/HpfpD7FiWQ6bM9MbqlC75IRMljHuZyMekXu5hxlhk8yqGey9JPSK4rFR3ThofUtFkWGKAOjd69Nm8WbKK7Vgqh09R1IY X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(82310400017)(36860700004)(7416005)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 21:16:54.3804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67804830-6a9d-4dae-40a6-08dc80edd4c0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6925 From: Avadhut Naik AMD's Scalable MCA systems viz. Genoa will include two new registers: MCA_SYND1 and MCA_SYND2. These registers will include supplemental error information in addition to the existing MCA_SYND register. The data within the registers is considered valid if MCA_STATUS[SyndV] is set. Add fields for these registers as vendor-specific error information in struct mce_hw_err. Save and print these registers wherever MCA_STATUS[SyndV]/MCA_SYND is currently used. Also, modify the mce_record tracepoint to export these new registers through __dynamic_array. While the sizeof() operator has been used to determine the size of this __dynamic_array, the same, if needed in the future can be substituted by caching the size of vendor-specific error information as part of struct mce_hw_err. Note: Checkpatch warnings/errors are ignored to maintain coding style. [Yazen: Drop Yazen's Co-developed-by tag and moved SoB tag.] Signed-off-by: Avadhut Naik Signed-off-by: Yazen Ghannam --- arch/x86/include/asm/mce.h | 12 ++++++++++++ arch/x86/kernel/cpu/mce/core.c | 24 +++++++++++++++++------- drivers/edac/mce_amd.c | 10 +++++++--- include/trace/events/mce.h | 9 +++++++-- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 83923d8a43b0..290d32c84ffd 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -122,6 +122,9 @@ #define MSR_AMD64_SMCA_MC0_DESTAT 0xc0002008 #define MSR_AMD64_SMCA_MC0_DEADDR 0xc0002009 #define MSR_AMD64_SMCA_MC0_MISC1 0xc000200a +/* Registers MISC2 to MISC4 are at offsets B to D. */ +#define MSR_AMD64_SMCA_MC0_SYND1 0xc000200e +#define MSR_AMD64_SMCA_MC0_SYND2 0xc000200f #define MSR_AMD64_SMCA_MCx_CTL(x) (MSR_AMD64_SMCA_MC0_CTL + 0x10*(x)) #define MSR_AMD64_SMCA_MCx_STATUS(x) (MSR_AMD64_SMCA_MC0_STATUS + 0x10*(x)) #define MSR_AMD64_SMCA_MCx_ADDR(x) (MSR_AMD64_SMCA_MC0_ADDR + 0x10*(x)) @@ -132,6 +135,8 @@ #define MSR_AMD64_SMCA_MCx_DESTAT(x) (MSR_AMD64_SMCA_MC0_DESTAT + 0x10*(x)) #define MSR_AMD64_SMCA_MCx_DEADDR(x) (MSR_AMD64_SMCA_MC0_DEADDR + 0x10*(x)) #define MSR_AMD64_SMCA_MCx_MISCy(x, y) ((MSR_AMD64_SMCA_MC0_MISC1 + y) + (0x10*(x))) +#define MSR_AMD64_SMCA_MCx_SYND1(x) (MSR_AMD64_SMCA_MC0_SYND1 + 0x10*(x)) +#define MSR_AMD64_SMCA_MCx_SYND2(x) (MSR_AMD64_SMCA_MC0_SYND2 + 0x10*(x)) #define XEC(x, mask) (((x) >> 16) & mask) @@ -189,6 +194,13 @@ enum mce_notifier_prios { struct mce_hw_err { struct mce m; + + union vendor_info { + struct { + u64 synd1; + u64 synd2; + } amd; + } vi; }; struct notifier_block; diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 2f93c825e0fc..253d7d0d3331 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -201,6 +201,10 @@ static void __print_mce(struct mce_hw_err *err) if (mce_flags.smca) { if (m->synd) pr_cont("SYND %llx ", m->synd); + if (err->vi.amd.synd1) + pr_cont("SYND1 %llx ", err->vi.amd.synd1); + if (err->vi.amd.synd2) + pr_cont("SYND2 %llx ", err->vi.amd.synd2); if (m->ipid) pr_cont("IPID %llx ", m->ipid); } @@ -651,8 +655,10 @@ static struct notifier_block mce_default_nb = { /* * Read ADDR and MISC registers. */ -static noinstr void mce_read_aux(struct mce *m, int i) +static noinstr void mce_read_aux(struct mce_hw_err *err, int i) { + struct mce *m = &err->m; + if (m->status & MCI_STATUS_MISCV) m->misc = mce_rdmsrl(mca_msr_reg(i, MCA_MISC)); @@ -675,8 +681,11 @@ static noinstr void mce_read_aux(struct mce *m, int i) if (mce_flags.smca) { m->ipid = mce_rdmsrl(MSR_AMD64_SMCA_MCx_IPID(i)); - if (m->status & MCI_STATUS_SYNDV) + if (m->status & MCI_STATUS_SYNDV) { m->synd = mce_rdmsrl(MSR_AMD64_SMCA_MCx_SYND(i)); + err->vi.amd.synd1 = mce_rdmsrl(MSR_AMD64_SMCA_MCx_SYND1(i)); + err->vi.amd.synd2 = mce_rdmsrl(MSR_AMD64_SMCA_MCx_SYND2(i)); + } } } @@ -815,7 +824,7 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) if (flags & MCP_DONTLOG) goto clear_it; - mce_read_aux(m, i); + mce_read_aux(&err, i); m->severity = mce_severity(m, NULL, NULL, false); /* * Don't get the IP here because it's unlikely to @@ -954,9 +963,10 @@ static __always_inline void quirk_zen_ifu(int bank, struct mce *m, struct pt_reg * Do a quick check if any of the events requires a panic. * This decides if we keep the events around or clear them. */ -static __always_inline int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, +static __always_inline int mce_no_way_out(struct mce_hw_err *err, char **msg, unsigned long *validp, struct pt_regs *regs) { + struct mce *m = &err->m; char *tmp = *msg; int i; @@ -974,7 +984,7 @@ static __always_inline int mce_no_way_out(struct mce *m, char **msg, unsigned lo m->bank = i; if (mce_severity(m, regs, &tmp, true) >= MCE_PANIC_SEVERITY) { - mce_read_aux(m, i); + mce_read_aux(err, i); *msg = tmp; return 1; } @@ -1372,7 +1382,7 @@ __mc_scan_banks(struct mce_hw_err *err, struct pt_regs *regs, struct mce *final, if (severity == MCE_NO_SEVERITY) continue; - mce_read_aux(m, i); + mce_read_aux(err, i); /* assuming valid severity level != 0 */ m->severity = severity; @@ -1573,7 +1583,7 @@ noinstr void do_machine_check(struct pt_regs *regs) final = this_cpu_ptr(&hw_errs_seen); final->m = *m; - no_way_out = mce_no_way_out(m, &msg, valid_banks, regs); + no_way_out = mce_no_way_out(&err, &msg, valid_banks, regs); barrier(); diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c index c5fae99de781..69e12cb2f0de 100644 --- a/drivers/edac/mce_amd.c +++ b/drivers/edac/mce_amd.c @@ -792,7 +792,8 @@ static const char *decode_error_status(struct mce *m) static int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m = &((struct mce_hw_err *)data)->m; + struct mce_hw_err *err = (struct mce_hw_err *)data; + struct mce *m = &err->m; unsigned int fam = x86_family(m->cpuid); int ecc; @@ -850,8 +851,11 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) if (boot_cpu_has(X86_FEATURE_SMCA)) { pr_emerg(HW_ERR "IPID: 0x%016llx", m->ipid); - if (m->status & MCI_STATUS_SYNDV) - pr_cont(", Syndrome: 0x%016llx", m->synd); + if (m->status & MCI_STATUS_SYNDV) { + pr_cont(", Syndrome: 0x%016llx\n", m->synd); + pr_emerg(HW_ERR "Syndrome1: 0x%016llx, Syndrome2: 0x%016llx", + err->vi.amd.synd1, err->vi.amd.synd2); + } pr_cont("\n"); diff --git a/include/trace/events/mce.h b/include/trace/events/mce.h index 65aba1afcd07..9e7211eddbca 100644 --- a/include/trace/events/mce.h +++ b/include/trace/events/mce.h @@ -43,6 +43,8 @@ TRACE_EVENT(mce_record, __field( u8, bank ) __field( u8, cpuvendor ) __field( u32, microcode ) + __field( u8, len ) + __dynamic_array(u8, v_data, sizeof(err->vi)) ), TP_fast_assign( @@ -65,9 +67,11 @@ TRACE_EVENT(mce_record, __entry->bank = err->m.bank; __entry->cpuvendor = err->m.cpuvendor; __entry->microcode = err->m.microcode; + __entry->len = sizeof(err->vi); + memcpy(__get_dynamic_array(v_data), &err->vi, sizeof(err->vi)); ), - TP_printk("CPU: %d, MCGc/s: %llx/%llx, MC%d: %016Lx, IPID: %016Lx, ADDR: %016Lx, MISC: %016Lx, SYND: %016Lx, RIP: %02x:<%016Lx>, TSC: %llx, PPIN: %llx, vendor: %u, CPUID: %x, time: %llu, socket: %u, APIC: %x, microcode: %x", + TP_printk("CPU: %d, MCGc/s: %llx/%llx, MC%d: %016llx, IPID: %016llx, ADDR: %016llx, MISC: %016llx, SYND: %016llx, RIP: %02x:<%016llx>, TSC: %llx, PPIN: %llx, vendor: %u, CPUID: %x, time: %llu, socket: %u, APIC: %x, microcode: %x, vendor data: %s", __entry->cpu, __entry->mcgcap, __entry->mcgstatus, __entry->bank, __entry->status, @@ -83,7 +87,8 @@ TRACE_EVENT(mce_record, __entry->walltime, __entry->socketid, __entry->apicid, - __entry->microcode) + __entry->microcode, + __print_array(__get_dynamic_array(v_data), __entry->len / 8, 8)) ); #endif /* _TRACE_MCE_H */ From patchwork Thu May 30 21:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13680856 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071.outbound.protection.outlook.com [40.107.243.71]) (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 E241018130F; Thu, 30 May 2024 21:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103837; cv=fail; b=m+HQeccvNUocAX/3g0iLe6pabEt7njnwdiURzRvz42JmOXtygwPnEndfAzbtUd/ZP57qZaP0VzO+xBmFOEq3aRFEHueW0Rm2jm8DcJUVyVt9tFdgWfFN99sO8fWQ0qmEWbx+qWHHLDrs+vT06DVNXi9bTwO8Vw4NGXSuvA0V2gM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103837; c=relaxed/simple; bh=8wT+S9xFWR/56b2IevNaYTjuveht0br3mSd2/0JLDJk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p2aRQ/xZ031zRtU0wnbsVM9xB05fqyv7xd1sPjEman29n+VO6yX9EqTFf2ntIkuHneuwKI1uWF4s1nFBNdmnJ/oWIJinrcJq7QygybWM+r370SK3eYYH0J0Io80SGhk8A1sVxaCNN5PAH1hqSwWgDQaIdoQrwA0yyAJQzuhFFsg= 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=ZJR1JrT2; arc=fail smtp.client-ip=40.107.243.71 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="ZJR1JrT2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ScTz8xoDlvv48koTQsgXc/hvnGDzpoTXwuR0vjmNdT2jNoN5OAqMrBfR2coJuWvoaK7PeX/LBkhfdd+E51E244FMVazfx4Ev2by+aT4WzwjnaWGC0bXkHHhCz0ZijoBptd6K8mENta/2jiVv84EPixptvFSEaDt0OHVZx9jJp4Nqrnw4IH9cWhOcRZYQxcTnB0sOjtdU78dN6MSiBc7wESIm9fEbNJDzxjWaK5/wP6Zv6CntybuoWAnX+Rhu2Qnc+OjIQOAas7K6Cm+eGspbLCt1MmPD+AkkqhmLv7xbQuJHWQH4KgqmvO/LdyxsbiJblIeaYLO7WFBJqDs6gXaXnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jmcae4TM+w1Zwn60GaLQvU+QpbTln4MaMCjShDDBSco=; b=Fc3tk6Wb7JumRiNlahdJw60LNNVm06RThWkJOviWTNc1hVCnsolEOwwZ9tnVmpOpXrZWYa6WH/5+d5EuE9o38fTHJWmBFZCyVbKJnug56u7c7oFCx7lujABr9Wj6GcpLA408HIm90hiKNXyN5InUzP9SWzQVL8ABC1DNE14bx2ardFjWkLL2cfLyEQaXZfVExlN4nftpftPZlSXfVLGkmr1LK6OtA59TkczkThHoZfxvuw+xj1EgX8ZGfT4APiVLuwNha5phAzYAyUe64AlQSeDdvqXoNcTW3TPx0E7v9sgGn+9LebWwnCl7brtAatKi+CboqdpGsaL9+S9dpOCxpQ== 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=jmcae4TM+w1Zwn60GaLQvU+QpbTln4MaMCjShDDBSco=; b=ZJR1JrT28YgK792aRo23jshBTAnfCE0SkCas5kuQ9Lt1+oovbpgu57iK5pRM2gMXeIQ2dZEWigW8dSUNd3OkgUmO+rS+gswgl3iGQmH7gumETARVfrOmP6FNJnINc4C8WXmw1ztke/B53kBl4n279IfzyeOTJvs/CAighQLNKNY= Received: from PH8PR22CA0020.namprd22.prod.outlook.com (2603:10b6:510:2d1::27) by CH2PR12MB4216.namprd12.prod.outlook.com (2603:10b6:610:a8::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.29; Thu, 30 May 2024 21:17:07 +0000 Received: from CY4PEPF0000E9DC.namprd05.prod.outlook.com (2603:10b6:510:2d1:cafe::58) by PH8PR22CA0020.outlook.office365.com (2603:10b6:510:2d1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22 via Frontend Transport; Thu, 30 May 2024 21:17:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9DC.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 21:17:06 +0000 Received: from titanite-d354host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 May 2024 16:17:04 -0500 From: Avadhut Naik To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH 3/4] x86/mce/apei: Handle variable register array size Date: Thu, 30 May 2024 16:16:19 -0500 Message-ID: <20240530211620.1829453-4-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530211620.1829453-1-avadhut.naik@amd.com> References: <20240530211620.1829453-1-avadhut.naik@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9DC:EE_|CH2PR12MB4216:EE_ X-MS-Office365-Filtering-Correlation-Id: 77811aa4-d236-4a52-3847-08dc80eddbb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|36860700004|7416005|376005|1800799015; X-Microsoft-Antispam-Message-Info: C8QcyK+Tvbeuacef0zqsLFsW0eGzGOd6KrOPtBAHIj6YXNEkyYUALH69izjoVjSvlB/lPYWBDR5h8534G6a7aTTASs+9LbcYARhVGMEYWlJJbO8hcAY39PSpfWOV4C2oKoqfPiEcjaQ+aPMOAvEuPRX2590nSJaVZgKlD0u/xTL/0uvOBkGvhAUOsUUAHnWLblu3xM4XBwzOUlpHfb2hR8m2tZ5Tits5d+t0RrDUEcY54laR5SSZSlgPFdMH8ddzzkLwwSV1z61RZ2RCf9zdIqp/8lOjz14lajGlffp4TMo3Ar8lan32GqNeoDBrJoSZx7YVivtkNEcYvkPWJGsly9mR67eICk5yoMovkBIoy77ocogirDNT2ozHrw/wsXFZm8GyEPFh+WmdnsDzXxPKWRzU54h1iy3l8YbQHfk4V/bD8IQ2O+5Wl/yaJPRktpxpPRcnvzr0KGRgrerbNoKLcZ17nQWggo7P6i1Ow6N7zwpQTFXyZF/5qTzHWSA0iQh+rfWG910OpPtCLyTD6502Bn4ldaI+r0Y3DhLU4Vhln2gVNhdJ/XqwCrY6+Ym74317mzBNzo/Wwf/eXHrsCzSNPv2EsbtiyMDGtgyDZZb5A3Y0R9szPG+9t2q3WMJaE0jPhZvGtEVvMdiyaRj52BL+On75MdKPxy2Wc+QeXvlVLmFT+Kw5BbvxjRc+qyoQ79RwSHUkkYEZWsIix+n3oScJ0fWSlZGyUGBqE3UGQAyqbmfw6ZHXm0uWrHmsSl8W15Kcd9iA0a7USWSOH8kjs0kPqGn/AZA8/Rx5TWGApkKNdNemzUe3eMMQL3es6bvkFJhksv9YiyuLaYnLKNT3Rsr5FhWl5Ps1zP49yRl1KRQrMhJ0mCvyoJTzBTWX97FqUuwKHOGz5+rZDYs53pSqQHilKr3Y2qbtpMADNIr5AY3PziAsigvycnfktn9fdLxxpg4qjF9kW1WE8AbpkuW4sJCT7ydowgsofsIR0eJvmDPjeu2zLGhmSnAW75qFRfBUyn2AIJ17juEJ4yGW/KOp/kEN+gj6Z9TgCcUUbPon6pLXTG3giK5l2cs5ObgbNsvZH4Li8CcR1eYV8AUZ8YvKSjLA8fh4btPeCLRqp3v3f1VZY4VhmjRTDimPBS7e/InXrd28vyvnngiwoK8NJvWw5i97TRJthOg55fMNREerKmFTcissCfcq67idrw7eSDQZOIhzzAFfsvZknp7GErMPwfvb6lwYNdlFJNa7JDBPyjod0VmMYWfRhHaaJMtwAw5srWu5udpOEEO5KFdybWTmtw1+eC4/CkADID8Nx7adNT48A+gWgfCuq9WreQ15SyBfjUXazTFAgznXHlDCqWxEyE9UevzsEFO2i6XL6E++ZyBjXMqc/VhpNwyNYsD7wwGMJNQl X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(36860700004)(7416005)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 21:17:06.0783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77811aa4-d236-4a52-3847-08dc80eddbb9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9DC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4216 From: Yazen Ghannam ACPI Boot Error Record Table (BERT) is being used by the kernel to report errors that occurred in a previous boot. On some modern AMD systems, these very errors within the BERT are reported through the x86 Common Platform Error Record (CPER) format which consists of one or more Processor Context Information Structures. These context structures provide a starting address and represent an x86 MSR range in which the data constitutes a contiguous set of MSRs starting from, and including the starting address. It's common, for AMD systems that implement this behavior, that the MSR range represents the MCAX register space used for the Scalable MCA feature. The apei_smca_report_x86_error() function decodes and passes this information through the MCE notifier chain. However, this function assumes a fixed register size based on the original HW/FW implementation. This assumption breaks with the addition of two new MCAX registers viz. MCA_SYND1 and MCA_SYND2. These registers are added at the end of the MCAX register space, so they won't be included when decoding the CPER data. Rework apei_smca_report_x86_error() to support a variable register array size. This covers any case where the MSR context information starts at the MCAX address for MCA_STATUS and ends at any other register within the MCAX register space. Add code comments indicating the MCAX register at each offset. [Yazen: Add Avadhut as co-developer for wrapper changes.] Co-developed-by: Avadhut Naik Signed-off-by: Avadhut Naik Signed-off-by: Yazen Ghannam --- arch/x86/kernel/cpu/mce/apei.c | 73 +++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 4cd6312423c6..8fd4c42ddc06 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -69,7 +69,7 @@ EXPORT_SYMBOL_GPL(apei_mce_report_mem_error); int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) { const u64 *i_mce = ((const u64 *) (ctx_info + 1)); - unsigned int cpu; + unsigned int cpu, num_registers; struct mce_hw_err err; struct mce *m = &err.m; @@ -91,16 +91,12 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) return -EINVAL; /* - * The register array size must be large enough to include all the - * SMCA registers which need to be extracted. - * * The number of registers in the register array is determined by * Register Array Size/8 as defined in UEFI spec v2.8, sec N.2.4.2.2. - * The register layout is fixed and currently the raw data in the - * register array includes 6 SMCA registers which the kernel can - * extract. + * Ensure that the array size includes at least 1 register. */ - if (ctx_info->reg_arr_size < 48) + num_registers = ctx_info->reg_arr_size >> 3; + if (!num_registers) return -EINVAL; for_each_possible_cpu(cpu) { @@ -115,12 +111,61 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) mce_prep_record_per_cpu(cpu, m); m->bank = (ctx_info->msr_addr >> 4) & 0xFF; - m->status = *i_mce; - m->addr = *(i_mce + 1); - m->misc = *(i_mce + 2); - /* Skipping MCA_CONFIG */ - m->ipid = *(i_mce + 4); - m->synd = *(i_mce + 5); + + /* + * The SMCA register layout is fixed and includes 16 registers. + * The end of the array may be variable, but the beginning is known. + * Switch on the number of registers. Cap the number of registers to + * expected max (15). + */ + if (num_registers > 15) + num_registers = 15; + + switch (num_registers) { + /* MCA_SYND2 */ + case 15: + err.vi.amd.synd2 = *(i_mce + 14); + fallthrough; + /* MCA_SYND1 */ + case 14: + err.vi.amd.synd1 = *(i_mce + 13); + fallthrough; + /* MCA_MISC4 */ + case 13: + /* MCA_MISC3 */ + case 12: + /* MCA_MISC2 */ + case 11: + /* MCA_MISC1 */ + case 10: + /* MCA_DEADDR */ + case 9: + /* MCA_DESTAT */ + case 8: + /* reserved */ + case 7: + /* MCA_SYND */ + case 6: + m->synd = *(i_mce + 5); + fallthrough; + /* MCA_IPID */ + case 5: + m->ipid = *(i_mce + 4); + fallthrough; + /* MCA_CONFIG */ + case 4: + /* MCA_MISC0 */ + case 3: + m->misc = *(i_mce + 2); + fallthrough; + /* MCA_ADDR */ + case 2: + m->addr = *(i_mce + 1); + fallthrough; + /* MCA_STATUS */ + case 1: + m->status = *i_mce; + } mce_log(&err); From patchwork Thu May 30 21:16:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13680857 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2062.outbound.protection.outlook.com [40.107.93.62]) (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 B19EA24B26; Thu, 30 May 2024 21:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103848; cv=fail; b=HzcaLOJbjd6swdv+Pk4d7oGoXAxnYP/CRgjvB5mx1cRyr2twYSe5bzoWQ3CNJGVTUjl2C2vBC3+fP6eM/wNTGEASoIZccQlS6NG5OoYlj32EOHWGP94fMoUaus+79/xcqfLveWJ2w522XUmeeu8eOHhyx59E4DCerI2SoOppoAA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717103848; c=relaxed/simple; bh=t16ycn82rfOPSztiIc8jcmxGPMacvxCGWlBnDHGZdgU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T9epJ3MfNkeIBKl1XK2tSHOCpAmlcIAYUQrgBWMhnzQRKLnkCxSVC/l0645UBNWfwJrJe41PBLOKK0XTaNCS84SE6ohysrSH/dE5hqQ0ocMYafgX7rm6eNTP5Y9+CZSm5uuBeKQdNnD6sOzYI4NCaZ+X9L2UoFJ4Hrv/nBHqg8w= 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=LhiuXrgg; arc=fail smtp.client-ip=40.107.93.62 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="LhiuXrgg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GSDR1m0tqFdcVbXPFNpFS50z6rE0I+CJZzg8GcZ3xI4Au4Zvtb+i17KAxWvOJLaPc0A8a7dGfG29gH6ptP7ntJ1ho2UJb72laXmLmFzrpeCS142ErjH/NaRVjBZrJ+cQKwyKd1U+CAAYwgnVY09so6hcjAT4On4rtXaO2+Xg5vcKQwsbWlQYyWQvhuPqa/k1wFfM7bGbSkr33sDuOJSyOYpb6soEI2fJePuUdZ07MwIf3sTqrA92XVA8XptDLzfH+NdiNHC+s0zlyObFb3M+As3cp5BnvfyqdDIxGtj/5A979S37SDTVXnxxUMZQ43ZdmXBJGdSnnXs2BqsccPnm3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GgZHAoNSlm/cHtBXuLuVAeOrAU0k8QGxE4kas9s/zmU=; b=aB51DspfDIzlx749OJOOZTa8qO2uMAl+1p2xtRanir7TF++6lXzCi0FI3C65aHDfvvyE3l1BFxhjxmvzW20QtZGHDwhmx7FIXdXBkbBpC/kQ4zt3mDQ9BCO918eEWPU/a46Ft3ipkB1maIqwfBOPmZkRSm0QEQ71HL9nDj+1NqCfNEOevV5FXrscQm/BIVongwGcbkm7P6xER3Ru+vGSGnI1/kZ7XnVaumBY3xr/ZGPHlJHa5NDYtgw76PKbXETY/AT5oYXmmrmqeIlO1bnQUei1lPF7GYoErT7g/2unUXU0dWx04UGxm8aIvPy70V8TpbahWzcCohjyD9nyFSkTyw== 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=GgZHAoNSlm/cHtBXuLuVAeOrAU0k8QGxE4kas9s/zmU=; b=LhiuXrggX12la2EdGux+BUNTN95hz2X3pwo/n8DqKfAhvx7fiTsxWK2e522DuccLoKOO8h4CvNMevsbYbIFxXAUSbCtKgxYS0yNCvBG3/SzhoHQVZsQvdfozZRKZVDNMOInSzoWxJ3gAn0G2CtHY4xqXBNVYvPyn54smkWSl7Io= Received: from SN6PR16CA0037.namprd16.prod.outlook.com (2603:10b6:805:ca::14) by SA1PR12MB7295.namprd12.prod.outlook.com (2603:10b6:806:2b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Thu, 30 May 2024 21:17:24 +0000 Received: from SA2PEPF00001506.namprd04.prod.outlook.com (2603:10b6:805:ca:cafe::81) by SN6PR16CA0037.outlook.office365.com (2603:10b6:805:ca::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21 via Frontend Transport; Thu, 30 May 2024 21:17: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001506.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Thu, 30 May 2024 21:17:23 +0000 Received: from titanite-d354host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 May 2024 16:17:20 -0500 From: Avadhut Naik To: , , , CC: , , , , , , , , , , , , , Subject: [PATCH 4/4] EDAC/mce_amd: Add support for FRU Text in MCA Date: Thu, 30 May 2024 16:16:20 -0500 Message-ID: <20240530211620.1829453-5-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240530211620.1829453-1-avadhut.naik@amd.com> References: <20240530211620.1829453-1-avadhut.naik@amd.com> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001506:EE_|SA1PR12MB7295:EE_ X-MS-Office365-Filtering-Correlation-Id: afaddaeb-3131-4368-f658-08dc80ede65b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: 4cmliK0AUjxnzKIO/lkxxYt8wyGHJ4HS7kHWUf3OXgaWFvxbHY+rgO4yDYVh0V9yUTEMjQ2LfYh4PMFNAUa7e5kC0WHhywg6+7p83CG/J+YWxfDHtqhRpVJc8jso/G6/OkDwLHTQND67vgcEtOWNZGP1PrjAIO0pdxjO7plyeRYZq1AuH3S/wnOTh9SjisIM7c36taRq8WWW+iBIabhm7CoBugvmqqfVjCKjW5+onx/nHXIq/HsjiUXGFfJ//caqBc28GegKwbKE3y2HfaQ3DCp6GeT0nAgoa6V5vS8HUXMAr8TwTsLqAl5vV8yLQ5mz2c2swd+9hCPuDmjQe3/Fzl6RS/OHCekhDOhX8fkqGzp1KjhXeM+3KAUW/CbUg8a6ZJjw5VHDzNQ14ZrYDVvgNcLtwvFpBZ0ZlgAxFsVPNQduGX2R6rJfKmzs+RdE4o1NA/djja9i41yknlJKvBQx6wd8WV4LNvlSt4WJ2zhcJRf6XZIq+dPsxe1byjYyeK3eq2aqtqBzfl3oMGxYFp/gif7t07HLEgisjN1Nz5Vyjhy+U5u+7nmEC1NQNOFq0S1Rl13yZVseqbMRUEIOo19/hW1tS7djsuvAmZ4cHNF7u7bwHwTHM286Oz6WUzIpK1VITMtFhORXfGfT1AKsy3o/53o4jysTU606sSV7KE0O3YgJ6yy7RL8zRx5p13j0Its5R6dV22+e8gNzfn88jBpzduDgd8wlwtU3nWWYRBJqDegfoEg6HG6hojyU56bJNbO9syQqDoJjUuFj2mNeHztOSa7+n4sFfcg0E44Pw4hHwjPltrJRFNAP0lomGVxwn2NX9bXeZm2P3dDAd1eGRj0NVGtnakA8BcQg2AWvF/qhzTNoaqrsFG4vPS/yxYnU8aUwpG587AVOCocdt8Tv1P5HvJ5rZeuOydQXoGqjesSDXME5snjeV7E74LvwQDEdluNu5uy8lT96DbZyyGxxE5RoX5aKC+ZfAYSHGeoxJSuJnK++ZtHUzZ+j+vFTq/IfFK3p50GcvSWsSEHdn6U2MF13Ga0fHOHnA+KuxMFoAjjmrOXcQfT7gcSAUQUBxvtxd8V9Zy+bYp/7wY6whcH89BaMXiqIVk+yGIM/J5fs+kg63TCJBHe1sntRYA9+sUbvKUPRtScKSQnFjYQPIeuvBQqPMc4LZNqHHwxjkgoWUo8t9Z5VvdV8LhVK/2lvTl7bIO6ICxzRcipCOR551TlOdjXSfGK5DNcL8EnRESFEezGVgmhcW0RT5elIo4Fua+5xqA38HgVgoc2X44yo1XxGqyMnkHIps2gEFXCSijP3qXWSI+wXO3rl0GNNy8CRBn7n24AdB5we+23Xgc1wBgjjYPKMXeoVJVZ5sWvlvMxaMycYVnlPJfjzXqUoLSmzODENXv3x X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(7416005)(82310400017)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 21:17:23.9533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afaddaeb-3131-4368-f658-08dc80ede65b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001506.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7295 From: Yazen Ghannam A new "FRU Text in MCA" feature is defined where the Field Replaceable Unit (FRU) Text for a device is represented by a string in the new MCA_SYND1 and MCA_SYND2 registers. This feature is supported per MCA bank, and it is advertised by the McaFruTextInMca bit (MCA_CONFIG[9]). The FRU Text is populated dynamically for each individual error state (MCA_STATUS, MCA_ADDR, et al.). This handles the case where an MCA bank covers multiple devices, for example, a Unified Memory Controller (UMC) bank that manages two DIMMs. Print the FRU Text string, if available, when decoding an MCA error. Also, add field for MCA_CONFIG MSR in struct mce_hw_err as vendor specific error information and save the value of the MSR. The very value can then be exported through tracepoint for userspace tools like rasdaemon to print FRU Text, if available. Note: Checkpatch checks/warnings are ignored to maintain coding style. [Yazen: Add Avadhut as co-developer for wrapper changes. ] Co-developed-by: Avadhut Naik Signed-off-by: Avadhut Naik Signed-off-by: Yazen Ghannam --- arch/x86/include/asm/mce.h | 2 ++ arch/x86/kernel/cpu/mce/apei.c | 2 ++ arch/x86/kernel/cpu/mce/core.c | 3 +++ drivers/edac/mce_amd.c | 21 ++++++++++++++------- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 290d32c84ffd..a513a2dce458 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -61,6 +61,7 @@ * - TCC bit is present in MCx_STATUS. */ #define MCI_CONFIG_MCAX 0x1 +#define MCI_CONFIG_FRUTEXT BIT_ULL(9) #define MCI_IPID_MCATYPE 0xFFFF0000 #define MCI_IPID_HWID 0xFFF @@ -199,6 +200,7 @@ struct mce_hw_err { struct { u64 synd1; u64 synd2; + u64 config; } amd; } vi; }; diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 8fd4c42ddc06..2671b3a5f24b 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -154,6 +154,8 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id) fallthrough; /* MCA_CONFIG */ case 4: + err.vi.amd.config = *(i_mce + 3); + fallthrough; /* MCA_MISC0 */ case 3: m->misc = *(i_mce + 2); diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 253d7d0d3331..a2a588c6383e 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -207,6 +207,8 @@ static void __print_mce(struct mce_hw_err *err) pr_cont("SYND2 %llx ", err->vi.amd.synd2); if (m->ipid) pr_cont("IPID %llx ", m->ipid); + if (err->vi.amd.config) + pr_cont("CONFIG %llx ", err->vi.amd.config); } pr_cont("\n"); @@ -680,6 +682,7 @@ static noinstr void mce_read_aux(struct mce_hw_err *err, int i) if (mce_flags.smca) { m->ipid = mce_rdmsrl(MSR_AMD64_SMCA_MCx_IPID(i)); + err->vi.amd.config = mce_rdmsrl(MSR_AMD64_SMCA_MCx_CONFIG(i)); if (m->status & MCI_STATUS_SYNDV) { m->synd = mce_rdmsrl(MSR_AMD64_SMCA_MCx_SYND(i)); diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c index 69e12cb2f0de..6ae6b89b1a1e 100644 --- a/drivers/edac/mce_amd.c +++ b/drivers/edac/mce_amd.c @@ -795,6 +795,7 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) struct mce_hw_err *err = (struct mce_hw_err *)data; struct mce *m = &err->m; unsigned int fam = x86_family(m->cpuid); + u64 mca_config = err->vi.amd.config; int ecc; if (m->kflags & MCE_HANDLED_CEC) @@ -814,11 +815,7 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) ((m->status & MCI_STATUS_PCC) ? "PCC" : "-")); if (boot_cpu_has(X86_FEATURE_SMCA)) { - u32 low, high; - u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank); - - if (!rdmsr_safe(addr, &low, &high) && - (low & MCI_CONFIG_MCAX)) + if (mca_config & MCI_CONFIG_MCAX) pr_cont("|%s", ((m->status & MCI_STATUS_TCC) ? "TCC" : "-")); pr_cont("|%s", ((m->status & MCI_STATUS_SYNDV) ? "SyndV" : "-")); @@ -853,8 +850,18 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) if (m->status & MCI_STATUS_SYNDV) { pr_cont(", Syndrome: 0x%016llx\n", m->synd); - pr_emerg(HW_ERR "Syndrome1: 0x%016llx, Syndrome2: 0x%016llx", - err->vi.amd.synd1, err->vi.amd.synd2); + if (mca_config & MCI_CONFIG_FRUTEXT) { + char frutext[17]; + + memset(frutext, 0, sizeof(frutext)); + memcpy(&frutext[0], &err->vi.amd.synd1, 8); + memcpy(&frutext[8], &err->vi.amd.synd2, 8); + + pr_emerg(HW_ERR "FRU Text: %s", frutext); + } else { + pr_emerg(HW_ERR "Syndrome1: 0x%016llx, Syndrome2: 0x%016llx", + err->vi.amd.synd1, err->vi.amd.synd2); + } } pr_cont("\n");