All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Gokul K <gokul02k@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
	linux-edac@vger.kernel.org, John Allen <john.allen@amd.com>,
	Aichun Shi <shiaichun@open-hieco.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RAS/AMD/ATL: Check the legacy MMIO hole after the address map is read
Date: Mon, 30 Nov 2026 13:50:13 -0500	[thread overview]
Message-ID: <20261130185013.GC212336@yaz-khff2.amd.com> (raw)
In-Reply-To: <20261126091744.2096611-1-gokul02k@gmail.com>

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@gmail.com>
> ---
> 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@open-hieco.net/
> 
>  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@amd.com>

Thanks,
Yazen

      reply	other threads:[~2026-11-30 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  9:17 [PATCH] RAS/AMD/ATL: Check the legacy MMIO hole after the address map is read Gokul K
2026-11-30 18:50 ` Yazen Ghannam [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130185013.GC212336@yaz-khff2.amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=bp@alien8.de \
    --cc=gokul02k@gmail.com \
    --cc=john.allen@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shiaichun@open-hieco.net \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.