From nobody Tue Nov 26 03:36:54 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2048.outbound.protection.outlook.com [40.107.244.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42F281CC14A; Tue, 22 Oct 2024 19:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729626150; cv=fail; b=XNSlKiuIsXSR8Z0NkXkC4Xvvj0fKSsJ9+t0ZDPWJIaX+NTuik2AXpcznYn+/ehF9YxDkY7Of/C58yZw7DSxhoyRGdZJZ19uYJAH1VEHkpe9YyVDq2ciCTqgqzKfEukN+nk5qM3muhupJEOp+z3jZQdvsci5QIG1tXcTmomYflkM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729626150; c=relaxed/simple; bh=4nPfytFfs0fUdUKwTT1sdXCg8lpanij18tR7H9Lv9VM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F3JAFM9rEqf//pfxd85p+O+Uj3fazX6SrRPcw8jJQDVqx0N0Qrf9gC7g2OjJFtuwOIp5LPd48/B1nsejGTYQcoXoPYcZ52dfQj7p368EcLkFDRtZM9fOOzVCkQxGL9OZkz294mInyTjjIocz6Zh0/MV3H2atTsXYnn2nVwxEwc8= 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=NmXtA3AT; arc=fail smtp.client-ip=40.107.244.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NmXtA3AT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FBsBV1vQO9NmyASoraTZFDdFlbJXn7Ugci+pO0rDgkrRXsDyaauJrTmNGqV40VmPG/YltRjwP7+6RWP3ZkAHy2S7CcxTKW63A1DLvg+GL1bxl6dGbgLxdCQLNw1PQ+DMN9UjLZjGQoA00zxmKek3IFVcXlSaHXaOwMqprez/h4JURorzC5jo3agUFx7C/IbrCp3xqIAPC0FpyAzbX/oPbMVEz7iJyEUHwzqluJ89dYYIFOyDgcdV32/fgfFNsuvwrdwt4iZQ8V/bTMra5NxxuiVWav857NFygPGbHA/CZvMNOs7EiiqLaqpmyFVhtpCnoVKhitWcrgwC6Wzs1fRIvw== 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=5qwq7ASx72wjqzeBiLbVokMHlbl2rbE3owj26lgsgMM=; b=NcaRrD/wHGhAECJ4yt+WvfuUwskOFdM98B7YwyBhx92sis+w7LAhXZN4Ypsa/g3ZQuLHN17pDvNtEL3qaSkFWqIHLLMTydLmLIszvub828t2h0hhD8aIjoiOTCX9C2rNKHm81QtSybw0pgrxW/u4maKwEgspK4ia2kHUS2vAKxNAGJ3VljjCaORiPbwae8NUoE5Fx9cQwHoHOsLOUD4PmBU7+OUp2ltfwFJVcE4k3Pg9TD2mm29AFVXaror6/HOIAd1P+h7thBY7eQKSpbTvs/EmXSFeXs/jhK8IJ7hr2RdyQ+QM6iY6wznscoYUgzuP5ZGGVm2CQcBuA0J/1i1AUg== 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=5qwq7ASx72wjqzeBiLbVokMHlbl2rbE3owj26lgsgMM=; b=NmXtA3ATPmsLxD/y5WyGhl+hs0iH1qJc18iXQ7ZoHYpfVeMehEqwEP+d3nEXjUvtBgbbCQz1VOguW8AZQB9G7zPFSPg3D4VMhXs9GmN1+iH2CNZBXUSTz+qkMI27BTl53vgUHA+2KPODLmbZ8AyJrjI/nUxFRolryus/2MQLesA= Received: from SJ0PR05CA0172.namprd05.prod.outlook.com (2603:10b6:a03:339::27) by DS0PR12MB9060.namprd12.prod.outlook.com (2603:10b6:8:c4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 19:42:23 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:a03:339:cafe::df) by SJ0PR05CA0172.outlook.office365.com (2603:10b6:a03:339::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 19:42:22 +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 MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 19:42:22 +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.39; Tue, 22 Oct 2024 14:42:20 -0500 From: Avadhut Naik To: , , CC: , , , , , , , , , , Subject: [PATCH v7 1/5] x86/mce: Add wrapper for struct mce to export vendor specific info Date: Tue, 22 Oct 2024 19:36:27 +0000 Message-ID: <20241022194158.110073-2-avadhut.naik@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022194158.110073-1-avadhut.naik@amd.com> References: <20241022194158.110073-1-avadhut.naik@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|DS0PR12MB9060:EE_ X-MS-Office365-Filtering-Correlation-Id: a7dcc792-8cb0-445f-550b-08dcf2d1a5ee 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: =?us-ascii?Q?qdyBm9BDNipjPJc47dkIzzB+H5YYSPlVxr9tzUYpRJ1EWjwX0qkT8yJ4mdGT?= =?us-ascii?Q?mtH4mGvm1yl6bKJjkDeylKHO4XWCOyeNfIXH2Ijgbz2tULT54+3sl6I94ey+?= =?us-ascii?Q?wjYab+TCWZWG9I/A9LAIrW16voIdVvGtEtxWzITeirHow9KYJ1paEvmN/Ts7?= =?us-ascii?Q?PkjWxIbU3sePyvAD3Mi06BCY1zVD3wKwcKo6zBnaY3R4BwFxBw/C5c3bh5KJ?= =?us-ascii?Q?QsdGcM47DPws6E63teknFiCCB2H89LdSqVHQe9ugc45ZZtr7WVu7aadTFm4T?= =?us-ascii?Q?fiSgsRQ/qMoRmsaR1IlM6ALnhwxV4Mqm/vDFKOJVf6epjE5gsjxO6LSrvSj4?= =?us-ascii?Q?U8hAXW0C9JWMk81lzkftdj7EGS4QFd+Kfohm1Am2RD1aeIMA0hNMipD9PGpT?= =?us-ascii?Q?oOXv5Xu+Zp8OBEnkaw+o0BDKiA+nQKbPfSByLghYEJlssk3lmTsTzoGEJUBG?= =?us-ascii?Q?N0lOwbDqdPivU09uK+6DeHHZuvhRKD633qFWR8voCeQjcsn8AuXoZpSWgS63?= =?us-ascii?Q?si3TyiRx2WNkqgVq3jO+QVUua0g97yfiIeXyLPaVzAElcUI5YfwL25FYBzu1?= =?us-ascii?Q?clJZRLO245hHGMoi6yAyYuBB6iMJ3xdmql43uHFVjv8M0LQyZHKyGgrQTutp?= =?us-ascii?Q?V/BHCPpXuO42YP+cwNPkndgj0ULzi7T9LX1hzQPwmedpXeJrjiWMs3ooFMu9?= =?us-ascii?Q?nW7Z4ryDT80wqoYNdXqLiXqjJwn6cMtc1dDEXzx4LVYaXVYq03JPAbMNKl4d?= =?us-ascii?Q?K5VoSuZNjYRsOQ0v5vIontiRhSG0QnYRGjIM8qld7cblTQeFNpSphoImWpJS?= =?us-ascii?Q?KIZbKHKqG7gitEYSiqyNmObHxcsPDPDRr8pN4z16eBoutdWJeTa+UPKloOds?= =?us-ascii?Q?kiNBiHnARX7lyGGfuAvdRt32bbGCauEvJlDML8U1HM0ZyMq/UAipJ1jrja1x?= =?us-ascii?Q?y3kTPmYf1pNH6UBKhwADNKuPNASUJcimIUd5AZZy8/YztoaAuh8Ub1nAjo6C?= =?us-ascii?Q?76herrSbDUMcc2jUY/SowNEmTACQjdrG8rt/mbjC5yLik2AhYPMexZO5+qmy?= =?us-ascii?Q?/qUb2iydfElJAkDgEKtOCkbhYP6JMfSo/rp8LkfNG/pUrY6JO6foH0txR+ZU?= =?us-ascii?Q?7nhIfCAdobODmZygtpGXynm34fcuhVRCxUiR2ViG9suYALbrEbxxpz1YgcEN?= =?us-ascii?Q?APWVV2DG8RVHDd9CQXSzqGg2QpnZ7wk3doozMjQA3icphthGpILYxWJQMnnm?= =?us-ascii?Q?W8JxU7nO2jhy0OGWoVVgz6TqF0IDAuh7toZRhRhXzr4YHZLV50E5LGY/Eerg?= =?us-ascii?Q?NFFtli+QXGyQ6fNO4SE1MHUUc7PciKTSf2HtaYqQQ51353YaVW73aBQw+S/A?= =?us-ascii?Q?TA3RGUajd1W5/3TeH3fCZcIhsZq1+yWLnTLQlX/sCrHytotgHBr3MqXh0Cj9?= =?us-ascii?Q?kJP327455fk=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 19:42:22.3839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7dcc792-8cb0-445f-550b-08dcf2d1a5ee 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: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9060 Content-Type: text/plain; charset="utf-8" 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. [Yazen: Add last commit message paragraph.] Suggested-by: Borislav Petkov (AMD) Signed-off-by: Avadhut Naik Signed-off-by: Yazen Ghannam Signed-off-by: Avadhut Naik --- Changes in v2: [1] https://lore.kernel.org/linux-edac/20240521125434.1555845-1-yazen.ghann= am@amd.com/ [2] https://lore.kernel.org/linux-edac/20240523155641.2805411-1-yazen.ghann= am@amd.com/ 1. Drop dependencies on sets [1] and [2] above and rebase on top of tip/master. Changes in v3: 1. Move wrapper changes required in mce_read_aux() and mce_no_way_out() to this patch from the second patch. 2. Fix SoB chain to properly reflect the patch path. Changes in v4: 1. Rebase on of tip/master to avoid merge conflicts. 2. Resolve kernel test robot's warning on the use of memset() in do_machine_check(). Changes in v5: 1. No changes except rebasing on top of tip/master. Changes in v6: 1. Rebase on top of tip/master. 2. Introduce to_mce_hw_err macro to eliminate changes required in notifier chain callback functions, especially callback functions of EDAC drivers. 3. Change third parameter of __mc_scan_banks() to a pointer to the new wrapper structure and make the required changes accordingly. Changes in v7: 1. Rebase on top of tip/master. 2. Fix initialization of struct mce_hw_err *final in do_machine_check(). --- arch/x86/include/asm/mce.h | 14 +- arch/x86/kernel/cpu/mce/amd.c | 27 ++-- arch/x86/kernel/cpu/mce/apei.c | 45 ++++--- arch/x86/kernel/cpu/mce/core.c | 205 ++++++++++++++++------------- arch/x86/kernel/cpu/mce/genpool.c | 18 +-- arch/x86/kernel/cpu/mce/inject.c | 4 +- arch/x86/kernel/cpu/mce/internal.h | 4 +- include/trace/events/mce.h | 42 +++--- 8 files changed, 200 insertions(+), 159 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 3b9970117a0f..4e45f45673a3 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -187,6 +187,16 @@ enum mce_notifier_prios { MCE_PRIO_HIGHEST =3D MCE_PRIO_CEC }; =20 +/** + * struct mce_hw_err - Hardware Error Record. + * @m: Machine Check record. + */ +struct mce_hw_err { + struct mce m; +}; + +#define to_mce_hw_err(mce) container_of(mce, struct mce_hw_err, m) + struct notifier_block; extern void mce_register_decode_chain(struct notifier_block *nb); extern void mce_unregister_decode_chain(struct notifier_block *nb); @@ -221,8 +231,8 @@ static inline int apei_smca_report_x86_error(struct cpe= r_ia_proc_ctx *ctx_info, u64 lapic_id) { return -EINVAL; } #endif =20 -void mce_prep_record(struct mce *m); -void mce_log(struct mce *m); +void mce_prep_record(struct mce_hw_err *err); +void mce_log(struct mce_hw_err *err); DECLARE_PER_CPU(struct device *, mce_device); =20 /* Maximum number of MCA banks per CPU. */ diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 14bf8c232e45..5b4d266500b2 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -778,29 +778,30 @@ bool amd_mce_usable_address(struct mce *m) =20 static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) { - struct mce m; + struct mce_hw_err err; + struct mce *m =3D &err.m; =20 - mce_prep_record(&m); + mce_prep_record(&err); =20 - m.status =3D status; - m.misc =3D misc; - m.bank =3D bank; - m.tsc =3D rdtsc(); + m->status =3D status; + m->misc =3D misc; + m->bank =3D bank; + m->tsc =3D rdtsc(); =20 - if (m.status & MCI_STATUS_ADDRV) { - m.addr =3D addr; + if (m->status & MCI_STATUS_ADDRV) { + m->addr =3D addr; =20 - smca_extract_err_addr(&m); + smca_extract_err_addr(m); } =20 if (mce_flags.smca) { - rdmsrl(MSR_AMD64_SMCA_MCx_IPID(bank), m.ipid); + rdmsrl(MSR_AMD64_SMCA_MCx_IPID(bank), m->ipid); =20 - if (m.status & MCI_STATUS_SYNDV) - rdmsrl(MSR_AMD64_SMCA_MCx_SYND(bank), m.synd); + if (m->status & MCI_STATUS_SYNDV) + rdmsrl(MSR_AMD64_SMCA_MCx_SYND(bank), m->synd); } =20 - mce_log(&m); + mce_log(&err); } =20 DEFINE_IDTENTRY_SYSVEC(sysvec_deferred_error) diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c index 3885fe05f01e..7f582b4ca1ca 100644 --- a/arch/x86/kernel/cpu/mce/apei.c +++ b/arch/x86/kernel/cpu/mce/apei.c @@ -28,7 +28,8 @@ =20 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; int lsb; =20 if (!(mem_err->validation_bits & CPER_MEM_VALID_PA)) @@ -44,22 +45,23 @@ void apei_mce_report_mem_error(int severity, struct cpe= r_sec_mem_err *mem_err) else lsb =3D PAGE_SHIFT; =20 - mce_prep_record(&m); - m.bank =3D -1; + mce_prep_record(&err); + m =3D &err.m; + m->bank =3D -1; /* Fake a memory read error with unknown channel */ - m.status =3D MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | MCI_STAT= US_MISCV | 0x9f; - m.misc =3D (MCI_MISC_ADDR_PHYS << 6) | lsb; + m->status =3D MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | MCI_STA= TUS_MISCV | 0x9f; + m->misc =3D (MCI_MISC_ADDR_PHYS << 6) | lsb; =20 if (severity >=3D GHES_SEV_RECOVERABLE) - m.status |=3D MCI_STATUS_UC; + m->status |=3D MCI_STATUS_UC; =20 if (severity >=3D GHES_SEV_PANIC) { - m.status |=3D MCI_STATUS_PCC; - m.tsc =3D rdtsc(); + m->status |=3D MCI_STATUS_PCC; + m->tsc =3D rdtsc(); } =20 - m.addr =3D mem_err->physical_addr; - mce_log(&m); + m->addr =3D mem_err->physical_addr; + mce_log(&err); } EXPORT_SYMBOL_GPL(apei_mce_report_mem_error); =20 @@ -67,8 +69,9 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *c= tx_info, u64 lapic_id) { const u64 *i_mce =3D ((const u64 *) (ctx_info + 1)); bool apicid_found =3D false; + struct mce_hw_err err; unsigned int cpu; - struct mce m; + struct mce *m; =20 if (!boot_cpu_has(X86_FEATURE_SMCA)) return -EINVAL; @@ -108,18 +111,20 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ct= x *ctx_info, u64 lapic_id) if (!apicid_found) return -EINVAL; =20 - mce_prep_record_common(&m); - mce_prep_record_per_cpu(cpu, &m); + m =3D &err.m; + memset(&err, 0, sizeof(struct mce_hw_err)); + mce_prep_record_common(m); + mce_prep_record_per_cpu(cpu, m); =20 - m.bank =3D (ctx_info->msr_addr >> 4) & 0xFF; - m.status =3D *i_mce; - m.addr =3D *(i_mce + 1); - m.misc =3D *(i_mce + 2); + m->bank =3D (ctx_info->msr_addr >> 4) & 0xFF; + m->status =3D *i_mce; + m->addr =3D *(i_mce + 1); + m->misc =3D *(i_mce + 2); /* Skipping MCA_CONFIG */ - m.ipid =3D *(i_mce + 4); - m.synd =3D *(i_mce + 5); + m->ipid =3D *(i_mce + 4); + m->synd =3D *(i_mce + 5); =20 - mce_log(&m); + mce_log(&err); =20 return 0; } diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 2a938f429c4d..3611366d56b7 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 =3D { .monarch_timeout =3D -1 }; =20 -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; =20 /* @@ -119,8 +119,6 @@ BLOCKING_NOTIFIER_HEAD(x86_mce_decoder_chain); =20 void mce_prep_record_common(struct mce *m) { - memset(m, 0, sizeof(struct mce)); - m->cpuid =3D cpuid_eax(1); m->cpuvendor =3D boot_cpu_data.x86_vendor; m->mcgcap =3D __rdmsr(MSR_IA32_MCG_CAP); @@ -138,9 +136,12 @@ void mce_prep_record_per_cpu(unsigned int cpu, struct = mce *m) m->socketid =3D topology_physical_package_id(cpu); } =20 -/* Do initial initialization of a struct mce */ -void mce_prep_record(struct mce *m) +/* Do initial initialization of struct mce_hw_err */ +void mce_prep_record(struct mce_hw_err *err) { + struct mce *m =3D &err->m; + + memset(err, 0, sizeof(struct mce_hw_err)); mce_prep_record_common(m); mce_prep_record_per_cpu(smp_processor_id(), m); } @@ -148,9 +149,9 @@ void mce_prep_record(struct mce *m) DEFINE_PER_CPU(struct mce, injectm); EXPORT_PER_CPU_SYMBOL_GPL(injectm); =20 -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 +172,10 @@ void mce_unregister_decode_chain(struct notifier_block= *nb) } EXPORT_SYMBOL_GPL(mce_unregister_decode_chain); =20 -static void __print_mce(struct mce *m) +static void __print_mce(struct mce_hw_err *err) { + struct mce *m =3D &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 +217,11 @@ static void __print_mce(struct mce *m) m->microcode); } =20 -static void print_mce(struct mce *m) +static void print_mce(struct mce_hw_err *err) { - __print_mce(m); + struct mce *m =3D &err->m; + + __print_mce(err); =20 if (m->cpuvendor !=3D X86_VENDOR_AMD && m->cpuvendor !=3D X86_VENDOR_HYGO= N) pr_emerg_ratelimited(HW_ERR "Run the above through 'mcelog --ascii'\n"); @@ -251,7 +256,7 @@ static const char *mce_dump_aux_info(struct mce *m) return NULL; } =20 -static noinstr void mce_panic(const char *msg, struct mce *final, char *ex= p) +static noinstr void mce_panic(const char *msg, struct mce_hw_err *final, c= har *exp) { struct llist_node *pending; struct mce_evt_llist *l; @@ -282,20 +287,22 @@ static noinstr void mce_panic(const char *msg, struct= mce *final, char *exp) pending =3D mce_gen_pool_prepare_records(); /* First print corrected ones that are still unlogged */ llist_for_each_entry(l, pending, llnode) { - struct mce *m =3D &l->mce; + struct mce_hw_err *err =3D &l->err; + struct mce *m =3D &err->m; if (!(m->status & MCI_STATUS_UC)) { - print_mce(m); + print_mce(err); if (!apei_err) apei_err =3D apei_write_mce(m); } } /* Now print uncorrected but with the final one last */ llist_for_each_entry(l, pending, llnode) { - struct mce *m =3D &l->mce; + struct mce_hw_err *err =3D &l->err; + struct mce *m =3D &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 =3D apei_write_mce(m); } @@ -303,12 +310,12 @@ static noinstr void mce_panic(const char *msg, struct= mce *final, char *exp) if (final) { print_mce(final); if (!apei_err) - apei_err =3D apei_write_mce(final); + apei_err =3D apei_write_mce(&final->m); } if (exp) pr_emerg(HW_ERR "Machine check: %s\n", exp); =20 - memmsg =3D mce_dump_aux_info(final); + memmsg =3D mce_dump_aux_info(&final->m); if (memmsg) pr_emerg(HW_ERR "Machine check: %s\n", memmsg); =20 @@ -323,9 +330,9 @@ static noinstr void mce_panic(const char *msg, struct m= ce *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 =3D pfn_to_online_page(final->addr >> PAGE_SHIFT); + p =3D pfn_to_online_page(final->m.addr >> PAGE_SHIFT); if (p) SetPageHWPoison(p); } @@ -445,16 +452,18 @@ static noinstr void mce_wrmsrl(u32 msr, u64 v) * check into our "mce" struct so that we can use it later to assess * the severity of the problem as we read per-bank specific details. */ -static noinstr void mce_gather_info(struct mce *m, struct pt_regs *regs) +static noinstr void mce_gather_info(struct mce_hw_err *err, struct pt_regs= *regs) { + struct mce *m; /* * Enable instrumentation around mce_prep_record() which calls external * facilities. */ instrumentation_begin(); - mce_prep_record(m); + mce_prep_record(err); instrumentation_end(); =20 + m =3D &err->m; m->mcgstatus =3D mce_rdmsrl(MSR_IA32_MCG_STATUS); if (regs) { /* @@ -574,13 +583,13 @@ EXPORT_SYMBOL_GPL(mce_is_correctable); static int mce_early_notifier(struct notifier_block *nb, unsigned long val, void *data) { - struct mce *m =3D (struct mce *)data; + struct mce_hw_err *err =3D to_mce_hw_err(data); =20 - if (!m) + if (!err) return NOTIFY_DONE; =20 /* Emit the trace record: */ - trace_mce_record(m); + trace_mce_record(err); =20 set_bit(0, &mce_need_notify); =20 @@ -624,13 +633,13 @@ static struct notifier_block mce_uc_nb =3D { static int mce_default_notifier(struct notifier_block *nb, unsigned long v= al, void *data) { - struct mce *m =3D (struct mce *)data; + struct mce_hw_err *err =3D to_mce_hw_err(data); =20 - if (!m) + if (!err) return NOTIFY_DONE; =20 - if (mca_cfg.print_all || !m->kflags) - __print_mce(m); + if (mca_cfg.print_all || !(err->m.kflags)) + __print_mce(err); =20 return NOTIFY_DONE; } @@ -644,8 +653,10 @@ static struct notifier_block mce_default_nb =3D { /* * 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 =3D &err->m; + if (m->status & MCI_STATUS_MISCV) m->misc =3D mce_rdmsrl(mca_msr_reg(i, MCA_MISC)); =20 @@ -692,26 +703,28 @@ DEFINE_PER_CPU(unsigned, mce_poll_count); void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) { struct mce_bank *mce_banks =3D this_cpu_ptr(mce_banks_array); - struct mce m; + struct mce_hw_err err; + struct mce *m; int i; =20 this_cpu_inc(mce_poll_count); =20 - mce_gather_info(&m, NULL); + mce_gather_info(&err, NULL); + m =3D &err.m; =20 if (flags & MCP_TIMESTAMP) - m.tsc =3D rdtsc(); + m->tsc =3D rdtsc(); =20 for (i =3D 0; i < this_cpu_read(mce_num_banks); i++) { if (!mce_banks[i].ctl || !test_bit(i, *b)) continue; =20 - m.misc =3D 0; - m.addr =3D 0; - m.bank =3D i; + m->misc =3D 0; + m->addr =3D 0; + m->bank =3D i; =20 barrier(); - m.status =3D mce_rdmsrl(mca_msr_reg(i, MCA_STATUS)); + m->status =3D mce_rdmsrl(mca_msr_reg(i, MCA_STATUS)); =20 /* * Update storm tracking here, before checking for the @@ -721,17 +734,17 @@ void machine_check_poll(enum mcp_flags flags, mce_ban= ks_t *b) * storm status. */ if (!mca_cfg.cmci_disabled) - mce_track_storm(&m); + mce_track_storm(m); =20 /* If this entry is not valid, ignore it */ - if (!(m.status & MCI_STATUS_VAL)) + if (!(m->status & MCI_STATUS_VAL)) continue; =20 /* * If we are logging everything (at CPU online) or this * is a corrected error, then we must log it. */ - if ((flags & MCP_UC) || !(m.status & MCI_STATUS_UC)) + if ((flags & MCP_UC) || !(m->status & MCI_STATUS_UC)) goto log_it; =20 /* @@ -741,20 +754,20 @@ void machine_check_poll(enum mcp_flags flags, mce_ban= ks_t *b) * everything else. */ if (!mca_cfg.ser) { - if (m.status & MCI_STATUS_UC) + if (m->status & MCI_STATUS_UC) continue; goto log_it; } =20 /* Log "not enabled" (speculative) errors */ - if (!(m.status & MCI_STATUS_EN)) + if (!(m->status & MCI_STATUS_EN)) goto log_it; =20 /* * Log UCNA (SDM: 15.6.3 "UCR Error Classification") * UC =3D=3D 1 && PCC =3D=3D 0 && S =3D=3D 0 */ - if (!(m.status & MCI_STATUS_PCC) && !(m.status & MCI_STATUS_S)) + if (!(m->status & MCI_STATUS_PCC) && !(m->status & MCI_STATUS_S)) goto log_it; =20 /* @@ -768,20 +781,20 @@ void machine_check_poll(enum mcp_flags flags, mce_ban= ks_t *b) if (flags & MCP_DONTLOG) goto clear_it; =20 - mce_read_aux(&m, i); - m.severity =3D mce_severity(&m, NULL, NULL, false); + mce_read_aux(&err, i); + m->severity =3D 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. */ =20 - if (mca_cfg.dont_log_ce && !mce_usable_address(&m)) + if (mca_cfg.dont_log_ce && !mce_usable_address(m)) goto clear_it; =20 if (flags & MCP_QUEUE_LOG) - mce_gen_pool_add(&m); + mce_gen_pool_add(&err); else - mce_log(&m); + mce_log(&err); =20 clear_it: /* @@ -905,9 +918,10 @@ static __always_inline void quirk_zen_ifu(int bank, st= ruct 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, unsig= ned long *validp, +static __always_inline int mce_no_way_out(struct mce_hw_err *err, char **m= sg, unsigned long *validp, struct pt_regs *regs) { + struct mce *m =3D &err->m; char *tmp =3D *msg; int i; =20 @@ -925,7 +939,7 @@ static __always_inline int mce_no_way_out(struct mce *m= , char **msg, unsigned lo =20 m->bank =3D i; if (mce_severity(m, regs, &tmp, true) >=3D MCE_PANIC_SEVERITY) { - mce_read_aux(m, i); + mce_read_aux(err, i); *msg =3D tmp; return 1; } @@ -1017,6 +1031,7 @@ static noinstr int mce_timed_out(u64 *t, const char *= msg) static void mce_reign(void) { int cpu; + struct mce_hw_err *err =3D NULL; struct mce *m =3D NULL; int global_worst =3D 0; char *msg =3D NULL; @@ -1027,11 +1042,13 @@ static void mce_reign(void) * Grade the severity of the errors of all the CPUs. */ for_each_possible_cpu(cpu) { - struct mce *mtmp =3D &per_cpu(mces_seen, cpu); + struct mce_hw_err *etmp =3D &per_cpu(hw_errs_seen, cpu); + struct mce *mtmp =3D &etmp->m; =20 if (mtmp->severity > global_worst) { global_worst =3D mtmp->severity; - m =3D &per_cpu(mces_seen, cpu); + err =3D &per_cpu(hw_errs_seen, cpu); + m =3D &err->m; } } =20 @@ -1043,7 +1060,7 @@ static void mce_reign(void) if (m && global_worst >=3D 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); } =20 /* @@ -1060,11 +1077,11 @@ static void mce_reign(void) mce_panic("Fatal machine check from unknown source", NULL, NULL); =20 /* - * 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)); } =20 static atomic_t global_nwo; @@ -1268,12 +1285,13 @@ static noinstr bool mce_check_crashing_cpu(void) } =20 static __always_inline int -__mc_scan_banks(struct mce *m, struct pt_regs *regs, struct mce *final, - unsigned long *toclear, unsigned long *valid_banks, int no_way_out, - int *worst) +__mc_scan_banks(struct mce_hw_err *err, struct pt_regs *regs, + struct mce_hw_err *final, unsigned long *toclear, + unsigned long *valid_banks, int no_way_out, int *worst) { struct mce_bank *mce_banks =3D this_cpu_ptr(mce_banks_array); struct mca_config *cfg =3D &mca_cfg; + struct mce *m =3D &err->m; int severity, i, taint =3D 0; =20 for (i =3D 0; i < this_cpu_read(mce_num_banks); i++) { @@ -1319,7 +1337,7 @@ __mc_scan_banks(struct mce *m, struct pt_regs *regs, = struct mce *final, if (severity =3D=3D MCE_NO_SEVERITY) continue; =20 - mce_read_aux(m, i); + mce_read_aux(err, i); =20 /* assuming valid severity level !=3D 0 */ m->severity =3D severity; @@ -1329,17 +1347,17 @@ __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(); =20 if (severity > *worst) { - *final =3D *m; + *final =3D *err; *worst =3D severity; } } =20 /* mce_clear_state will clear *final, save locally for use later */ - *m =3D *final; + *err =3D *final; =20 return taint; } @@ -1399,8 +1417,9 @@ static void kill_me_never(struct callback_head *cb) set_mce_nospec(pfn); } =20 -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 =3D &err->m; int count =3D ++current->mce_count; =20 /* First call, save all the details */ @@ -1414,11 +1433,12 @@ static void queue_task_work(struct mce *m, char *ms= g, void (*func)(struct callba =20 /* 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); =20 /* Second or later call, make sure page address matches the one from firs= t call */ if (count > 1 && (current->mce_addr >> PAGE_SHIFT) !=3D (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= ); =20 /* Do not call task_work_add() more than once */ if (count > 1) @@ -1467,8 +1487,10 @@ noinstr void do_machine_check(struct pt_regs *regs) int worst =3D 0, order, no_way_out, kill_current_task, lmce, taint =3D 0; DECLARE_BITMAP(valid_banks, MAX_NR_BANKS) =3D { 0 }; DECLARE_BITMAP(toclear, MAX_NR_BANKS) =3D { 0 }; - struct mce m, *final; + struct mce_hw_err *final; + struct mce_hw_err err; char *msg =3D NULL; + struct mce *m; =20 if (unlikely(mce_flags.p5)) return pentium_machine_check(regs); @@ -1506,13 +1528,14 @@ noinstr void do_machine_check(struct pt_regs *regs) =20 this_cpu_inc(mce_exception_count); =20 - mce_gather_info(&m, regs); - m.tsc =3D rdtsc(); + mce_gather_info(&err, regs); + m =3D &err.m; + m->tsc =3D rdtsc(); =20 - final =3D this_cpu_ptr(&mces_seen); - *final =3D m; + final =3D this_cpu_ptr(&hw_errs_seen); + *final =3D err; =20 - no_way_out =3D mce_no_way_out(&m, &msg, valid_banks, regs); + no_way_out =3D mce_no_way_out(&err, &msg, valid_banks, regs); =20 barrier(); =20 @@ -1521,15 +1544,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 =3D 1; /* * Check if this MCE is signaled to only this logical processor, * on Intel, Zhaoxin only. */ - if (m.cpuvendor =3D=3D X86_VENDOR_INTEL || - m.cpuvendor =3D=3D X86_VENDOR_ZHAOXIN) - lmce =3D m.mcgstatus & MCG_STATUS_LMCES; + if (m->cpuvendor =3D=3D X86_VENDOR_INTEL || + m->cpuvendor =3D=3D X86_VENDOR_ZHAOXIN) + lmce =3D m->mcgstatus & MCG_STATUS_LMCES; =20 /* * Local machine check may already know that we have to panic. @@ -1540,12 +1563,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 =3D mce_start(&no_way_out); } =20 - taint =3D __mc_scan_banks(&m, regs, final, toclear, valid_banks, no_way_o= ut, &worst); + taint =3D __mc_scan_banks(&err, regs, final, toclear, valid_banks, no_way= _out, &worst); =20 if (!no_way_out) mce_clear_state(toclear); @@ -1560,7 +1583,7 @@ noinstr void do_machine_check(struct pt_regs *regs) no_way_out =3D worst >=3D MCE_PANIC_SEVERITY; =20 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 { /* @@ -1572,8 +1595,8 @@ noinstr void do_machine_check(struct pt_regs *regs) * make sure we have the right "msg". */ if (worst >=3D 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); } } =20 @@ -1591,16 +1614,16 @@ noinstr void do_machine_check(struct pt_regs *regs) goto out; =20 /* Fault was in user mode and we need to take some action */ - if ((m.cs & 3) =3D=3D 3) { + if ((m->cs & 3) =3D=3D 3) { /* If this triggers there is no way to recover. Die hard. */ BUG_ON(!on_thread_stack() || !user_mode(regs)); =20 - 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); =20 - } 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 @@ -1612,8 +1635,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 =3D pfn_to_online_page(m.addr >> PAGE_SHIFT); + if (mce_usable_address(m)) { + struct page *p =3D pfn_to_online_page(m->addr >> PAGE_SHIFT); =20 if (p) SetPageHWPoison(p); @@ -1628,13 +1651,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); } =20 - 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); } =20 out: diff --git a/arch/x86/kernel/cpu/mce/genpool.c b/arch/x86/kernel/cpu/mce/ge= npool.c index 4284749ec803..504d89724ecd 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_ev= t_llist *l) { + struct mce_hw_err *err1, *err2; struct mce_evt_llist *node; - struct mce *m1, *m2; =20 - m1 =3D &t->mce; + err1 =3D &t->err; =20 llist_for_each_entry(node, &l->llnode, llnode) { - m2 =3D &node->mce; + err2 =3D &node->err; =20 - 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) =20 void mce_gen_pool_process(struct work_struct *__unused) { + struct mce *mce; struct llist_node *head; struct mce_evt_llist *node, *tmp; - struct mce *mce; =20 head =3D llist_del_all(&mce_event_llist); if (!head) @@ -83,7 +83,7 @@ void mce_gen_pool_process(struct work_struct *__unused) =20 head =3D llist_reverse_order(head); llist_for_each_entry_safe(node, tmp, head, llnode) { - mce =3D &node->mce; + mce =3D &node->err.m; blocking_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); 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); } =20 -int mce_gen_pool_add(struct mce *mce) +int mce_gen_pool_add(struct mce_hw_err *err) { struct mce_evt_llist *node; =20 - if (filter_mce(mce)) + if (filter_mce(&err->m)) return -EINVAL; =20 if (!mce_evt_pool) @@ -110,7 +110,7 @@ int mce_gen_pool_add(struct mce *mce) return -ENOMEM; } =20 - memcpy(&node->mce, mce, sizeof(*mce)); + memcpy(&node->err, err, sizeof(*err)); llist_add(&node->llnode, &mce_event_llist); =20 return 0; diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inj= ect.c index 49ed3428785d..c65a5c4e2f22 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) =20 static void do_inject(void) { + struct mce_hw_err err; u64 mcg_status =3D 0; unsigned int cpu =3D i_mce.extcpu; u8 b =3D i_mce.bank; @@ -517,7 +518,8 @@ static void do_inject(void) i_mce.status |=3D MCI_STATUS_SYNDV; =20 if (inj_type =3D=3D SW_INJ) { - mce_log(&i_mce); + err.m =3D i_mce; + mce_log(&err); return; } =20 diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/i= nternal.h index 43c7f3b71df5..84f810598231 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_ch= ain; =20 struct mce_evt_llist { struct llist_node llnode; - struct mce mce; + struct mce_hw_err err; }; =20 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); =20 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 @@ =20 TRACE_EVENT(mce_record, =20 - TP_PROTO(struct mce *m), + TP_PROTO(struct mce_hw_err *err), =20 - TP_ARGS(m), + TP_ARGS(err), =20 TP_STRUCT__entry( __field( u64, mcgcap ) @@ -46,25 +46,25 @@ TRACE_EVENT(mce_record, ), =20 TP_fast_assign( - __entry->mcgcap =3D m->mcgcap; - __entry->mcgstatus =3D m->mcgstatus; - __entry->status =3D m->status; - __entry->addr =3D m->addr; - __entry->misc =3D m->misc; - __entry->synd =3D m->synd; - __entry->ipid =3D m->ipid; - __entry->ip =3D m->ip; - __entry->tsc =3D m->tsc; - __entry->ppin =3D m->ppin; - __entry->walltime =3D m->time; - __entry->cpu =3D m->extcpu; - __entry->cpuid =3D m->cpuid; - __entry->apicid =3D m->apicid; - __entry->socketid =3D m->socketid; - __entry->cs =3D m->cs; - __entry->bank =3D m->bank; - __entry->cpuvendor =3D m->cpuvendor; - __entry->microcode =3D m->microcode; + __entry->mcgcap =3D err->m.mcgcap; + __entry->mcgstatus =3D err->m.mcgstatus; + __entry->status =3D err->m.status; + __entry->addr =3D err->m.addr; + __entry->misc =3D err->m.misc; + __entry->synd =3D err->m.synd; + __entry->ipid =3D err->m.ipid; + __entry->ip =3D err->m.ip; + __entry->tsc =3D err->m.tsc; + __entry->ppin =3D err->m.ppin; + __entry->walltime =3D err->m.time; + __entry->cpu =3D err->m.extcpu; + __entry->cpuid =3D err->m.cpuid; + __entry->apicid =3D err->m.apicid; + __entry->socketid =3D err->m.socketid; + __entry->cs =3D err->m.cs; + __entry->bank =3D err->m.bank; + __entry->cpuvendor =3D err->m.cpuvendor; + __entry->microcode =3D err->m.microcode; ), =20 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: %l= lx, vendor: %u, CPUID: %x, time: %llu, socket: %u, APIC: %x, microcode: %x", --=20 2.43.0