From patchwork Mon May 6 17:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Allen X-Patchwork-Id: 13655862 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2071.outbound.protection.outlook.com [40.107.236.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 BD4AC157E7A; Mon, 6 May 2024 17:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715017724; cv=fail; b=Bgv6mHJ4UdR44vsKSbcGuQ/lin+WoqloASPrUxF8Ptv9WDO81jzbODEmYsmicmo3pap/4NIqVoFktiqDLlObTqYakRR8LvSdG2M612qn+/VUS79OmcY1yoHmkrmPsjR/y5SwJMgIoYUmNafqTgV2WkQSwIJ9e0UxaKLaF7BiC/w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715017724; c=relaxed/simple; bh=NAQUS0iXrBz0gpy7VEGw6/C1DfYkIskTvWIbGrb8dws=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q6rCoygVJAzvSNNH3oBBQB2n2Gqi7iGBLv7jtXu6L5IOAqbetb0goGzCigKLQ3/E3kE8aV9rlzo3BqJQjv5JWJz4b+Vf/7DrG02+ZV4fYRqUId10nEmGIiCwv9H7dA5TtwpSbEd0cg44GbSTJYLKRuexazbqIhFOZzSU4cw3zjg= 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=1ZNksg23; arc=fail smtp.client-ip=40.107.236.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="1ZNksg23" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DcZDgp/Ugk/OW5LdjsHyCJFQd/REYzbEmDTG/IBVouGKlJsCLMp2rZPly7swjhfDJAhe25OiAEVi2DkKZby0ExijNQ8jwm5pY6M1RmMe71tdj+jLKDd2e5b8Go0zC/gbUAey1KiLLbsO8y6eqH5I8vvLHHQYxwxrNUzVdK8iT9Isdoag+fRlB24ybIWB8BD1szV9+BFYqVb6Go/kQ7TeeWjUI/KmK8MJtBMHDiX2y9akrfoXWOHo8UUboNOYUMERwUzw0Ik4SkGnTiZZa7JjbmVEf+YsNQMNZfYCMRdfezdxD+DSdFjLBhxMOYrqfDueVslm3tUluQrCcoDZ+lODGw== 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=edN5g7ybAMFNKVnU2tLL1HyAOrob1vyHXE/fPGvQ9Pc=; b=Joixr7nFWOh/QBI1DMA75D9/1w4PC6YnMikzttnFPXY2E/qrYLeo2Uy6QE97x/1o9Fqm36TpxGN3m7HUme0Ox59vLea/0ozQLojhfcuNhsZ8oBePpuB/B5XmVRu3Rg/9sxmyYkmtq/XRlBakJN7VjY5nNA/803nvEB7NZOMz+oFkhFhSxKJ5Ti/fHhsrzmKW1uixcsz81EVbH8wos3IVQdTsIH+38Ekpso/39hcEQlKxaY5JXRq19IgCArVSxR0/ZUx22whcNGirnF94O6xpZoHfZvrDijdDYwBoYBiRdrVyS9Fgc9vhiI/M1pBUUY+/tLwYbiDO+O46H6sx8lX2Pg== 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=edN5g7ybAMFNKVnU2tLL1HyAOrob1vyHXE/fPGvQ9Pc=; b=1ZNksg23pb0SNxuvd18ZFQMlYjTMt5J7urqptRlVBVsh3tROWst4wV37LVSpR+lq9bBQSKOD8M7vKEoT1CJ1vZo5gTBmZqebS/510/o2fB3eh5itCkRQShfOp1NDjAG75I8SZ9M9MusBiPlwDAqsN6PCr6ElJORiU3nyZIRB60c= Received: from BN0PR03CA0017.namprd03.prod.outlook.com (2603:10b6:408:e6::22) by PH7PR12MB7018.namprd12.prod.outlook.com (2603:10b6:510:1b8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 17:48:31 +0000 Received: from BN1PEPF00004689.namprd05.prod.outlook.com (2603:10b6:408:e6:cafe::a7) by BN0PR03CA0017.outlook.office365.com (2603:10b6:408:e6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41 via Frontend Transport; Mon, 6 May 2024 17:48:31 +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 BN1PEPF00004689.mail.protection.outlook.com (10.167.243.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Mon, 6 May 2024 17:48:31 +0000 Received: from jallen-jump-host.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; Mon, 6 May 2024 12:48:30 -0500 From: John Allen To: , , , CC: , , , John Allen Subject: [PATCH v2 2/2] RAS/AMD/ATL: Translate normalized to system physical addresses using PRM Date: Mon, 6 May 2024 17:47:21 +0000 Message-ID: <20240506174721.72018-3-john.allen@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506174721.72018-1-john.allen@amd.com> References: <20240506174721.72018-1-john.allen@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: BN1PEPF00004689:EE_|PH7PR12MB7018:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f76b15b-c806-45a0-11fe-08dc6df4be8c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?cO6CuV3En7VVUKe4JxEm96fs9EAV6Nu?= =?utf-8?q?wkaWkJ2NCVi/PV8lYRVK3jQ3YCBzNKXQrmmgLtJ68CgrWsbcdeuY1gl4djwH09F9Q?= =?utf-8?q?/iLG29nIZrTY3/QGVefHYMB6i8549nBF3NntV10hDcx/yudfOTgjF9LRSbZJ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?= =?utf-8?q?x+JPosW9mnoVYHQPTPz9uveTJKFTaT376XaGVuuPRdZVQooWP6G5xrW9Uu1ku1tLt?= =?utf-8?q?Qgjkse2GjMYbgiWfiXupC34XRjsb+Ayi8wOMOwC4HJhc2wWSx/QLaUGkMNB2R5FJh?= =?utf-8?q?xRsjxOer/yd1Zciax5kp50llpqjjJJPqja3xkmObKFanBThg39cCQnnqdrobu/uD8?= =?utf-8?q?St/lx1YvEOodVpav6ApwahapBPYKsOp42sizY4nsDIMklwYO2q2H9BscP17rKlpSE?= =?utf-8?q?AoEXLCljKtRR5427/TX8uSjF9h+Ru8v5/4iHfHBWQ7NGX/ZdZoaT4AuZomlq8ahBN?= =?utf-8?q?F1+5q4hd9Zu3?= 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)(1800799015)(36860700004)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 17:48:31.5597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f76b15b-c806-45a0-11fe-08dc6df4be8c 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: BN1PEPF00004689.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7018 Future AMD platforms will provide a UEFI PRM module that implements a number of address translation PRM handlers. This will provide an interface for the OS to call platform specific code without requiring the use of SMM or other heavy firmware operations. AMD Zen-based systems report memory error addresses through Machine Check banks representing Unified Memory Controllers (UMCs) in the form of UMC relative "normalized" addresses. A normalized address must be converted to a system physical address to be usable by the OS. Add support for the normalized to system physical address translation PRM handler in the AMD Address Translation Library and prefer it over native code if available. The GUID and parameter buffer structure are specific to the normalized to system physical address handler provided by the address translation PRM module included in future AMD systems. The address translation PRM module is documented in chapter 22 of the publicly available "AMD Family 1Ah Models 00h–0Fh and Models 10h–1Fh ACPI v6.5 Porting Guide": https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/58088-0.75-pub.pdf Signed-off-by: John Allen --- v2: - Make norm_to_sys_prm_handler_guid static. - Change pr_info statements to more appropriate pr_debug and pr_info_once statements. --- drivers/ras/amd/atl/Makefile | 1 + drivers/ras/amd/atl/internal.h | 2 ++ drivers/ras/amd/atl/prm.c | 61 ++++++++++++++++++++++++++++++++++ drivers/ras/amd/atl/umc.c | 5 +++ 4 files changed, 69 insertions(+) create mode 100644 drivers/ras/amd/atl/prm.c diff --git a/drivers/ras/amd/atl/Makefile b/drivers/ras/amd/atl/Makefile index 4acd5f05bd9c..8f1afa793e3b 100644 --- a/drivers/ras/amd/atl/Makefile +++ b/drivers/ras/amd/atl/Makefile @@ -14,5 +14,6 @@ amd_atl-y += denormalize.o amd_atl-y += map.o amd_atl-y += system.o amd_atl-y += umc.o +amd_atl-y += prm.o obj-$(CONFIG_AMD_ATL) += amd_atl.o diff --git a/drivers/ras/amd/atl/internal.h b/drivers/ras/amd/atl/internal.h index 5de69e0bb0f9..f739dcada126 100644 --- a/drivers/ras/amd/atl/internal.h +++ b/drivers/ras/amd/atl/internal.h @@ -234,6 +234,8 @@ int dehash_address(struct addr_ctx *ctx); unsigned long norm_to_sys_addr(u8 socket_id, u8 die_id, u8 coh_st_inst_id, unsigned long addr); unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err); +unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id, unsigned long addr); + /* * Make a gap in @data that is @num_bits long starting at @bit_num. * e.g. data = 11111111'b diff --git a/drivers/ras/amd/atl/prm.c b/drivers/ras/amd/atl/prm.c new file mode 100644 index 000000000000..8e96a6370ae3 --- /dev/null +++ b/drivers/ras/amd/atl/prm.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD Address Translation Library + * + * prm.c : Plumbing code to UEFI Platform Runtime Mechanism (PRM) + * + * Copyright (c) 2024, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: John Allen + */ + +#include "internal.h" + +#if defined(CONFIG_ACPI_PRMT) + +#include + +struct prm_umc_param_buffer_norm { + u64 norm_addr; + u8 socket; + u64 umc_bank_inst_id; + void *output_buffer; +} __packed; + +static const guid_t norm_to_sys_prm_handler_guid = GUID_INIT(0xE7180659, 0xA65D, + 0x451D, 0x92, 0xCD, + 0x2B, 0x56, 0xF1, 0x2B, + 0xEB, 0xA6); + +unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id, unsigned long addr) +{ + struct prm_umc_param_buffer_norm param_buffer; + unsigned long ret_addr; + int ret; + + param_buffer.norm_addr = addr; + param_buffer.socket = socket_id; + param_buffer.umc_bank_inst_id = umc_bank_inst_id; + param_buffer.output_buffer = &ret_addr; + + ret = acpi_call_prm_handler(norm_to_sys_prm_handler_guid, ¶m_buffer); + if (!ret) + return ret_addr; + + if (ret == -ENODEV) + pr_debug("PRM module/handler not available\n"); + else + pr_notice_once("PRM address translation failed\n"); + + return ret; +} + +#else /* ACPI_PRMT */ + +unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id, unsigned long addr) +{ + return -ENODEV; +} + +#endif diff --git a/drivers/ras/amd/atl/umc.c b/drivers/ras/amd/atl/umc.c index 08c6dbd44c62..3c018870633c 100644 --- a/drivers/ras/amd/atl/umc.c +++ b/drivers/ras/amd/atl/umc.c @@ -333,9 +333,14 @@ unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err) u8 coh_st_inst_id = get_coh_st_inst_id(err); unsigned long addr = get_addr(err->addr); u8 die_id = get_die_id(err); + unsigned long ret_addr; pr_debug("socket_id=0x%x die_id=0x%x coh_st_inst_id=0x%x addr=0x%016lx", socket_id, die_id, coh_st_inst_id, addr); + ret_addr = prm_umc_norm_to_sys_addr(socket_id, err->ipid, addr); + if (!IS_ERR_VALUE(ret_addr)) + return ret_addr; + return norm_to_sys_addr(socket_id, die_id, coh_st_inst_id, addr); }