* [Qemu-devel] [PATCH v2 0/3] target-ppc: Relax use of generic CPU name for KVM
@ 2014-04-11 17:34 Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 1/3] target-ppc: Create versionless CPU class per family if KVM Alexey Kardashevskiy
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-04-11 17:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf
This enables generic CPU family name use with "-cpu" for all CPUs
across the family and not for the ones already defined in QEMU.
Changes:
v2:
* split one patch into 3
* added assert into ppc_cpu_get_family_class()
Alexey Kardashevskiy (3):
target-ppc: Create versionless CPU class per family if KVM
target-ppc: Move alias lookup after class lookup
target-ppc: Remove redundant POWER7 declarations
target-ppc/cpu-models.c | 4 ----
target-ppc/cpu-models.h | 2 --
target-ppc/kvm.c | 21 +++++++++++++++++++++
target-ppc/translate_init.c | 18 +++++++++++-------
4 files changed, 32 insertions(+), 13 deletions(-)
--
1.8.4.rc4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] target-ppc: Create versionless CPU class per family if KVM
2014-04-11 17:34 [Qemu-devel] [PATCH v2 0/3] target-ppc: Relax use of generic CPU name for KVM Alexey Kardashevskiy
@ 2014-04-11 17:34 ` Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 2/3] target-ppc: Move alias lookup after class lookup Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 3/3] target-ppc: Remove redundant POWER7 declarations Alexey Kardashevskiy
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-04-11 17:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf
At the moment generic version-less CPUs are supported via hardcoded aliases.
For example, POWER7 is an alias for POWER7_v2.1. So when QEMU is started
with -cpu POWER7, the POWER7_v2.1 class instance is created.
This approach works for TCG and KVMs other than HV KVM. HV KVM cannot emulate
PVR value so the guest always sees the real PVR. HV KVM will not allow setting
PVR other that the host PVR because of that (the kernel patch for it is on
its way). So in most cases it is impossible to run QEMU with -cpu POWER7
unless the host PVR is exactly the same as the one from the alias (which
is now POWER7_v2.3). It was decided that under HV KVM QEMU should use
-cpu host.
Using "host" CPU type creates a problem for management tools such as libvirt
because they want to know in advance if the destination guest can possibly
run on the destination. Since the "host" type is really not a type and will
always work with any KVM, there is no way for libvirt to know if the migration
will success.
This registers additional CPU class derived from the host CPU family.
The name for it is taken from @desc field of the CPU family class.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
target-ppc/kvm.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 8083ba9..cc4b26c 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1778,6 +1778,18 @@ bool kvmppc_has_cap_htab_fd(void)
return cap_htab_fd;
}
+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 = {
@@ -1787,6 +1799,7 @@ static int kvm_ppc_register_host_cpu_type(void)
};
uint32_t host_pvr = mfpvr();
PowerPCCPUClass *pvr_pcc;
+ DeviceClass *dc;
pvr_pcc = ppc_cpu_class_by_pvr(host_pvr);
if (pvr_pcc == NULL) {
@@ -1797,6 +1810,14 @@ static int kvm_ppc_register_host_cpu_type(void)
}
type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
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);
+
return 0;
}
--
1.8.4.rc4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] target-ppc: Move alias lookup after class lookup
2014-04-11 17:34 [Qemu-devel] [PATCH v2 0/3] target-ppc: Relax use of generic CPU name for KVM Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 1/3] target-ppc: Create versionless CPU class per family if KVM Alexey Kardashevskiy
@ 2014-04-11 17:34 ` Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 3/3] target-ppc: Remove redundant POWER7 declarations Alexey Kardashevskiy
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-04-11 17:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf
This moves aliases lookup after CPU class lookup. This is to let new generic
CPU to be found first if it is present and only if it is not (TCG case), use
aliases.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
target-ppc/translate_init.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index c7afa62..709094c 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8228,12 +8228,6 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
}
}
- for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
- if (strcmp(ppc_cpu_aliases[i].alias, name) == 0) {
- return ppc_cpu_class_by_alias(&ppc_cpu_aliases[i]);
- }
- }
-
list = object_class_get_list(TYPE_POWERPC_CPU, false);
item = g_slist_find_custom(list, name, ppc_cpu_compare_class_name);
if (item != NULL) {
@@ -8241,7 +8235,17 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
}
g_slist_free(list);
- return ret;
+ if (ret) {
+ return ret;
+ }
+
+ for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
+ if (strcmp(ppc_cpu_aliases[i].alias, name) == 0) {
+ return ppc_cpu_class_by_alias(&ppc_cpu_aliases[i]);
+ }
+ }
+
+ return NULL;
}
PowerPCCPU *cpu_ppc_init(const char *cpu_model)
--
1.8.4.rc4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] target-ppc: Remove redundant POWER7 declarations
2014-04-11 17:34 [Qemu-devel] [PATCH v2 0/3] target-ppc: Relax use of generic CPU name for KVM Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 1/3] target-ppc: Create versionless CPU class per family if KVM Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 2/3] target-ppc: Move alias lookup after class lookup Alexey Kardashevskiy
@ 2014-04-11 17:34 ` Alexey Kardashevskiy
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-04-11 17:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf
At the moment there are 3 versions of POWER7 CPUs defined. However
we do not emulate these CPUs diffent and it does not make much
sense to keep them all.
This removes POWER7_v2.0 and POWER7_v2.1 and leaves just one versioned
CPU per family which is POWER7_v2.3 with POWER7 alias.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
target-ppc/cpu-models.c | 4 ----
target-ppc/cpu-models.h | 2 --
2 files changed, 6 deletions(-)
diff --git a/target-ppc/cpu-models.c b/target-ppc/cpu-models.c
index f6c9b3a..57cb4e4 100644
--- a/target-ppc/cpu-models.c
+++ b/target-ppc/cpu-models.c
@@ -1134,10 +1134,6 @@
POWERPC_DEF("POWER6A", CPU_POWERPC_POWER6A, POWER6,
"POWER6A")
#endif
- POWERPC_DEF("POWER7_v2.0", CPU_POWERPC_POWER7_v20, POWER7,
- "POWER7 v2.0")
- POWERPC_DEF("POWER7_v2.1", CPU_POWERPC_POWER7_v21, POWER7,
- "POWER7 v2.1")
POWERPC_DEF("POWER7_v2.3", CPU_POWERPC_POWER7_v23, POWER7,
"POWER7 v2.3")
POWERPC_DEF("POWER7+_v2.1", CPU_POWERPC_POWER7P_v21, POWER7P,
diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
index 644a126..9a003b4 100644
--- a/target-ppc/cpu-models.h
+++ b/target-ppc/cpu-models.h
@@ -555,8 +555,6 @@ enum {
CPU_POWERPC_POWER6A = 0x0F000002,
CPU_POWERPC_POWER7_BASE = 0x003F0000,
CPU_POWERPC_POWER7_MASK = 0xFFFF0000,
- CPU_POWERPC_POWER7_v20 = 0x003F0200,
- CPU_POWERPC_POWER7_v21 = 0x003F0201,
CPU_POWERPC_POWER7_v23 = 0x003F0203,
CPU_POWERPC_POWER7P_BASE = 0x004A0000,
CPU_POWERPC_POWER7P_MASK = 0xFFFF0000,
--
1.8.4.rc4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-11 17:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11 17:34 [Qemu-devel] [PATCH v2 0/3] target-ppc: Relax use of generic CPU name for KVM Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 1/3] target-ppc: Create versionless CPU class per family if KVM Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 2/3] target-ppc: Move alias lookup after class lookup Alexey Kardashevskiy
2014-04-11 17:34 ` [Qemu-devel] [PATCH v2 3/3] target-ppc: Remove redundant POWER7 declarations Alexey Kardashevskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).