Skip to contentSkip to conversation

target/ppc: Return default CPU for max CPU

PATCH Applied Murilo Opsfelder Araujo 3 participants 3 messages Jun 28, 2022 – Jul 2, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/ppc: Return default CPU for max CPU

All ppc CPUs represent hardware that exists in the real world, i.e.: we do not have a "max" CPU with all possible emulated features enabled. Return the default CPU type for the machine because that has greater chance of being useful as the "max" CPU.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1038

Cc Cédric Le Goater <[email protected]>
Cc Daniel Henrique Barboza <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Greg Kurz <[email protected]>
Cc Matheus K. Ferst <[email protected]>
Cc Thomas Huth <[email protected]>

---
v2:
- Return the default CPU of the machine instead of hard-coded alias.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

 target/ppc/cpu-models.c |  1 -
 target/ppc/cpu_init.c   | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
target/ppc/cpu-models.c +0 -1
index 976be5e0d1..05589eb21d 100644
@@ -879,7 +879,6 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
     { "755", "755_v2.8" },
     { "goldfinger", "755_v2.8" },
     { "7400", "7400_v2.9" },
-    { "max", "7400_v2.9" },
     { "g4",  "7400_v2.9" },
     { "7410", "7410_v1.4" },
     { "nitro", "7410_v1.4" },
target/ppc/cpu_init.c +19 -0
index c16cb8dbe7..8ee0b7c785 100644
@@ -47,6 +47,10 @@
 #include "spr_common.h"
 #include "power8-pmu.h"
 
+#ifndef CONFIG_USER_ONLY
+#include "hw/boards.h"
+#endif
+
 /* #define PPC_DEBUG_SPR */
 /* #define USE_APPLE_GDB */
 
@@ -6963,6 +6967,21 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
         }
     }
 
+    /*
+     * All ppc CPUs represent hardware that exists in the real world, i.e.: we
+     * do not have a "max" CPU with all possible emulated features enabled.
+     * Return the default CPU type for the machine because that has greater
+     * chance of being useful as the "max" CPU.
+     */
+#if !defined(CONFIG_USER_ONLY)
+    if (strcmp(name, "max") == 0) {
+        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+        if (mc) {
+            return object_class_by_name(mc->default_cpu_type);
+        }
+    }
+#endif
+
     cpu_model = g_ascii_strdown(name, -1);
     p = ppc_cpu_lookup_alias(cpu_model);
     if (p) {
Signature · 1 line
2.36.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 74 lines · Murilo Opsfelder Araujo

All ppc CPUs represent hardware that exists in the real world, i.e.: we do not have a "max" CPU with all possible emulated features enabled. Return the default CPU type for the machine because that has greater chance of being useful as the "max" CPU.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1038

Cc Cédric Le Goater <[email protected]>
Cc Daniel Henrique Barboza <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Greg Kurz <[email protected]>
Cc Matheus K. Ferst <[email protected]>
Cc Thomas Huth <[email protected]>

---
v2:
- Return the default CPU of the machine instead of hard-coded alias.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

  target/ppc/cpu-models.c |  1 -
  target/ppc/cpu_init.c   | 19 +++++++++++++++++++
  2 files changed, 19 insertions(+), 1 deletion(-)
target/ppc/cpu-models.c +0 -1
index 976be5e0d1..05589eb21d 100644
@@ -879,7 +879,6 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
      { "755", "755_v2.8" },
      { "goldfinger", "755_v2.8" },
      { "7400", "7400_v2.9" },
-    { "max", "7400_v2.9" },
      { "g4",  "7400_v2.9" },
      { "7410", "7410_v1.4" },
      { "nitro", "7410_v1.4" },
target/ppc/cpu_init.c +19 -1
index c16cb8dbe7..8ee0b7c785 100644
@@ -47,6 +47,10 @@
  #include "spr_common.h"
  #include "power8-pmu.h"
 
+#ifndef CONFIG_USER_ONLY
+#include "hw/boards.h"
+#endif
+
  /* #define PPC_DEBUG_SPR */
  /* #define USE_APPLE_GDB */
 
@@ -6963,6 +6967,21 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
          }
      }
 
+    /*
+     * All ppc CPUs represent hardware that exists in the real world, i.e.: we
+     * do not have a "max" CPU with all possible emulated features enabled.
+     * Return the default CPU type for the machine because that has greater
+     * chance of being useful as the "max" CPU.
+     */
+#if !defined(CONFIG_USER_ONLY)
+    if (strcmp(name, "max") == 0) {
+        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+        if (mc) {
+            return object_class_by_name(mc->default_cpu_type);
+        }
+    }
+#endif
+
      cpu_model = g_ascii_strdown(name, -1);
      p = ppc_cpu_lookup_alias(cpu_model);
      if (p) {
--
Quoted 3 lines

2.36.1

Best regards,

Signature · 3 lines
Víctor Cora Colombo
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
#2 lore raw
In reply to Murilo Opsfelder Araujo
Quoted 14 lines · Murilo Opsfelder Araujo

All ppc CPUs represent hardware that exists in the real world, i.e.: we do not have a "max" CPU with all possible emulated features enabled. Return the default CPU type for the machine because that has greater chance of being useful as the "max" CPU.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1038

Cc Cédric Le Goater <[email protected]>
Cc Daniel Henrique Barboza <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Greg Kurz <[email protected]>
Cc Matheus K. Ferst <[email protected]>
Cc Thomas Huth <[email protected]>
Quoted 1 line

---

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,

Daniel

Quoted 58 lines

v2:
- Return the default CPU of the machine instead of hard-coded alias.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

  target/ppc/cpu-models.c |  1 -
  target/ppc/cpu_init.c   | 19 +++++++++++++++++++
  2 files changed, 19 insertions(+), 1 deletion(-)
target/ppc/cpu-models.c +0 -1
index 976be5e0d1..05589eb21d 100644
@@ -879,7 +879,6 @@ PowerPCCPUAlias ppc_cpu_aliases[] = {
      { "755", "755_v2.8" },
      { "goldfinger", "755_v2.8" },
      { "7400", "7400_v2.9" },
-    { "max", "7400_v2.9" },
      { "g4",  "7400_v2.9" },
      { "7410", "7410_v1.4" },
      { "nitro", "7410_v1.4" },
target/ppc/cpu_init.c +19 -0
index c16cb8dbe7..8ee0b7c785 100644
@@ -47,6 +47,10 @@
  #include "spr_common.h"
  #include "power8-pmu.h"
 
+#ifndef CONFIG_USER_ONLY
+#include "hw/boards.h"
+#endif
+
  /* #define PPC_DEBUG_SPR */
  /* #define USE_APPLE_GDB */
 
@@ -6963,6 +6967,21 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
          }
      }
 
+    /*
+     * All ppc CPUs represent hardware that exists in the real world, i.e.: we
+     * do not have a "max" CPU with all possible emulated features enabled.
+     * Return the default CPU type for the machine because that has greater
+     * chance of being useful as the "max" CPU.
+     */
+#if !defined(CONFIG_USER_ONLY)
+    if (strcmp(name, "max") == 0) {
+        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+        if (mc) {
+            return object_class_by_name(mc->default_cpu_type);
+        }
+    }
+#endif
+
      cpu_model = g_ascii_strdown(name, -1);
      p = ppc_cpu_lookup_alias(cpu_model);
      if (p) {