Commit ef9aad1a authored by Yazen Ghannam's avatar Yazen Ghannam Committed by PrithivishS
Browse files

EDAC/amd64: Use new AMD Address Translation Library

mainline inclusion
from mainline-v6.9-rc1
commit 6c9058f49084569d1d816e87185e0a4f9ab1a321
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAYOV8
CVE: NA

Reference: https://github.com/torvalds/linux/commit/6c9058f49084569d1d816e87185e0a4f9ab1a321



--------------------------------

commit 6c9058f49084569d1d816e87185e0a4f9ab1a321 upstream.

Remove old address translation code and use the new AMD Address
Translation Library.

Use "imply" in Kconfig so that the "AMD_ATL" config option takes the
value of "EDAC_AMD64" as its default.

[Backport changes]
1. Retained all existing 277+ lines of in-file address translation code
along with changes added in Euler commit 845ff731 including function
umc_normaddr_to_sysaddr() in drivers/edac/amd64_edac.c to continue support
for address translation in EDAC for DRAM ECC errors in Hygon family 18h
and model 4h.

2. Modified conditional block in decode_umc_error() added by
Euler commit 7722509e to retain usage of existing old in-file
address translation code in hygon family CPU's and enabled use of
new AMD Address Translation Library in AMD CPU's as per upstream.

Signed-off-by: default avatarYazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20240123041401.79812-3-yazen.ghannam@amd.com


Signed-off-by: default avatarJeevan deep J <j.jeevandeep@amd.com>
Signed-off-by: default avatarPrithivishS <sprithiv@amd.com>
parent 39c06704
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ config EDAC_GHES
config EDAC_AMD64
	tristate "AMD64 (Opteron, Athlon64)"
	depends on AMD_NB && EDAC_DECODE_MCE
	imply AMD_ATL
	help
	  Support for error detection and correction of DRAM ECC errors on
	  the AMD64 families (>= K8) of memory controllers.
+17 −8
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/ras.h>
#include "amd64_edac.h"
#include <asm/amd_nb.h>

@@ -3115,6 +3116,7 @@ static void decode_umc_error(int node_id, struct mce *m)
	u8 ecc_type = (m->status >> 45) & 0x3;
	struct mem_ctl_info *mci;
	struct amd64_pvt *pvt;
	struct atl_err a_err;
	struct err_info err;
	u64 sys_addr;
	u8 umc;
@@ -3148,16 +3150,23 @@ static void decode_umc_error(int node_id, struct mce *m)

	pvt->ops->get_err_info(m, &err);

	if (hygon_f18h_m4h() && boot_cpu_data.x86_model == 0x6)
	if (hygon_f18h_m4h() && boot_cpu_data.x86_model == 0x6) {
		umc = err.channel << 1;
	else
		umc = err.channel;

		if (umc_normaddr_to_sysaddr(m->addr, pvt->mc_node_id, umc, &sys_addr)) {
			err.err_code = ERR_NORM_ADDR;
			goto log_error;
		}
	} else {
		a_err.addr = m->addr;
		a_err.ipid = m->ipid;
		a_err.cpu  = m->extcpu;

		sys_addr = (u64)amd_convert_umc_mca_addr_to_sys_addr(&a_err);
		if (IS_ERR_VALUE(sys_addr)) {
			err.err_code = ERR_NORM_ADDR;
			goto log_error;
		}
	}
	error_address_to_page_and_offset(sys_addr, &err);

log_error: