Skip to contentSkip to conversation

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

PATCH In review Phineas Su 3 participants 7 messages Jun 8 – Jun 23

Subsystems (2)
lore
Share & tools
lore

Phineas Su

author
#0 lore raw

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

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")
---
 drivers/edac/amd64_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/amd64_edac.c +4 -0
index c6aa69dbd9fb..1e688123a50c 100644
@@ -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;
Signature · 1 line
2.54.0.1032.g2f8565e1d1-goog
maintainer
#1 lore raw
Quoted 5 lines · Phineas Su

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().

Can you please share the MCA_IPID register value for these banks?

The statement 'Zen4 and newer processors...use SMCA_UMC_V2 banks' isn't generally true.

This system may be a special case. Or there may be a hardware issue. Or there may be a bug in the kernel enumeration code.

Thanks,
Yazen

author
#2 lore raw
Quoted 10 lines · Yazen Ghannam
Quoted 5 lines · Phineas Su

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().

Can you please share the MCA_IPID register value for these banks?

Quoted 8 lines

The statement 'Zen4 and newer processors...use SMCA_UMC_V2 banks' isn't generally true.

This system may be a special case. Or there may be a hardware issue. Or there may be a bug in the kernel enumeration code.

Thanks,
Yazen

Hi Yazen,

Thanks, you are correct. I think we misunderstood the code regarding Zen4 CPUs generally using UMC_V2.
I was troubleshooting an internal memory error reporting issue on a CPU-only system and initially thought this might be the problem. However, I think making the code more robust and clearer is worthwhile. If a CPU-only system were to report UMC_V2 (due to future hardware iterations, firmware bugs, or enumeration anomalies), the current logic would incorrectly apply the GPU fixup.
I will send a v2 of the patch with an updated commit message framing this as a robustness improvement.

Thanks,
Phineas Su

author
#3 lore raw

PATCH v2 1/1 EDAC/amd64: Only translate Node ID if GPU nodes are present

The fixup_node_id() function adjusts the AMD Node ID for GPU memory controllers (which report as SMCA_UMC_V2) on heterogeneous systems. CPU memory controllers typically report as SMCA_UMC (v1) and do not require translation.

If a CPU memory controller on a CPU-only system were to report as SMCA_UMC_V2 (e.g. due to future hardware iterations, firmware reporting, or kernel enumeration differences), the code would attempt to apply the GPU translation. Since gpu_node_map is uninitialized on CPU-only systems, this would lead to an unintended translation being applied.

Harden the translation logic by checking that GPU nodes are actually present in the system (gpu_node_map.node_count > 0) before applying the translation. This ensures CPU-only systems are always safely bypassed.

---
v2:
- Reframed commit message to focus on robustness rather than a confirmed bug, as Zen4 CPUs do not generally report UMC_V2. (Yazen)

 drivers/edac/amd64_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/amd64_edac.c +4 -0
index c6aa69dbd9fb..1e688123a50c 100644
@@ -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;
Signature · 1 line
2.54.0.1136.gdb2ca164c4-goog
maintainer
#4 lore raw

Re: [PATCH v2] EDAC/amd64: Only translate Node ID if GPU nodes are present

Quoted 29 lines · Phineas Su

The fixup_node_id() function adjusts the AMD Node ID for GPU memory controllers (which report as SMCA_UMC_V2) on heterogeneous systems. CPU memory controllers typically report as SMCA_UMC (v1) and do not require translation.

If a CPU memory controller on a CPU-only system were to report as SMCA_UMC_V2 (e.g. due to future hardware iterations, firmware reporting, or kernel enumeration differences), the code would attempt to apply the GPU translation. Since gpu_node_map is uninitialized on CPU-only systems, this would lead to an unintended translation being applied.

Harden the translation logic by checking that GPU nodes are actually present in the system (gpu_node_map.node_count > 0) before applying the translation. This ensures CPU-only systems are always safely bypassed.

---
v2:
- Reframed commit message to focus on robustness rather than a confirmed bug, as Zen4 CPUs do not generally report UMC_V2. (Yazen)

 drivers/edac/amd64_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/amd64_edac.c +0 -0
index c6aa69dbd9fb..1e688123a50c 100644

drivers/edac/amd64_edac.c static int fixup_node_id(int node_id, struct mce *m) · line 1053

Quoted 7 lines
drivers/edac/amd64_edac.c +4 -0
@@ -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;
+

Thanks Phineas for the patch.

I do agree, in principle, about hardening against possible new configurations.

I think your patch could go a bit further.

I don't see any users of gpu_node_map.node_count. So rather than add a user, we could remove it.

In fact, we don't even need the entire struct. We just need the 'gpu_base_node_id'.

drivers/edac/amd64_edac.c static int fixup_node_id(int node_id, struct mce *m) · line 1056

Quoted 3 lines
drivers/edac/amd64_edac.c +0 -0
 	/* 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;

You could add the "unintialized" check here. ^^^

	if (!gpu_base_node_id || nid < gpu_base_node_id)
	    	return node_id;

What do you think?

Thanks,
Yazen

maintainer
#5 lore raw

Re: [PATCH v2] EDAC/amd64: Only translate Node ID if GPU nodes are present

Quoted 2 lines · Yazen Ghannam

I do agree, in principle, about hardening against possible new configurations.

Are those configurations going to happen?

If so, we can harden when that happens. We don't do hypothetical coding yet.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#6 lore raw

Re: [PATCH v2] EDAC/amd64: Only translate Node ID if GPU nodes are present

Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Yazen Ghannam

I do agree, in principle, about hardening against possible new configurations.

Are those configurations going to happen?

Not that I'm aware.

Quoted 3 lines

If so, we can harden when that happens. We don't do hypothetical coding yet.

Okay, no problem.

Thanks,
Yazen