static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)

{

    int ret = 0, offset, cpus_offset;

    CPUState *cs;

    char cpu_model[32];

    int smt = kvmppc_smt_threads();

    uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};



    CPU_FOREACH(cs) {

        PowerPCCPU *cpu = POWERPC_CPU(cs);

        DeviceClass *dc = DEVICE_GET_CLASS(cs);

        int index = spapr_vcpu_id(cpu);

        int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));



        if ((index % smt) != 0) {

            continue;

        }



        snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);



        cpus_offset = fdt_path_offset(fdt, "/cpus");

        if (cpus_offset < 0) {

            cpus_offset = fdt_add_subnode(fdt, 0, "cpus");

            if (cpus_offset < 0) {

                return cpus_offset;

            }

        }

        offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);

        if (offset < 0) {

            offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);

            if (offset < 0) {

                return offset;

            }

        }



        ret = fdt_setprop(fdt, offset, "ibm,pft-size",

                          pft_size_prop, sizeof(pft_size_prop));

        if (ret < 0) {

            return ret;

        }



        if (nb_numa_nodes > 1) {

            ret = spapr_fixup_cpu_numa_dt(fdt, offset, cpu);

            if (ret < 0) {

                return ret;

            }

        }



        ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt);

        if (ret < 0) {

            return ret;

        }



        spapr_populate_pa_features(cpu, fdt, offset,

                                         spapr->cas_legacy_guest_workaround);

    }

    return ret;

}

static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)

{

    int ret = 0, offset, cpus_offset;

    CPUState *cs;

    char cpu_model[32];

    int smt = kvmppc_smt_threads();

    uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};



    CPU_FOREACH(cs) {

        PowerPCCPU *cpu = POWERPC_CPU(cs);

        DeviceClass *dc = DEVICE_GET_CLASS(cs);

        int index = spapr_vcpu_id(cpu);

        int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));



        if ((index % smt) != 0) {

            continue;

        }



        snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);



        cpus_offset = fdt_path_offset(fdt, "/cpus");

        if (cpus_offset < 0) {

            cpus_offset = fdt_add_subnode(fdt, 0, "cpus");

            if (cpus_offset < 0) {

                return cpus_offset;

            }

        }

        offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);

        if (offset < 0) {

            offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);

            if (offset < 0) {

                return offset;

            }

        }



        ret = fdt_setprop(fdt, offset, "ibm,pft-size",

                          pft_size_prop, sizeof(pft_size_prop));

        if (ret < 0) {

            return ret;

        }



        if (nb_numa_nodes > 1) {

            ret = spapr_fixup_cpu_numa_dt(fdt, offset, cpu);

            if (ret < 0) {

                return ret;

            }

        }



        ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu, compat_smt);

        if (ret < 0) {

            return ret;

        }



        spapr_populate_pa_features(cpu, fdt, offset,

                                         spapr->cas_legacy_guest_workaround);

    }

    return ret;

}

static int FUNC_0(void *VAR_0, sPAPRMachineState *VAR_1)

{

    int VAR_2 = 0, VAR_3, VAR_4;

    CPUState *cs;

    char VAR_5[32];

    int VAR_6 = kvmppc_smt_threads();

    uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_1->htab_shift)};



    CPU_FOREACH(cs) {

        PowerPCCPU *cpu = POWERPC_CPU(cs);

        DeviceClass *dc = DEVICE_GET_CLASS(cs);

        int index = spapr_vcpu_id(cpu);

        int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));



        if ((index % VAR_6) != 0) {

            continue;

        }



        snprintf(VAR_5, 32, "%s@%x", dc->fw_name, index);



        VAR_4 = fdt_path_offset(VAR_0, "/cpus");

        if (VAR_4 < 0) {

            VAR_4 = fdt_add_subnode(VAR_0, 0, "cpus");

            if (VAR_4 < 0) {

                return VAR_4;

            }

        }

        VAR_3 = fdt_subnode_offset(VAR_0, VAR_4, VAR_5);

        if (VAR_3 < 0) {

            VAR_3 = fdt_add_subnode(VAR_0, VAR_4, VAR_5);

            if (VAR_3 < 0) {

                return VAR_3;

            }

        }



        VAR_2 = fdt_setprop(VAR_0, VAR_3, "ibm,pft-size",

                          pft_size_prop, sizeof(pft_size_prop));

        if (VAR_2 < 0) {

            return VAR_2;

        }



        if (nb_numa_nodes > 1) {

            VAR_2 = spapr_fixup_cpu_numa_dt(VAR_0, VAR_3, cpu);

            if (VAR_2 < 0) {

                return VAR_2;

            }

        }



        VAR_2 = spapr_fixup_cpu_smt_dt(VAR_0, VAR_3, cpu, compat_smt);

        if (VAR_2 < 0) {

            return VAR_2;

        }



        spapr_populate_pa_features(cpu, VAR_0, VAR_3,

                                         VAR_1->cas_legacy_guest_workaround);

    }

    return VAR_2;

}

static int FUNC_0(void *VAR_0, sPAPRMachineState *VAR_1)
{ int VAR_2 = 0, VAR_3, VAR_4; CPUState *cs; char VAR_5[32]; int VAR_6 = kvmppc_smt_threads(); uint32_t pft_size_prop[] = {0, cpu_to_be32(VAR_1->htab_shift)}; CPU_FOREACH(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); DeviceClass *dc = DEVICE_GET_CLASS(cs); int index = spapr_vcpu_id(cpu); int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu)); if ((index % VAR_6) != 0) { continue; } snprintf(VAR_5, 32, "%s@%x", dc->fw_name, index); VAR_4 = fdt_path_offset(VAR_0, "/cpus"); if (VAR_4 < 0) { VAR_4 = fdt_add_subnode(VAR_0, 0, "cpus"); if (VAR_4 < 0) { return VAR_4; } } VAR_3 = fdt_subnode_offset(VAR_0, VAR_4, VAR_5); if (VAR_3 < 0) { VAR_3 = fdt_add_subnode(VAR_0, VAR_4, VAR_5); if (VAR_3 < 0) { return VAR_3; } } VAR_2 = fdt_setprop(VAR_0, VAR_3, "ibm,pft-size",
pft_size_prop, sizeof(pft_size_prop)); if (VAR_2 < 0) { return VAR_2; } if (nb_numa_nodes > 1) { VAR_2 = spapr_fixup_cpu_numa_dt(VAR_0, VAR_3, cpu); if (VAR_2 < 0) { return VAR_2; } } VAR_2 = spapr_fixup_cpu_smt_dt(VAR_0, VAR_3, cpu, compat_smt); if (VAR_2 < 0) { return VAR_2; } spapr_populate_pa_features(cpu, VAR_0, VAR_3,
VAR_1->cas_legacy_guest_workaround); } return VAR_2; }