The generic models use PVRs 0x80230020, 0x80240020 and 0x80400020.
The default PVR callback is an exact comparison, so KVM's fallback
lookup fails on various P/T-series SoCs and the VMM cannot register
the host CPU type.

Match the architected core-version field in the upper 16 bits for
all three families, allowing differences in the revision field.

Signed-off-by: Bin Meng <[email protected]>


---

Changes in v3:
- New

 target/ppc/cpu_init.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index a2da7c509d..42d69d0865 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -3159,6 +3159,12 @@ POWERPC_FAMILY(e500v2)(ObjectClass *oc, const void *data)
                  POWERPC_FLAG_BUS_CLK;
 }
 
+static bool ppc_pvr_match_booke(PowerPCCPUClass *pcc, uint32_t pvr, bool best)
+{
+    /* Match the core version while allowing hardware revision differences */
+    return (pvr & 0xffff0000) == (pcc->pvr & 0xffff0000);
+}
+
 static void init_proc_e500mc(CPUPPCState *env)
 {
     init_proc_e500(env, fsl_e500mc);
@@ -3170,6 +3176,7 @@ POWERPC_FAMILY(e500mc)(ObjectClass *oc, const void *data)
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
 
     dc->desc = "e500mc core";
+    pcc->pvr_match = ppc_pvr_match_booke;
     pcc->init_proc = init_proc_e500mc;
     pcc->check_pow = check_pow_none;
     pcc->check_attn = check_attn_none;
@@ -3218,6 +3225,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, const void *data)
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
 
     dc->desc = "e5500 core";
+    pcc->pvr_match = ppc_pvr_match_booke;
     pcc->init_proc = init_proc_e5500;
     pcc->check_pow = check_pow_none;
     pcc->check_attn = check_attn_none;
@@ -3268,6 +3276,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, const void *data)
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
 
     dc->desc = "e6500 core";
+    pcc->pvr_match = ppc_pvr_match_booke;
     pcc->init_proc = init_proc_e6500;
     pcc->check_pow = check_pow_none;
     pcc->check_attn = check_attn_none;
-- 
2.53.0


Reply via email to