ppc: Force CPU threads count to be a power of 2.
PATCH v2 1/1 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.
---
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(+)
target-ppc/translate_init.c +6 -0
@@ -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 ()) {
Signature · 1 line
1.7.11.7
Quoted 7 lines · 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.
Quoted 6 lines
Signed-off-by Bharata B Rao <[email protected]>---
Changes in v2: Useis_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
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 8 lines · 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 <[email protected]>
Quoted 15 lines · Eric Blake
Quoted 7 lines · 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.
Quoted 6 lines
Signed-off-by Bharata B Rao <[email protected]>---
Changes in v2: Useis_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
Quoted 3 lines
Reviewed-by Eric Blake <[email protected]>Reviewed-by Stewart Smith <[email protected]>
Alexander/Andreas,
Could you take this patch into your tree ?
Regards,
Bharata.
Am 19.03.2014 03:47, schrieb Bharata B Rao:
Quoted 16 lines · Eric Blake
Quoted 15 lines · Bharata B Rao
Quoted 13 lines
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 <[email protected]>---
Changes in v2: Useis_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
Quoted 7 lines
Quoted 3 lines
Reviewed-by Eric Blake <[email protected]>Reviewed-by Stewart Smith <[email protected]>Alexander/Andreas,
Could you take this patch into your tree ?
Thanks for the reminder.
Didn't apply cleanly any more. Applied to my ppc-next with fixups:
https://github.com/afaerber/qemu-cpu/commits/ppc-next
Andreas
target-ppc/translate_init.c +0 -0
@@@ -7848,12 -7987,20 +7848,18 @@@ static void ppc_cpu_realizefn(DeviceSta 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);#endif
- if (kvm_enabled()) {
- if (kvmppc_fixup_cpu(cpu) != 0) {
- error_setg(errp, "Unable to virtualize selected CPU with
KVM");
- return;
- }
- } else if (tcg_enabled()) {
+ if (tcg_enabled()) {
if (ppc_fixup_cpu(cpu) != 0) {
error_setg(errp, "Unable to emulate selected CPU with TCG");
return;Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg