Mechanical change using the following coccinelle script: @@ @@ - first_cpu + qemu_get_cpu(0, TYPE_POWERPC_CPU)
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- hw/ppc/e500.c | 2 +- hw/ppc/ppc.c | 4 ++-- hw/ppc/prep_systemio.c | 2 +- hw/ppc/spapr.c | 11 ++++++----- hw/ppc/spapr_caps.c | 10 +++++----- hw/ppc/spapr_rtas.c | 2 +- hw/ppc/spapr_vof.c | 2 +- hw/ppc/vof.c | 3 ++- target/ppc/arch_dump.c | 4 ++-- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index c4bf3fef32..02d14404d9 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -373,7 +373,7 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms, MachineState *machine = MACHINE(pms); unsigned int smp_cpus = machine->smp.cpus; const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms); - CPUPPCState *env = cpu_env(first_cpu); + CPUPPCState *env = cpu_env(qemu_get_cpu(0, TYPE_POWERPC_CPU)); int ret = -1; uint64_t mem_reg_property[] = { 0, cpu_to_be64(machine->ram_size) }; int fdt_size; diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index be167710a3..be0b1536f5 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -970,7 +970,7 @@ void cpu_ppc_store_purr(CPUPPCState *env, uint64_t value) static void timebase_save(PPCTimebase *tb) { uint64_t ticks = cpu_get_host_ticks(); - PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *first_ppc_cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); if (!first_ppc_cpu->env.tb_env) { error_report("No timebase object"); @@ -998,7 +998,7 @@ static void timebase_save(PPCTimebase *tb) static void timebase_load(PPCTimebase *tb) { CPUState *cpu; - PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *first_ppc_cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); int64_t tb_off_adj, tb_off; unsigned long freq; diff --git a/hw/ppc/prep_systemio.c b/hw/ppc/prep_systemio.c index c96cefb13d..0431cde91c 100644 --- a/hw/ppc/prep_systemio.c +++ b/hw/ppc/prep_systemio.c @@ -261,7 +261,7 @@ static void prep_systemio_realize(DeviceState *dev, Error **errp) s->iomap_type = PORT0850_IOMAP_NONCONTIGUOUS; qemu_set_irq(s->non_contiguous_io_map_irq, s->iomap_type & PORT0850_IOMAP_NONCONTIGUOUS); - cpu = POWERPC_CPU(first_cpu); + cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); s->softreset_irq = qdev_get_gpio_in(DEVICE(cpu), PPC6xx_INPUT_HRESET); isa_register_portio_list(isa, &s->portio, 0x0, ppc_io800_port_list, s, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index cb840676d3..a5006eaa5e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -981,7 +981,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) static void spapr_dt_ov5_platform_support(SpaprMachineState *spapr, void *fdt, int chosen) { - PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *first_ppc_cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); char val[2 * 4] = { 23, 0x00, /* XICS / XIVE mode */ @@ -1125,7 +1125,7 @@ static void spapr_dt_hypervisor(SpaprMachineState *spapr, void *fdt) * Older KVM versions with older guest kernels were broken * with the magic page, don't allow the guest to map it. */ - if (!kvmppc_get_hypercall(cpu_env(first_cpu), hypercall, + if (!kvmppc_get_hypercall(cpu_env(qemu_get_cpu(0, TYPE_POWERPC_CPU)), hypercall, sizeof(hypercall))) { _FDT(fdt_setprop(fdt, hypervisor, "hcall-instructions", hypercall, sizeof(hypercall))); @@ -1669,7 +1669,7 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason) pef_kvm_reset(machine->cgs, &error_fatal); spapr_caps_apply(spapr); - first_ppc_cpu = POWERPC_CPU(first_cpu); + first_ppc_cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); if (kvm_enabled() && kvmppc_has_cap_mmu_radix() && ppc_type_check_compat(machine->cpu_type, CPU_POWERPC_LOGICAL_3_00, 0, spapr->max_compat_pvr)) { @@ -1845,7 +1845,7 @@ static int spapr_post_load(void *opaque, int version_id) } if (kvm_enabled() && spapr->patb_entry) { - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); bool radix = !!(spapr->patb_entry & PATE1_GR); bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE); @@ -4014,7 +4014,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) */ if (hotplugged) { for (i = 0; i < cc->nr_threads; i++) { - ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compat_pvr, + ppc_set_compat(core->threads[i], + POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU))->compat_pvr, &error_abort); } } diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 5a0755d34f..0c1f00d869 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -194,7 +194,7 @@ static void cap_htm_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); CPUPPCState *env = &cpu->env; if (!val) { @@ -213,7 +213,7 @@ static void cap_vsx_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) static void cap_dfp_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); CPUPPCState *env = &cpu->env; if (!val) { @@ -440,7 +440,7 @@ static void cap_nested_kvm_hv_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); CPUPPCState *env = &cpu->env; if (!val) { @@ -494,7 +494,7 @@ static void cap_large_decr_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); if (!val) { @@ -632,7 +632,7 @@ static void cap_ail_mode_3_apply(SpaprMachineState *spapr, uint8_t val, Error **errp) { ERRP_GUARD(); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); if (!val) { diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 7df21581c2..3d4e93a188 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -539,7 +539,7 @@ uint64_t qtest_rtas_call(char *cmd, uint32_t nargs, uint64_t args, for (token = 0; token < RTAS_TOKEN_MAX - RTAS_TOKEN_BASE; token++) { if (strcmp(cmd, rtas_table[token].name) == 0) { SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); - PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); rtas_table[token].fn(cpu, spapr, token + RTAS_TOKEN_BASE, nargs, args, nret, rets); diff --git a/hw/ppc/spapr_vof.c b/hw/ppc/spapr_vof.c index 09f29be0b9..301b3cd433 100644 --- a/hw/ppc/spapr_vof.c +++ b/hw/ppc/spapr_vof.c @@ -58,7 +58,7 @@ void spapr_vof_reset(SpaprMachineState *spapr, void *fdt, Error **errp) { target_ulong stack_ptr; Vof *vof = spapr->vof; - PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); + PowerPCCPU *first_ppc_cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); vof_init(vof, spapr->rma_size, errp); diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c index e3b430a81f..9fa1cd9e19 100644 --- a/hw/ppc/vof.c +++ b/hw/ppc/vof.c @@ -797,7 +797,8 @@ static uint32_t vof_call_method(MachineState *ms, Vof *vof, uint32_t methodaddr, VofMachineIfClass *vmc = VOF_MACHINE_GET_CLASS(vmo); g_assert(vmc->client_architecture_support); - ret = (uint32_t)vmc->client_architecture_support(ms, first_cpu, + ret = (uint32_t)vmc->client_architecture_support(ms, + qemu_get_cpu(0, TYPE_POWERPC_CPU), param1); } diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c index a8315659d9..be2a78d01f 100644 --- a/target/ppc/arch_dump.c +++ b/target/ppc/arch_dump.c @@ -228,11 +228,11 @@ int cpu_get_dump_info(ArchDumpInfo *info, { PowerPCCPU *cpu; - if (first_cpu == NULL) { + if (qemu_get_cpu(0, TYPE_POWERPC_CPU) == NULL) { return -1; } - cpu = POWERPC_CPU(first_cpu); + cpu = POWERPC_CPU(qemu_get_cpu(0, TYPE_POWERPC_CPU)); info->d_machine = PPC_ELF_MACHINE; info->d_class = ELFCLASS; -- 2.41.0