Re: [PATCH] RAS/AMD/ATL: Check the legacy MMIO hole after the address map is read
From: Yazen Ghannam
Date: Mon Nov 30 2026 - 13:50:28 EST
On Thu, Nov 26, 2026 at 02:47:44PM +0530, Gokul K wrote:
Hi Gokul,
Thanks for the patch.
> norm_to_sys_addr() refuses to translate an address when the legacy MMIO
> hole is enabled but the DRAM hole base is unknown. That check cannot
> fire. It runs on a freshly zeroed addr_ctx, and legacy_hole_en() reads
> ctx->map.base, or ctx->map.ctl on DF4 and later. Both are only filled in
> by get_address_map(), which runs two calls further down, so FIELD_GET()
> always sees a zeroed register and reports the hole as disabled.
>
> The situation the check was added for is still reachable.
> get_df_system_info() only warns when get_dram_hole_base() fails and
> leaves df_cfg.dram_hole_base at zero, so the library loads either way.
> On a system whose hole is enabled, add_legacy_hole() then compares
> against a base of zero, takes the branch for every address, and adds
> BIT_ULL(32). The system physical address handed back is 4 GiB too high,
> and the caller retires the wrong page.
"retires the wrong page" is a very specific use case that may or may not
apply. The gist of the issue is that the translated address is wrong.
>
> This has not been observed on hardware; it needs the DRAM hole base read
> to fail on a system that has the hole enabled.
>
Right, this is one of those sanity checks that shouldn't ever happen in
real use.
It would be a bigger issue if we couldn't read the register, or if the
values are invalid. The latter would affect general system functionality.
> Move the check below get_address_map(), where ctx.map holds the values
> read from the Data Fabric.
>
> Fixes: 1233aa3fb342 ("RAS/AMD/ATL: Read DRAM hole base early")
> Signed-off-by: Gokul K <gokul02k@xxxxxxxxx>
> ---
> Compile-tested only. ATL needs an AMD Zen system with a Data Fabric, and
> norm_to_sys_addr() is only entered from a DRAM ECC error, so I cannot run it
> here. Built at W=1 with CONFIG_AMD_ATL=m, and confirmed core.o is not built
> with it =n. I also replayed the guard outside the kernel, with the same field
> masks, across DF2 through DF4p5: it lets every address through today and the
> result is 4 GiB too high in each case.
>
> Noticed while reading the Hygon Family 0x18 series, which clones this function
> as hygon_norm_to_sys_addr() and places the same check after its own
> get_address_map() call [1]. That is the ordering this patch moves to.
>
> Based on origin/master; drivers/ras/amd/atl/core.c is identical in
> ras.git edac-for-next, so it applies there too.
>
> [1] https://lore.kernel.org/all/20260528035246.526012-6-shiaichun@xxxxxxxxxxxxxx/
>
> drivers/ras/amd/atl/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ras/amd/atl/core.c b/drivers/ras/amd/atl/core.c
> index d77dacdd4f56..06744d3aaf0c 100644
> --- a/drivers/ras/amd/atl/core.c
> +++ b/drivers/ras/amd/atl/core.c
> @@ -125,15 +125,15 @@ unsigned long norm_to_sys_addr(u8 socket_id, u8 die_id, u8 coh_st_inst_id, unsig
> ctx.inputs.die_id = die_id;
> ctx.inputs.coh_st_inst_id = coh_st_inst_id;
>
> - if (legacy_hole_en(&ctx) && !df_cfg.dram_hole_base)
> - return -EINVAL;
> -
> if (determine_node_id(&ctx, socket_id, die_id))
> return -EINVAL;
>
> if (get_address_map(&ctx))
> return -EINVAL;
>
> + if (legacy_hole_en(&ctx) && !df_cfg.dram_hole_base)
> + return -EINVAL;
> +
> if (denormalize_address(&ctx))
> return -EINVAL;
>
> --
Besides the minor points above, this looks correct.
Reviewed-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
Thanks,
Yazen