qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL for-2.0 05/13] target-ppc: Force CPU threads count to


From: Andreas Färber
Subject: [Qemu-devel] [PULL for-2.0 05/13] target-ppc: Force CPU threads count to be a power of 2
Date: Thu, 20 Mar 2014 02:48:47 +0100

From: Bharata B Rao <address@hidden>

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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stewart Smith <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
 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, 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);
-- 
1.8.4.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]