From: Ingo Molnar <mingo@kernel.org>
To: Jason Andryuk <jason.andryuk@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>,
Yazen Ghannam <yazen.ghannam@amd.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Penny Zheng <penny.zheng@amd.com>,
stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: Avoid divide by 0 in amd_smn_init()
Date: Wed, 24 Jun 2026 11:21:51 +0200 [thread overview]
Message-ID: <ajuhrzRodTlLAiIe@gmail.com> (raw)
In-Reply-To: <20260623211904.3674-1-jason.andryuk@amd.com>
* Jason Andryuk <jason.andryuk@amd.com> wrote:
> Xen synthesizes the CPU topology, so the num_nodes and num_roots values
> may be surprising for amd_smn_init(). Specifically:
>
> roots_per_node = num_roots / num_nodes;
>
> may results in roots_per_node == 0 which leads to divide by zero in
>
> count % roots_per_node
>
> As an example, I have a system with a Xen PVH dom0 that reports:
> Found 1 AMD root devices
> Found 2 AMD nodes
>
> Ensure roots_per_node is at least 1 to avoid the divide by zero errors.
> num_nodes are allocated for amd_roots, so roots_per_node = 1 will
> populate all the entries.
>
> Also add a pr_debug() for the number of nodes.
So arguably this Xen PHV dom0 PCI configuration is bogus,
because it violates the roots % nodes rule, right?
Why should we not go back to something similar to the pre-40a5f6ffdfc8
state of things, which warned about such bogus configs in the syslog,
so that it could be seen and fixed:
- /*
- * There should be _exactly_ N roots for each DF/SMN
- * interface.
- */
- if (!roots_per_misc || (root_count % roots_per_misc)) {
- pr_info("Unsupported AMD DF/PCI configuration found\n");
- return -ENODEV;
- }
Instead of your patch which just silently works around the
borkage and issues a pr_debug() that nobody reads?
AFAICS the following fix:
0a4b61d9c2e4 ("x86/amd_node: Fix AMD root device caching")
Never restored that sanity check & warning about such firmware
bogosity.
Thanks,
Ingo
next prev parent reply other threads:[~2026-06-24 9:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 21:19 [PATCH] x86: Avoid divide by 0 in amd_smn_init() Jason Andryuk
2026-06-23 21:35 ` Borislav Petkov
2026-06-24 15:41 ` Jason Andryuk
2026-06-24 15:59 ` Borislav Petkov
2026-06-24 16:41 ` Jason Andryuk
2026-06-24 17:15 ` Borislav Petkov
2026-06-24 9:21 ` Ingo Molnar [this message]
2026-06-24 14:54 ` Borislav Petkov
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=ajuhrzRodTlLAiIe@gmail.com \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jason.andryuk@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mingo@redhat.com \
--cc=penny.zheng@amd.com \
--cc=stable@vger.kernel.org \
--cc=tglx@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