linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Thomas Gleixner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: david.vrabel@citrix.com, hpa@zytor.com, peterz@infradead.org,
	joseph.salisbury@canonical.com, linux-kernel@vger.kernel.org,
	boris.ostrovsky@oracle.com, tglx@linutronix.de, mingo@kernel.org
Subject: [tip:x86/urgent] x86/topology: Handle CPUID bogosity gracefully
Date: Sat, 7 May 2016 01:12:39 -0700	[thread overview]
Message-ID: <tip-56402d63eefe22179f7311a51ff2094731420406@git.kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.11.1605062046270.3540@nanos>

Commit-ID:  56402d63eefe22179f7311a51ff2094731420406
Gitweb:     http://git.kernel.org/tip/56402d63eefe22179f7311a51ff2094731420406
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Fri, 6 May 2016 20:48:16 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 7 May 2016 10:06:55 +0200

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>

---
 arch/x86/kernel/smpboot.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index a2065d3..0e4329e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -332,6 +332,11 @@ static void __init smp_init_package_map(void)
 	 * primary cores.
 	 */
 	ncpus = boot_cpu_data.x86_max_cores;
+	if (!ncpus) {
+		pr_warn("x86_max_cores == zero !?!?");
+		ncpus = 1;
+	}
+
 	__max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
 
 	/*

      parent reply	other threads:[~2016-05-07  8:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-06 18:15 [v4.6-rc1 Regression] x86/topology: Create logical package id Joseph Salisbury
2016-05-06 18:48 ` Thomas Gleixner
2016-05-06 19:13   ` Boris Ostrovsky
2016-05-06 19:38     ` Joseph Salisbury
2016-05-06 20:46       ` Boris Ostrovsky
2016-05-06 20:51         ` Joseph Salisbury
2016-05-06 21:24           ` Boris Ostrovsky
2016-05-06 19:38   ` Joseph Salisbury
2016-05-06 20:50     ` Joseph Salisbury
2016-05-07  5:16   ` Ingo Molnar
2016-05-07  8:12   ` tip-bot for Thomas Gleixner [this message]

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=tip-56402d63eefe22179f7311a51ff2094731420406@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=hpa@zytor.com \
    --cc=joseph.salisbury@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).