From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH for-1.1] target-arm: Fix crash when passed "-cpu foo"
Date: Wed, 09 May 2012 18:07:21 +0200 [thread overview]
Message-ID: <4FAA9639.5070409@suse.de> (raw)
In-Reply-To: <1336575277-12840-1-git-send-email-peter.maydell@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 <peter.maydell@linaro.org>
> ---
> 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(-)
>
> 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
>
> -#define cpu_init(model) (&cpu_arm_init(model)->env)
> +static inline CPUARMState *cpu_init(const char *cpu_model)
> +{
> + ARMCPU *cpu = 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ärber <afaerber@suse.de>
Thanks,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
prev parent reply other threads:[~2012-05-09 16:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-09 14:54 [Qemu-devel] [PATCH for-1.1] target-arm: Fix crash when passed "-cpu foo" Peter Maydell
2012-05-09 16:07 ` Andreas Färber [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FAA9639.5070409@suse.de \
--to=afaerber@suse.de \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.