From: Jason Andryuk <jason.andryuk@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Mario Limonciello <mario.limonciello@amd.com>,
Yazen Ghannam <yazen.ghannam@amd.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
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:41:16 -0400 [thread overview]
Message-ID: <48629f88-4b78-424e-a199-d87594c8cb40@amd.com> (raw)
In-Reply-To: <20260623213552.GAajr8ONjXFUnuUOE3@fat_crate.local>
On 2026-06-23 17:35, Borislav Petkov wrote:
> On Tue, Jun 23, 2026 at 05:19:03PM -0400, Jason Andryuk 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.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
>> ---
>> This is an alternative to
>> https://lore.kernel.org/xen-devel/20260506055528.476493-2-penny.zheng@amd.com/
>> but it leaves smn available for dom0.
>
> Does this alternative work too?
>
> https://lore.kernel.org/r/20260605230949.GBaiNXPZ2ztjVL7DBg@fat_crate.local
It boots as dom0, but smn is disabled.
Yours:
$ journalctl -b | grep -e amd-pmf -e ypervisor
Hypervisor detected: Xen HVM
amd-pmf AMDI0107:00: error -EINVAL: error in reading from 0x13b102e8
amd-pmf AMDI0107:00: probe with driver amd-pmf failed with error -22
Mine:
$ journalctl -b -2 | grep -e amd-pmf -e ypervisor
Hypervisor detected: Xen HVM
amd-pmf AMDI0107:00: No Smart PC policy present
amd-pmf AMDI0107:00: registered PMF device successfully
amd-pmc also fails with yours.
dom0 is the privileged hardware domain and sees the physical PCI
devices. get_next_root() is looking for AMD or Hygon vendor ids, and
dom0 will find those. A regular domain (domU) would see QEMU's emulated
pci host bridges, which will be Intel.
I have wip s0ix support with Xen where dom0 issues the amd-pmc calls to
enter s0ix. I'm not sure of all the uses of SMN, but with Xen
dom0/hardware domain running most drivers, I think it should be available.
Regards,
Jason
next prev parent reply other threads:[~2026-06-24 15:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 21:19 Jason Andryuk
2026-06-23 21:35 ` Borislav Petkov
2026-06-24 15:41 ` Jason Andryuk [this message]
2026-06-24 15:59 ` Borislav Petkov
2026-06-24 16:41 ` Jason Andryuk
2026-06-24 17:15 ` Borislav Petkov
2026-06-24 19:08 ` Jason Andryuk
2026-06-24 19:25 ` Borislav Petkov
2026-06-24 9:21 ` Ingo Molnar
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=48629f88-4b78-424e-a199-d87594c8cb40@amd.com \
--to=jason.andryuk@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.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
all inboxes | Powered by JetHome®