From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQPRK-0002iQ-Qw for qemu-devel@nongnu.org; Wed, 19 Mar 2014 18:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQPRF-0000ej-Gz for qemu-devel@nongnu.org; Wed, 19 Mar 2014 18:58:26 -0400 Received: from cantor2.suse.de ([195.135.220.15]:59247 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQPRF-0000ee-AE for qemu-devel@nongnu.org; Wed, 19 Mar 2014 18:58:21 -0400 Message-ID: <532A210A.40502@suse.de> Date: Wed, 19 Mar 2014 23:58:18 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1394008356-15320-1-git-send-email-bharata@linux.vnet.ibm.com> <53172DC1.9070505@redhat.com> <20140319024752.GB11069@in.ibm.com> In-Reply-To: <20140319024752.GB11069@in.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] ppc: Force CPU threads count to be a power of 2. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: bharata@linux.vnet.ibm.com Cc: aik@ozlabs.ru, stewart@linux.vnet.ibm.com, qemu-devel@nongnu.org, agraf@suse.de 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 po= wer >>> of 2. Since QEMU doesn't enforce this, it leads to an early guest ker= nel >>> 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 >>> --- >>> Changes in v2: Use is_power_of_2() from QEMU itself instead of depend= ing >>> on libm. >>> v1: https://lists.gnu.org/archive/html/qemu-devel/2014-03/msg00660.ht= ml >>> v0: https://lists.gnu.org/archive/html/qemu-devel/2014-03/msg00355.ht= ml >> >> Reviewed-by: Eric Blake >=20 >> Reviewed-by: Stewart Smith >=20 > Alexander/Andreas, >=20 > 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(DeviceSt= a 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 =3D (cs->cpu_index / smp_threads) * max_smt + + (cs->cpu_index % smp_threads); #endif - if (kvm_enabled()) { - if (kvmppc_fixup_cpu(cpu) !=3D 0) { - error_setg(errp, "Unable to virtualize selected CPU with KVM"); - return; - } - } else if (tcg_enabled()) { + if (tcg_enabled()) { if (ppc_fixup_cpu(cpu) !=3D 0) { error_setg(errp, "Unable to emulate selected CPU with TCG")= ; return; --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg