Skip to content

Commit 56402d6

Browse files
committed
x86/topology: Handle CPUID bogosity gracefully
Joseph reported that a XEN guest dies with a division by 0 in the package topology setup code. This happens if cpu_info.x86_max_cores is zero. Handle that case and emit a warning. This does not fix the underlying XEN bug, but makes the code more robust. Reported-and-tested-by: Joseph Salisbury <joseph.salisbury@canonical.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: David Vrabel <david.vrabel@citrix.com> Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1605062046270.3540@nanos Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 0783783 commit 56402d6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ static void __init smp_init_package_map(void)
332332
* primary cores.
333333
*/
334334
ncpus = boot_cpu_data.x86_max_cores;
335+
if (!ncpus) {
336+
pr_warn("x86_max_cores == zero !?!?");
337+
ncpus = 1;
338+
}
339+
335340
__max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
336341

337342
/*

0 commit comments

Comments
 (0)