From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQS6Z-0000ZZ-O4 for qemu-devel@nongnu.org; Wed, 19 Mar 2014 21:49:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQS6Q-0003zn-8L for qemu-devel@nongnu.org; Wed, 19 Mar 2014 21:49:11 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 20 Mar 2014 02:48:47 +0100 Message-Id: <1395280135-10644-6-git-send-email-afaerber@suse.de> In-Reply-To: <1395280135-10644-1-git-send-email-afaerber@suse.de> References: <1395280135-10644-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL for-2.0 05/13] target-ppc: Force CPU threads count to be a power of 2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexander Graf , qemu-ppc@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Bharata B Rao From: Bharata B Rao PowerPC kernel expects the number of SMT threads in a core to be a power of 2. Since QEMU doesn't enforce this, it leads to an early guest kernel crash if invalid threads count is specified. Prevent this crash and make it a graceful exit from QEMU itself by validating the user-supplied threads count. Signed-off-by: Bharata B Rao Reviewed-by: Eric Blake Reviewed-by: Stewart Smith Signed-off-by: Andreas F=C3=A4rber --- target-ppc/translate_init.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 3269c3e..5302bdc 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -7848,6 +7848,12 @@ static void ppc_cpu_realizefn(DeviceState *dev, Er= ror **errp) max_smt, kvm_enabled() ? "KVM" : "TCG"); return; } + if (!is_power_of_2(smp_threads)) { + error_setg(errp, "Cannot support %d threads on PPC with %s, " + "threads count must be a power of 2.", + smp_threads, kvm_enabled() ? "KVM" : "TCG"); + return; + } =20 cpu->cpu_dt_id =3D (cs->cpu_index / smp_threads) * max_smt + (cs->cpu_index % smp_threads); --=20 1.8.4.5