[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2] ppc: Force CPU threads count to be a power of 2.
From: |
Bharata B Rao |
Subject: |
[Qemu-devel] [PATCH v2] ppc: Force CPU threads count to be a power of 2. |
Date: |
Wed, 5 Mar 2014 14:02:36 +0530 |
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>
---
Changes in v2: Use is_power_of_2() from QEMU itself instead of depending
on libm.
v1: https://lists.gnu.org/archive/html/qemu-devel/2014-03/msg00660.html
v0: https://lists.gnu.org/archive/html/qemu-devel/2014-03/msg00355.html
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 445c360..5628248 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7987,6 +7987,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;
+ }
#endif
if (kvm_enabled()) {
--
1.7.11.7
- [Qemu-devel] [PATCH v2] ppc: Force CPU threads count to be a power of 2.,
Bharata B Rao <=