Commit 4482e05c authored by Igor Mammedov's avatar Igor Mammedov Committed by Eduardo Habkost
Browse files

cpu: make cpu_generic_init() abort QEMU on error



Almost every user of cpu_generic_init() checks for
returned NULL and then reports failure in a custom way
and aborts process.
Some users assume that call can't fail and don't check
for failure, though they should have checked for it.

In either cases cpu_generic_init() failure is fatal,
so instead of checking for failure and reporting
it various ways, make cpu_generic_init() report
errors in consistent way and terminate QEMU on failure.

Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1505318697-77161-3-git-send-email-imammedo@redhat.com>
Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
parent 3c72234c
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -902,10 +902,6 @@ int main(int argc, char **argv)
    /* NOTE: we need to init the CPU at this stage to get
       qemu_host_page_size */
    cpu = cpu_init(cpu_model);
    if (!cpu) {
        fprintf(stderr, "Unable to find CPU definition\n");
        exit(1);
    }
    env = cpu->env_ptr;
#if defined(TARGET_SPARC) || defined(TARGET_PPC)
    cpu_reset(cpu);
+0 −4
Original line number Diff line number Diff line
@@ -68,10 +68,6 @@ static void clipper_init(MachineState *machine)
    memset(cpus, 0, sizeof(cpus));
    for (i = 0; i < smp_cpus; ++i) {
        cpus[i] = ALPHA_CPU(cpu_generic_init(TYPE_ALPHA_CPU, cpu_model));
        if (!cpus[i]) {
            error_report("Unable to find CPU definition");
            exit(1);
        }
    }

    cpus[0]->env.trap_arg0 = ram_size;
+0 −4
Original line number Diff line number Diff line
@@ -1594,10 +1594,6 @@ static void musicpal_init(MachineState *machine)
        cpu_model = "arm926";
    }
    cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, cpu_model));
    if (!cpu) {
        fprintf(stderr, "Unable to find CPU definition\n");
        exit(1);
    }

    /* For now we use a fixed - the original - RAM size */
    memory_region_allocate_system_memory(ram, NULL, "musicpal.ram",
+0 −4
Original line number Diff line number Diff line
@@ -3864,10 +3864,6 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
    /* Core */
    s->mpu_model = omap310;
    s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, core));
    if (s->cpu == NULL) {
        fprintf(stderr, "Unable to find CPU definition\n");
        exit(1);
    }
    s->sdram_size = sdram_size;
    s->sram_size = OMAP15XX_SRAM_SIZE;

+0 −4
Original line number Diff line number Diff line
@@ -2262,10 +2262,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
    /* Core */
    s->mpu_model = omap2420;
    s->cpu = ARM_CPU(cpu_generic_init(TYPE_ARM_CPU, core ?: "arm1136-r2"));
    if (s->cpu == NULL) {
        fprintf(stderr, "Unable to find CPU definition\n");
        exit(1);
    }
    s->sdram_size = sdram_size;
    s->sram_size = OMAP242X_SRAM_SIZE;

Loading