[PATCH] EDAC/amd64: Fix incorrect Node ID mapping on CPU-only Zen4+ systems

Phineas Su <[email protected]>
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On CPU-only systems using AMD Zen4 (Genoa) and newer processors, memory
ECC errors can be reported with an incorrect Node ID (incremented by 1).
This happens because these CPUs use SMCA_UMC_V2 banks, which triggers
the GPU node ID fixup logic in fixup_node_id().

Since it is a CPU-only system, gpu_node_map is not initialized and
gpu_node_map.base_node_id is 0. The check (nid < gpu_node_map.base_node_id)
evaluates to (nid < 0), which is always false for the unsigned u8 nid.
The function then incorrectly applies the fixup (nid - 0 + 1), resulting
in the Node ID being incremented.

Fix this by ensuring that gpu_node_map has been initialized (i.e.,
node_count is non-zero) before applying any GPU-specific fixups.

Fixes: 4251566ebc1c ("EDAC/amd64: Cache and use GPU node map")
Signed-off-by: Phineas Su <[email protected]>
---
 drivers/edac/amd64_edac.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index c6aa69dbd9fb..1e688123a50c 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1047,6 +1047,10 @@ static int fixup_node_id(int node_id, struct mce *m)
 	if (smca_get_bank_type(m->extcpu, m->bank) != SMCA_UMC_V2)
 		return node_id;
 
+	/* If no GPU nodes are present, no fixup is needed. */
+	if (!gpu_node_map.node_count)
+		return node_id;
+
 	/* Nodes below the GPU base node are CPU nodes and don't need a fixup. */
 	if (nid < gpu_node_map.base_node_id)
 		return node_id;
-- 
2.54.0.1032.g2f8565e1d1-goog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.