From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS9QH-0004LE-Tv for qemu-devel@nongnu.org; Wed, 09 May 2012 12:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SS9QC-00042i-3h for qemu-devel@nongnu.org; Wed, 09 May 2012 12:07:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:55119 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS9QB-00041o-Pt for qemu-devel@nongnu.org; Wed, 09 May 2012 12:07:24 -0400 Message-ID: <4FAA9639.5070409@suse.de> Date: Wed, 09 May 2012 18:07:21 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1336575277-12840-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1336575277-12840-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-1.1] target-arm: Fix crash when passed "-cpu foo" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, patches@linaro.org Am 09.05.2012 16:54, schrieb Peter Maydell: > The macro definition of cpu_init meant that if cpu_arm_init() > returned NULL this wouldn't result in cpu_init() itself returning > NULL. This had the effect that "-cpu foo" for some unknown CPU > name 'foo' would cause ARM targets to segfault rather than > generating a useful error message. Fix this by making cpu_init > a simple inline function. Ouch. > Signed-off-by: Peter Maydell > --- > I did a quick grep and I think ARM is the only target at the moment > where we've made this change to cpu_init -- is that right, Andreas? Affirmative for master. But I need to respin my qom-cpu-reset series (QOM CPUState part 3) and the followups I have queued. > target-arm/cpu.h | 10 +++++++++- > 1 files changed, 9 insertions(+), 1 deletions(-) >=20 > diff --git a/target-arm/cpu.h b/target-arm/cpu.h > index 5eac070..d01285f 100644 > --- a/target-arm/cpu.h > +++ b/target-arm/cpu.h > @@ -458,7 +458,15 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum= , > #define TARGET_PHYS_ADDR_SPACE_BITS 32 > #define TARGET_VIRT_ADDR_SPACE_BITS 32 > =20 > -#define cpu_init(model) (&cpu_arm_init(model)->env) > +static inline CPUARMState *cpu_init(const char *cpu_model) > +{ > + ARMCPU *cpu =3D cpu_arm_init(cpu_model); > + if (cpu) { Personally I prefer an explicit NULL check for pointers, but it's the same either way. > + return &cpu->env; > + } > + return NULL; > +} > + > #define cpu_exec cpu_arm_exec > #define cpu_gen_code cpu_arm_gen_code > #define cpu_signal_handler cpu_arm_signal_handler Acked-by: Andreas F=E4rber Thanks, Andreas --=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