[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH qom-cpu for-1.4 08/14] target-unicore32: Detect
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH qom-cpu for-1.4 08/14] target-unicore32: Detect attempt to instantiate non-CPU type in cpu_init() |
Date: |
Sat, 26 Jan 2013 17:25:13 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130105 Thunderbird/17.0.2 |
Am 23.01.2013 13:07, schrieb Andreas Färber:
> Consolidate model checking into a new uc32_cpu_class_by_name().
>
> If the name matches an existing type, also check whether that type is
> actually (a sub-type of) TYPE_UNICORE32_CPU.
>
> This fixes, e.g., -cpu puv3_dma asserting.
>
> Cc: address@hidden
> Signed-off-by: Andreas Färber <address@hidden>
> ---
> target-unicore32/cpu.c | 23 +++++++++++++++++++++++
> target-unicore32/helper.c | 4 +++-
> 2 Dateien geändert, 26 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
>
> diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
> index a38fc4d..e9b9254 100644
> --- a/target-unicore32/cpu.c
> +++ b/target-unicore32/cpu.c
> @@ -22,6 +22,21 @@ static inline void set_feature(CPUUniCore32State *env, int
> feature)
>
> /* CPU models */
>
> +static ObjectClass *uc32_cpu_class_by_name(const char *cpu_model)
> +{
> + ObjectClass *oc;
> +
> + if (cpu_model == NULL) {
> + return NULL;
> + }
> +
> + oc = object_class_by_name(cpu_model);
> + if (oc != NULL && object_class_dynamic_cast(oc, TYPE_UNICORE32_CPU)) {
== NULL missing. Fixed by adding ! operator.
Andreas
> + oc = NULL;
> + }
> + return oc;
> +}
> +
> typedef struct UniCore32CPUInfo {
> const char *name;
> void (*instance_init)(Object *obj);
> @@ -80,6 +95,13 @@ static void uc32_cpu_initfn(Object *obj)
> tlb_flush(env, 1);
> }
>
> +static void uc32_cpu_class_init(ObjectClass *oc, void *data)
> +{
> + CPUClass *cc = CPU_CLASS(oc);
> +
> + cc->class_by_name = uc32_cpu_class_by_name;
> +}
> +
> static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
> {
> TypeInfo type_info = {
> @@ -98,6 +120,7 @@ static const TypeInfo uc32_cpu_type_info = {
> .instance_init = uc32_cpu_initfn,
> .abstract = true,
> .class_size = sizeof(UniCore32CPUClass),
> + .class_init = uc32_cpu_class_init,
> };
>
> static void uc32_cpu_register_types(void)
> diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
> index 5359538..7ace68c 100644
> --- a/target-unicore32/helper.c
> +++ b/target-unicore32/helper.c
> @@ -29,9 +29,11 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
> {
> UniCore32CPU *cpu;
> CPUUniCore32State *env;
> + ObjectClass *oc;
> static int inited = 1;
>
> - if (object_class_by_name(cpu_model) == NULL) {
> + oc = cpu_class_by_name(TYPE_UNICORE32_CPU, cpu_model);
> + if (oc == NULL) {
> return NULL;
> }
> cpu = UNICORE32_CPU(object_new(cpu_model));
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- Re: [Qemu-devel] [PATCH qom-cpu for-1.4 04/14] target-arm: Detect attempt to instantiate non-CPU type in cpu_init(), (continued)
[Qemu-devel] [PATCH qom-cpu for-1.4 07/14] target-openrisc: Detect attempt to instantiate non-CPU type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 01/14] target-openrisc: Don't use type_register_static(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 13/14] target-openrisc: Catch attempt to instantiate abstract type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 08/14] target-unicore32: Detect attempt to instantiate non-CPU type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 12/14] target-m68k: Catch attempt to instantiate abstract type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 05/14] target-alpha: Detect attempt to instantiate non-CPU type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 11/14] target-arm: Catch attempt to instantiate abstract type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 14/14] target-unicore32: Catch attempt to instantiate abstract type in cpu_init(), Andreas Färber, 2013/01/23
[Qemu-devel] [PATCH qom-cpu for-1.4 10/14] target-alpha: Catch attempt to instantiate abstract type in cpu_init(), Andreas Färber, 2013/01/23
Re: [Qemu-devel] [PATCH qom-cpu for-1.4 00/14] QOM CPU fixes for 1.4, Andreas Färber, 2013/01/26
Re: [Qemu-devel] [PATCH qom-cpu for-1.4 00/14] QOM CPU fixes for 1.4, Andreas Färber, 2013/01/27