mirror of
https://github.com/torvalds/linux.git
synced 2026-09-14 16:10:02 +02:00
x86/amd_node: Avoid divide by zero on virtualized systems
On a virtualized system, the number of nodes does not have a relationship to
the number of roots. A Xen PVH dom0 can calculate roots_per_node as 0, which
crashes with a divide by zero in:
if (count++ % roots_per_node)
because the underlying topology code on Xen ends up making num_nodes
2 and num_roots 1 and the integer division result is 0.
The issue is seen with Xen, but it could affect other systems.
Set roots_per_node to 1 in this case. Print a firmware bug when this is
performed for non-virtualized systems.
[ bp: Massage commit message. ]
Fixes: 0a4b61d9c2 ("x86/amd_node: Fix AMD root device caching")
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260825214805.39148-2-jason.andryuk@amd.com
This commit is contained in:
parent
cee9395acd
commit
72bd92bd81
|
|
@ -287,6 +287,11 @@ static int __init amd_smn_init(void)
|
|||
return -ENOMEM;
|
||||
|
||||
roots_per_node = num_roots / num_nodes;
|
||||
if (!roots_per_node) {
|
||||
if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
|
||||
pr_warn(FW_BUG "Error detecting roots per node.\n");
|
||||
roots_per_node = 1;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
node = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user