Am 19.03.2014 03:47, schrieb Bharata B Rao: > On Wed, Mar 05, 2014 at 06:59:29AM -0700, Eric Blake wrote: >> On 03/05/2014 01:32 AM, Bharata B Rao wrote: >>> 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 <bhar...@linux.vnet.ibm.com> >>> --- >>> 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 >> >> Reviewed-by: Eric Blake <ebl...@redhat.com> > >> Reviewed-by: Stewart Smith <stew...@linux.vnet.ibm.com> > > 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 diff --cc target-ppc/translate_init.c index 3269c3e,5628248..0000000 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@@ -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; -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg