bool ppc_check_compat(PowerPCCPU *cpu, uint32_t compat_pvr, uint32_t min_compat_pvr, uint32_t max_compat_pvr) { PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); const CompatInfo *compat = compat_by_pvr(compat_pvr); const CompatInfo *min = compat_by_pvr(min_compat_pvr); const CompatInfo *max = compat_by_pvr(max_compat_pvr); #if !defined(CONFIG_USER_ONLY) g_assert(cpu->vhyp); #endif g_assert(!min_compat_pvr || min); g_assert(!max_compat_pvr || max); if (!compat) { /* Not a recognized logical PVR */ return false; } if ((min && (compat < min)) || (max && (compat > max))) { /* Outside specified range */ return false; } if (!(pcc->pcr_supported & compat->pcr_level)) { /* Not supported by this CPU */ return false; } return true; }
void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp) { const CompatInfo *compat = compat_by_pvr(compat_pvr); CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); uint64_t pcr; if (!compat_pvr) { pcr = 0; } else if (!compat) { error_setg(errp, "Unknown compatibility PVR 0x%08"PRIx32, compat_pvr); return; } else if (!ppc_check_compat(cpu, compat_pvr, 0, 0)) { error_setg(errp, "Compatibility PVR 0x%08"PRIx32" not valid for CPU", compat_pvr); return; } else { pcr = compat->pcr; } cpu_synchronize_state(CPU(cpu)); cpu->compat_pvr = compat_pvr; env->spr[SPR_PCR] = pcr & pcc->pcr_mask; if (kvm_enabled()) { int ret = kvmppc_set_compat(cpu, cpu->compat_pvr); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to set CPU compatibility mode in KVM"); } } }
int ppc_compat_max_threads(PowerPCCPU *cpu) { const CompatInfo *compat = compat_by_pvr(cpu->compat_pvr); int n_threads = CPU(cpu)->nr_threads; if (cpu->compat_pvr) { g_assert(compat); n_threads = MIN(n_threads, compat->max_threads); } return n_threads; }
static void ppc_compat_prop_get(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { uint32_t compat_pvr = *((uint32_t *)opaque); const char *value; if (!compat_pvr) { value = ""; } else { const CompatInfo *compat = compat_by_pvr(compat_pvr); g_assert(compat); value = compat->name; } visit_type_str(v, name, (char **)&value, errp); }