aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharata B Rao <bharata@linux.vnet.ibm.com>2014-03-05 14:02:36 +0530
committerAndreas Färber <afaerber@suse.de>2014-03-20 02:39:33 +0100
commit5ec83c73e5ece590538878b24dfcb422904533e0 (patch)
tree256572056d362bd5cc2a36526972167b4ef2c3f4
parenta80172a4762465a40f6b59d10d64360bd272b700 (diff)
downloadqemu-arm-5ec83c73e5ece590538878b24dfcb422904533e0.tar.gz
target-ppc: Force CPU threads count to be a power of 2
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 <bharata@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r--target-ppc/translate_init.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 3269c3ebe4..5302bdc1b2 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7848,6 +7848,12 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **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;
+ }
cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt
+ (cs->cpu_index % smp_threads);