target-ppc: Add compatibility between P7/P7+ and P8E/P8
RFC PATCH 1/1 target-ppc: Add compatibility between P7/P7+ and P8E/P8
At the moment POWER7+ and POWER7 CPUs are different incompatible families in QOM. The same is valid for POWER8E and POWER8 CPUs. However, these couples are architecturally equal and there is no good reason, for example, not to let run -cpu POWER7 on the real POWER7+ CPU machine.
This introduces one more level in hierarchy of POWERPC CPU classes. New macro POWERPC_FAMILY_2 takes a family class and the parent family class and, for example, for POWER7+ the hierarchy looks like:TYPE_CPUTYPE_POWERPC_CPU
POWER7-powerpc64-cpu
POWER7+-powerpc64-cpu
This registers new dynamic POWERPC CPU classes for all classes between the lowest one which matches the real PVR and TYPE_POWERPC_CPU. So for POWER7, it is still going to be just a single dynamic "POWER7" class but for POWER7+ inherited from POWER7 there are going to be 2 dynamic classes - "POWER7+" and "POWER7" so management software can use both to ensure successful migration.
Since POWER7+ inherits from POWER7 and POWER8E from POWER8, this removes recurring pieces of code. CPUs with shorter names were chosen as parents.
---
This is rather RFC patch and there is no hurry in reviewing this, and this is not 2.1 material and everyhting, just tried to solve a QOM puzzle here :)
--- target-ppc/kvm.c | 28 ++++++---------- target-ppc/translate_init.c | 82 +++++++++++---------------------------------- 2 files changed, 30 insertions(+), 80 deletions(-)
target-ppc/kvm.c +11 -17
@@ -38,6 +38,7 @@#include "hw/ppc/ppc.h" #include "sysemu/watchdog.h" #include "trace.h" +#include "cpu-models.h" //#define DEBUG_KVM
@@ -1828,18 +1829,6 @@ bool kvmppc_has_cap_fixup_hcalls(void)return cap_fixup_hcalls; } -static PowerPCCPUClass *ppc_cpu_get_family_class (PowerPCCPUClass *pcc) -{ -ObjectClass *oc =OBJECT_CLASS (pcc); - -while (oc && !object_class_is_abstract (oc)) { - oc =object_class_get_parent (oc); - } -assert (oc); - -return POWERPC_CPU_CLASS (oc); -} -static int kvm_ppc_register_host_cpu_type (void ) {TypeInfo type_info = {
@@ -1850,6 +1839,7 @@ static int kvm_ppc_register_host_cpu_type(void)uint32_t host_pvr =mfpvr ();PowerPCCPUClass *pvr_pcc;DeviceClass *dc; +ObjectClass *oc; pvr_pcc =ppc_cpu_class_by_pvr (host_pvr);if (pvr_pcc ==NULL ) {
@@ -1862,11 +1852,15 @@ static int kvm_ppc_register_host_cpu_type(void)type_register (&type_info);/* Register generic family CPU class for a family */ - pvr_pcc =ppc_cpu_get_family_class (pvr_pcc); - dc =DEVICE_CLASS (pvr_pcc); - type_info.parent =object_class_get_name (OBJECT_CLASS (pvr_pcc)); - type_info.name =g_strdup_printf ("%s-" TYPE_POWERPC_CPU , dc->desc); -type_register (&type_info); +while (pvr_pcc && (pvr_pcc->pvr_mask !=CPU_POWERPC_DEFAULT_MASK )) { + dc =DEVICE_CLASS (pvr_pcc); + oc =OBJECT_CLASS (pvr_pcc); + type_info.parent =object_class_get_name (oc); + type_info.name =g_strdup_printf ("%s-" TYPE_POWERPC_CPU , dc->desc); +type_register (&type_info); + + pvr_pcc =POWERPC_CPU_CLASS (object_class_get_parent (oc)); + }return 0 ; }
target-ppc/translate_init.c +19 -63
136 lines not on this page · raw message
Signature · 1 line
2.0.0
Quoted 25 lines · Alexey Kardashevskiy
At the moment POWER7+ and POWER7 CPUs are different incompatible families in QOM. The same is valid for POWER8E and POWER8 CPUs. However, these couples are architecturally equal and there is no good reason, for example, not to let run -cpu POWER7 on the real POWER7+ CPU machine.
This introduces one more level in hierarchy of POWERPC CPU classes. New macro
POWERPC_FAMILY_2takes a family class and the parent family class and, for example, for POWER7+ the hierarchy looks like:TYPE_CPUTYPE_POWERPC_CPU
POWER7-powerpc64-cpu
POWER7+-powerpc64-cpuThis registers new dynamic POWERPC CPU classes for all classes between the lowest one which matches the real PVR and
TYPE_POWERPC_CPU. So for POWER7, it is still going to be just a single dynamic "POWER7" class but for POWER7+ inherited from POWER7 there are going to be 2 dynamic classes - "POWER7+" and "POWER7" so management software can use both to ensure successful migration.Since POWER7+ inherits from POWER7 and POWER8E from POWER8, this removes recurring pieces of code. CPUs with shorter names were chosen as parents.
Quoted 6 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
This is rather RFC patch and there is no hurry in reviewing this, and this is not 2.1 material and everyhting, just tried to solve a QOM puzzle here :)
I'm not sure - I'd rather make sure we have this sorted out for 2.1 so we can keep the -cpu list stable.
Could we make the PVR matching a function callback rather than value+mask? Then we could have p7 and p8 just match on 2 different PVR ranges.
Alex
Quoted 34 lines · Alexander Graf
Quoted 25 lines · Alexey Kardashevskiy
At the moment POWER7+ and POWER7 CPUs are different incompatible families in QOM. The same is valid for POWER8E and POWER8 CPUs. However, these couples are architecturally equal and there is no good reason, for example, not to let run -cpu POWER7 on the real POWER7+ CPU machine.
This introduces one more level in hierarchy of POWERPC CPU classes. New macro
POWERPC_FAMILY_2takes a family class and the parent family class and, for example, for POWER7+ the hierarchy looks like:TYPE_CPUTYPE_POWERPC_CPU
POWER7-powerpc64-cpu
POWER7+-powerpc64-cpuThis registers new dynamic POWERPC CPU classes for all classes between the lowest one which matches the real PVR and
TYPE_POWERPC_CPU. So for POWER7, it is still going to be just a single dynamic "POWER7" class but for POWER7+ inherited from POWER7 there are going to be 2 dynamic classes - "POWER7+" and "POWER7" so management software can use both to ensure successful migration.Since POWER7+ inherits from POWER7 and POWER8E from POWER8, this removes recurring pieces of code. CPUs with shorter names were chosen as parents.
Quoted 6 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
This is rather RFC patch and there is no hurry in reviewing this, and this is not 2.1 material and everyhting, just tried to solve a QOM puzzle here :)
Quoted 5 lines
I'm not sure - I'd rather make sure we have this sorted out for 2.1 so we can keep the -cpu list stable.
Could we make the PVR matching a function callback rather than value+mask? Then we could have p7 and p8 just match on 2 different PVR ranges.
POWER8:
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4d)
'0b1001101'
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4b)
'0b1001011'
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4c)
'0b1001100'
4D == POWER8, 4B == POWER8E, 4C - does not exist and when it will, I do not know what it is going to be.
POWER7:
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x3f)
'0b111111'
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4a)
'0b1001010'
Quoted 1 line
Quoted 1 line
Quoted 1 line
What should mask look like for P7 and P8?
Signature · 1 line
Alexey
Quoted 53 lines · Alexey Kardashevskiy
Quoted 34 lines · Alexander Graf
Quoted 25 lines · Alexey Kardashevskiy
At the moment POWER7+ and POWER7 CPUs are different incompatible families in QOM. The same is valid for POWER8E and POWER8 CPUs. However, these couples are architecturally equal and there is no good reason, for example, not to let run -cpu POWER7 on the real POWER7+ CPU machine.
This introduces one more level in hierarchy of POWERPC CPU classes. New macro
POWERPC_FAMILY_2takes a family class and the parent family class and, for example, for POWER7+ the hierarchy looks like:TYPE_CPUTYPE_POWERPC_CPU
POWER7-powerpc64-cpu
POWER7+-powerpc64-cpuThis registers new dynamic POWERPC CPU classes for all classes between the lowest one which matches the real PVR and
TYPE_POWERPC_CPU. So for POWER7, it is still going to be just a single dynamic "POWER7" class but for POWER7+ inherited from POWER7 there are going to be 2 dynamic classes - "POWER7+" and "POWER7" so management software can use both to ensure successful migration.Since POWER7+ inherits from POWER7 and POWER8E from POWER8, this removes recurring pieces of code. CPUs with shorter names were chosen as parents.
Quoted 6 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
This is rather RFC patch and there is no hurry in reviewing this, and this is not 2.1 material and everyhting, just tried to solve a QOM puzzle here :)
Quoted 5 lines
I'm not sure - I'd rather make sure we have this sorted out for 2.1 so we can keep the -cpu list stable.
Could we make the PVR matching a function callback rather than value+mask? Then we could have p7 and p8 just match on 2 different PVR ranges.
POWER8:
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4d)
'
0b1001101'Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4b)
'
0b1001011'Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4c)
'
0b1001100'4D == POWER8, 4B == POWER8E, 4C - does not exist and when it will, I do not know what it is going to be.
POWER7:
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x3f)
'
0b111111'Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4a)
'
0b1001010'Quoted 1 line
Quoted 1 line
Quoted 1 line
What should mask look like for P7 and P8?
Re-read your email :) Callback you say... And we will loose POWER7+ and POWER8E. May it is all right as we drop bottom 16bits already...
Signature · 1 line
Alexey
Quoted 57 lines · Alexey Kardashevskiy
Quoted 56 lines · Alexey Kardashevskiy
Quoted 34 lines · Alexander Graf
Quoted 25 lines · Alexey Kardashevskiy
At the moment POWER7+ and POWER7 CPUs are different incompatible families in QOM. The same is valid for POWER8E and POWER8 CPUs. However, these couples are architecturally equal and there is no good reason, for example, not to let run -cpu POWER7 on the real POWER7+ CPU machine.
This introduces one more level in hierarchy of POWERPC CPU classes. New macro
POWERPC_FAMILY_2takes a family class and the parent family class and, for example, for POWER7+ the hierarchy looks like:TYPE_CPUTYPE_POWERPC_CPU
POWER7-powerpc64-cpu
POWER7+-powerpc64-cpuThis registers new dynamic POWERPC CPU classes for all classes between the lowest one which matches the real PVR and
TYPE_POWERPC_CPU. So for POWER7, it is still going to be just a single dynamic "POWER7" class but for POWER7+ inherited from POWER7 there are going to be 2 dynamic classes - "POWER7+" and "POWER7" so management software can use both to ensure successful migration.Since POWER7+ inherits from POWER7 and POWER8E from POWER8, this removes recurring pieces of code. CPUs with shorter names were chosen as parents.
Quoted 6 lines
Signed-off-by Alexey Kardashevskiy <[email protected]>---
This is rather RFC patch and there is no hurry in reviewing this, and this is not 2.1 material and everyhting, just tried to solve a QOM puzzle here :)
Quoted 5 lines
I'm not sure - I'd rather make sure we have this sorted out for 2.1 so we can keep the -cpu list stable.
Could we make the PVR matching a function callback rather than value+mask? Then we could have p7 and p8 just match on 2 different PVR ranges.
POWER8:
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4d)
'
0b1001101'Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4b)
'
0b1001011'Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4c)
'
0b1001100'4D == POWER8, 4B == POWER8E, 4C - does not exist and when it will, I do not know what it is going to be.
POWER7:
Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x3f)
'
0b111111'Quoted 1 line
Quoted 1 line
Quoted 1 line
bin(0x4a)
Quoted 8 lines
Quoted 5 lines
'
0b1001010'Quoted 1 line
Quoted 1 line
Quoted 1 line
What should mask look like for P7 and P8?
Re-read your email :) Callback you say... And we will loose POWER7+ and POWER8E. May it is all right as we drop bottom 16bits already...
Ufff. Ok, I tried adding a callback:
int (*pvr_match)(uint32_t pvr);
Ok. Then POWER7 has fw_name = "PowerPC,POWER7" and POWER7+ has fw_name = "PowerPC,POWER7+". Hosts use the same names, with and without "+", QEMU uses them to make up CPU nodes in /proc/device-tree/cpus/. If it is going to be one CPU class, won't we need yet another callback for these fw_name's?
And this fw_path is just a field (or a typename is used if fw_path==NULL) and since it is a DeviceState's property and used directly, I cannot intercept this so I need to hack the original class somehow.
Make it
int (*pvr_match_and_init_fw_path_if_matched)(uint32_t pvr); ?
Signature · 1 line
Alexey