Skip to content

Commit d332191

Browse files
committed
RAS/AMD/ATL: Translate normalized to system physical addresses using PRM
JIRA: https://issues.redhat.com/browse/RHEL-22695 Tested: sanity commit 26e43c9 Author: John Allen <[email protected]> Date: Tue Jul 30 15:17:31 2024 +0000 RAS/AMD/ATL: Translate normalized to system physical addresses using PRM 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. 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. 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". [ bp: Massage commit message. ] Signed-off-by: John Allen <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Aristeu Rozanski <[email protected]>
1 parent 4aa8784 commit d332191

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

drivers/ras/amd/atl/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ config AMD_ATL
1919

2020
Enable this option if using DRAM ECC on Zen-based systems
2121
and OS-based error handling.
22+
23+
config AMD_ATL_PRM
24+
depends on AMD_ATL && ACPI_PRMT
25+
def_bool y

drivers/ras/amd/atl/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ amd_atl-y += map.o
1515
amd_atl-y += system.o
1616
amd_atl-y += umc.o
1717

18+
amd_atl-$(CONFIG_AMD_ATL_PRM) += prm.o
19+
1820
obj-$(CONFIG_AMD_ATL) += amd_atl.o

drivers/ras/amd/atl/internal.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ int dehash_address(struct addr_ctx *ctx);
234234
unsigned long norm_to_sys_addr(u8 socket_id, u8 die_id, u8 coh_st_inst_id, unsigned long addr);
235235
unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err);
236236

237+
#ifdef CONFIG_AMD_ATL_PRM
238+
unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id, unsigned long addr);
239+
#else
240+
static inline unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 umc_bank_inst_id,
241+
unsigned long addr)
242+
{
243+
return -ENODEV;
244+
}
245+
#endif
246+
237247
/*
238248
* Make a gap in @data that is @num_bits long starting at @bit_num.
239249
* e.g. data = 11111111'b

drivers/ras/amd/atl/prm.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* AMD Address Translation Library
4+
*
5+
* prm.c : Plumbing code for ACPI Platform Runtime Mechanism (PRM)
6+
*
7+
* Information on AMD PRM modules and handlers including the GUIDs and buffer
8+
* structures used here are defined in the AMD ACPI Porting Guide in the
9+
* chapter "Platform Runtime Mechanism Table (PRMT)"
10+
*
11+
* Copyright (c) 2024, Advanced Micro Devices, Inc.
12+
* All Rights Reserved.
13+
*
14+
* Author: John Allen <[email protected]>
15+
*/
16+
17+
#include "internal.h"
18+
19+
#include <linux/prmt.h>
20+
21+
/*
22+
* PRM parameter buffer - normalized to system physical address, as described
23+
* in the "PRM Parameter Buffer" section of the AMD ACPI Porting Guide.
24+
*/
25+
struct norm_to_sys_param_buf {
26+
u64 norm_addr;
27+
u8 socket;
28+
u64 bank_id;
29+
void *out_buf;
30+
} __packed;
31+
32+
static const guid_t norm_to_sys_guid = GUID_INIT(0xE7180659, 0xA65D, 0x451D,
33+
0x92, 0xCD, 0x2B, 0x56, 0xF1,
34+
0x2B, 0xEB, 0xA6);
35+
36+
unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
37+
{
38+
struct norm_to_sys_param_buf p_buf;
39+
unsigned long ret_addr;
40+
int ret;
41+
42+
p_buf.norm_addr = addr;
43+
p_buf.socket = socket_id;
44+
p_buf.bank_id = bank_id;
45+
p_buf.out_buf = &ret_addr;
46+
47+
ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf);
48+
if (!ret)
49+
return ret_addr;
50+
51+
if (ret == -ENODEV)
52+
pr_debug("PRM module/handler not available\n");
53+
else
54+
pr_notice_once("PRM address translation failed\n");
55+
56+
return ret;
57+
}

drivers/ras/amd/atl/umc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,14 @@ unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err)
401401
u8 coh_st_inst_id = get_coh_st_inst_id(err);
402402
unsigned long addr = get_addr(err->addr);
403403
u8 die_id = get_die_id(err);
404+
unsigned long ret_addr;
404405

405406
pr_debug("socket_id=0x%x die_id=0x%x coh_st_inst_id=0x%x addr=0x%016lx",
406407
socket_id, die_id, coh_st_inst_id, addr);
407408

409+
ret_addr = prm_umc_norm_to_sys_addr(socket_id, err->ipid, addr);
410+
if (!IS_ERR_VALUE(ret_addr))
411+
return ret_addr;
412+
408413
return norm_to_sys_addr(socket_id, die_id, coh_st_inst_id, addr);
409414
}

0 commit comments

Comments
 (0)