Patchwork [1/2,v3] target-ppc: Get CPU name to correct reflect its model in the SLOF device tree.

login
register
mail settings
Submitter Prerna Saxena
Date Aug. 8, 2013, 7:24 a.m.
Message ID <20130808125455.2ba5a8b4@zephyr>
Download mbox | patch
Permalink /patch/265675/
State New
Headers show

Comments

Prerna Saxena - Aug. 8, 2013, 7:24 a.m.
From: Andreas Farber <afaerber@suse.de>
Date: Wed, 7 Aug 2013 14:50:41 +0530
Subject: [PATCH 1/2] By default on KVM or when user asks for it via -cpu
 host, cpu_model will be "host" and sPAPR merely
 upper-cases it for the SLOF device tree.

Change it so that we get the underlying CPU type, e.g., "POWER7_V2.3@0".

Tested-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/ppc/spapr.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 16bfab9..59e2fea 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1072,7 +1072,7 @@  static void ppc_spapr_init(QEMUMachineInitArgs *args)
     const char *kernel_cmdline = args->kernel_cmdline;
     const char *initrd_filename = args->initrd_filename;
     const char *boot_device = args->boot_device;
-    PowerPCCPU *cpu;
+    PowerPCCPU *cpu = NULL;
     CPUPPCState *env;
     PCIHostState *phb;
     int i;
@@ -1307,6 +1307,16 @@  static void ppc_spapr_init(QEMUMachineInitArgs *args)
     register_savevm_live(NULL, "spapr/htab", -1, 1,
                          &savevm_htab_handlers, spapr);
 
+    if (kvm_enabled() && strcmp(cpu_model, "host") == 0) {
+        ObjectClass *cpu_class = object_get_class(OBJECT(cpu));
+        ObjectClass *parent_cpu_class = object_class_get_parent(cpu_class);
+
+        const char *parent_name = object_class_get_name(parent_cpu_class);
+
+        cpu_model = g_strndup(parent_name,
+            strlen(parent_name) - strlen("-" TYPE_POWERPC_CPU));
+    }
+
     /* Prepare the device tree */
     spapr->fdt_skel = spapr_create_fdt_skel(cpu_model,
                                             initrd_base, initrd_size,