From: Serge Hallyn <sergeh@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: Yazen Ghannam <yazen.ghannam@amd.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] x86/amd_node: Fix PCI device reference counting in amd_smn_init()
Date: Fri, 11 Sep 2026 11:33:56 -0500 [thread overview]
Message-ID: <aqQtdHUN3NVQI9yu@shallyn-amd> (raw)
In-Reply-To: <20260911030303.GCaqNvZ3QRcCLSmzja@fat_crate.local>
On Thu, Sep 10, 2026 at 08:03:03PM -0700, Borislav Petkov wrote:
> On Thu, Sep 03, 2026 at 02:37:08PM -0500, Serge Hallyn (AMD) wrote:
> > On Thu, Sep 03, 2026 at 10:43:25AM -0500, Yazen Ghannam wrote:
> > > The local "root" pointer is a temporary variable used during the device
> > > search. Therefore, refcount related to the search iterators should be
> > > cleaned up after the search is complete.
>
> Ontop of this:
>
> From: "Borislav Petkov (AMD)" <bp@alien8.de>
> Date: Thu, 10 Sep 2026 18:43:33 -0700
> Subject: [PATCH] x86/topo: Initialize AMD nodes per package
>
> Sashiko reports that
>
> If amd_num_nodes() evaluates to 0, kzalloc_objs(*amd_roots, 0) returns the
> truthy ZERO_SIZE_PTR (typically (void *)16).
>
> Because ZERO_SIZE_PTR is not NULL, the subsequent check for !amd_roots will
> fail to catch it, resulting in a divide-by-zero kernel panic on the very
> next line during the __init boot phase.
>
> Make sure topology_amd_nodes_per_pkg() doesn't return 0 - the AMD nodes per
> package count can be trivially 1 if detection fails just like the rest
> of the max* and num* packages topology attributes.
May not be worth it, but should we also add a num_nodes == 0 or
ZERO_OR_NULL_PTR(amd_roots) check, in case as code churns we
end up with another way for amd_num_nodes() to return 0?
> Closes: https://sashiko.dev/#/patchset/20260903154325.74343-1-yazen.ghannam%40amd.com
> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
> ---
> arch/x86/kernel/cpu/topology_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c
> index 6845e3c63fbb..7a7442981594 100644
> --- a/arch/x86/kernel/cpu/topology_common.c
> +++ b/arch/x86/kernel/cpu/topology_common.c
> @@ -14,7 +14,7 @@
> struct x86_topology_system x86_topo_system __ro_after_init;
> EXPORT_SYMBOL_GPL(x86_topo_system);
>
> -unsigned int __amd_nodes_per_pkg __ro_after_init;
> +unsigned int __amd_nodes_per_pkg __ro_after_init = 1;
> EXPORT_SYMBOL_GPL(__amd_nodes_per_pkg);
>
> /* CPUs which are the primary SMT threads */
> --
> 2.53.0
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2026-09-11 16:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 15:43 Yazen Ghannam
2026-09-03 19:37 ` Serge Hallyn (AMD)
2026-09-11 3:03 ` Borislav Petkov
2026-09-11 13:42 ` Yazen Ghannam
2026-09-11 16:33 ` Serge Hallyn [this message]
2026-09-11 17:21 ` Borislav Petkov
2026-09-11 2:59 ` [tip: x86/urgent] " tip-bot2 for Yazen Ghannam
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=aqQtdHUN3NVQI9yu@shallyn-amd \
--to=sergeh@kernel.org \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
--cc=yazen.ghannam@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®