e73cc6
From: Prerna Saxena <prerna@linux.vnet.ibm.com>
e73cc6
Date: Tue, 4 Nov 2014 22:58:33 +0530
e73cc6
Subject: [PATCH] PowerPC:Improve PVR handling to fall back to cpu generation.
e73cc6
e73cc6
IBM Power processors differ uniquely across generations (such as power6,
e73cc6
power7, power8). Each generation signifies a new PowerISA version
e73cc6
that exhibits features unique to that generation.
e73cc6
The higher 16 bits of PVR for IBM Power processors encode the CPU
e73cc6
generation, while the CPU chip (sub)version is encoded in lower 16 bits.
e73cc6
e73cc6
For all practical purposes of launching a VM, we care about the
e73cc6
generation which the vCPU will belong to, and not specifically the chip
e73cc6
version. This patch updates the libvirt PVR check to reflect this
e73cc6
relationship. It allows libvirt to select the right CPU generation
e73cc6
in case the exact match for a a specific CPU is not found.
e73cc6
Hence, there will no longer be a need to add each PowerPC CPU model to
e73cc6
cpu_map.xml; just adding entry for the matching ISA generation will
e73cc6
suffice.
e73cc6
e73cc6
It also contains changes to cpu_map.xml since processor generations
e73cc6
as understood by QEMU compat mode go as "power6", "power7" or "power8"
e73cc6
[Reference : QEMU commit 8dfa3a5e85 ]
e73cc6
e73cc6
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
e73cc6
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
e73cc6
Signed-off-by: Anton Blanchard <anton@samba.org>
e73cc6
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
e73cc6
(cherry picked from commit 1e911742287d964055f33ab76d53e673a9b4477f)
e73cc6
---
e73cc6
 src/cpu/cpu_map.xml   | 30 ++++++++++++++++++++++++++++++
e73cc6
 src/cpu/cpu_powerpc.c |  8 ++++++++
e73cc6
 2 files changed, 38 insertions(+)
e73cc6
e73cc6
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
e73cc6
index 18c7b0d..bd9b056 100644
e73cc6
--- a/src/cpu/cpu_map.xml
e73cc6
+++ b/src/cpu/cpu_map.xml
e73cc6
@@ -627,5 +627,35 @@
e73cc6
       <pvr value='0x004b0100'/>
e73cc6
     </model>
e73cc6
 
e73cc6
+    <model name='power6'>
e73cc6
+      <vendor name='IBM'/>
e73cc6
+      <compat isa='2.05'/>
e73cc6
+      <pvr value='0x003e0000'/>
e73cc6
+    </model>
e73cc6
+
e73cc6
+    <model name='power7'>
e73cc6
+      <vendor name='IBM'/>
e73cc6
+      <compat isa='2.06'/>
e73cc6
+      <pvr value='0x003f0000'/>
e73cc6
+    </model>
e73cc6
+
e73cc6
+    <model name='power7+'>
e73cc6
+      <vendor name='IBM'/>
e73cc6
+      <compat isa='2.06B'/>
e73cc6
+      <pvr value='0x004a0000'/>
e73cc6
+    </model>
e73cc6
+
e73cc6
+    <model name='power8e'>
e73cc6
+      <vendor name='IBM'/>
e73cc6
+      <compat isa='2.07'/>
e73cc6
+      <pvr value='0x004b0000'/>
e73cc6
+    </model>
e73cc6
+
e73cc6
+    <model name='power8'>
e73cc6
+      <vendor name='IBM'/>
e73cc6
+      <compat isa='2.07'/>
e73cc6
+      <pvr value='0x004d0000'/>
e73cc6
+    </model>
e73cc6
+
e73cc6
   </arch>
e73cc6
 </cpus>
e73cc6
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
e73cc6
index 4ea1835..531868c 100644
e73cc6
--- a/src/cpu/cpu_powerpc.c
e73cc6
+++ b/src/cpu/cpu_powerpc.c
e73cc6
@@ -99,6 +99,14 @@ ppcModelFindPVR(const struct ppc_map *map,
e73cc6
         model = model->next;
e73cc6
     }
e73cc6
 
e73cc6
+    /* PowerPC Processor Version Register is interpreted as follows :
e73cc6
+     * Higher order 16 bits : Power ISA generation.
e73cc6
+     * Lower order 16 bits : CPU chip version number.
e73cc6
+     * If the exact CPU isnt found, return the nearest matching CPU generation
e73cc6
+     */
e73cc6
+    if (pvr & 0x0000FFFFul)
e73cc6
+        return ppcModelFindPVR(map, (pvr & 0xFFFF0000ul));
e73cc6
+
e73cc6
     return NULL;
e73cc6
 }
e73cc6