76daa3
From 4fbb9c18f0a43c8dea773ef3a115f43492e3a971 Mon Sep 17 00:00:00 2001
76daa3
From: David Gibson <dgibson@redhat.com>
76daa3
Date: Wed, 17 May 2017 02:23:23 +0200
76daa3
Subject: [PATCH 07/27] target/ppc: Allow workarounds for POWER9 DD1
76daa3
76daa3
RH-Author: David Gibson <dgibson@redhat.com>
76daa3
Message-id: <20170517022323.16930-3-dgibson@redhat.com>
76daa3
Patchwork-id: 75202
76daa3
O-Subject: [Pegas-1.0 qemu-kvm-rhev PATCH 2/2] target/ppc: Allow workarounds for POWER9 DD1
76daa3
Bugzilla: 1443289
76daa3
RH-Acked-by: Thomas Huth <thuth@redhat.com>
76daa3
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
76daa3
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
76daa3
76daa3
From: David Gibson <david@gibson.dropbear.id.au>
76daa3
76daa3
POWER9 DD1 silicon has some bugs which mean it a) isn't really compliant
76daa3
with the ISA v3.00 and b) require a number of special workarounds in the
76daa3
kernel.
76daa3
76daa3
At the moment, qemu isn't aware of DD1.  For TCG we don't really want it to
76daa3
be (why bother emulating buggy silicon).  But with KVM, the guest does need
76daa3
to be aware of DD1 so it can apply the necessary workarounds.
76daa3
76daa3
Meanwhile, the feature negotiation between qemu and the guest strongly
76daa3
favours architected compatibility modes to "raw" CPU modes.  In combination
76daa3
with the above, this means the guest sees architected POWER9 mode, and
76daa3
doesn't apply the DD1 workarounds.  Well, unless it has yet another
76daa3
workaround to partially ignore what qemu tells it.
76daa3
76daa3
This patch addresses this by disabling support for compatibility modes when
76daa3
using KVM on a POWER9 DD1 host.
76daa3
76daa3
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
76daa3
(cherry picked from commit 5f3066d8b1063b364cd42d64bc011a56fae9c086)
76daa3
76daa3
Signed-off-by: David Gibson <dgibson@redhat.com>
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
---
76daa3
 target/ppc/cpu-models.h |  1 +
76daa3
 target/ppc/kvm.c        | 11 +++++++++++
76daa3
 2 files changed, 12 insertions(+)
76daa3
76daa3
diff --git a/target/ppc/cpu-models.h b/target/ppc/cpu-models.h
76daa3
index d587e69..b563c45 100644
76daa3
--- a/target/ppc/cpu-models.h
76daa3
+++ b/target/ppc/cpu-models.h
76daa3
@@ -561,6 +561,7 @@ enum {
76daa3
     CPU_POWERPC_POWER8NVL_BASE     = 0x004C0000,
76daa3
     CPU_POWERPC_POWER8NVL_v10      = 0x004C0100,
76daa3
     CPU_POWERPC_POWER9_BASE        = 0x004E0000,
76daa3
+    CPU_POWERPC_POWER9_DD1         = 0x004E0100,
76daa3
     CPU_POWERPC_970_v22            = 0x00390202,
76daa3
     CPU_POWERPC_970FX_v10          = 0x00391100,
76daa3
     CPU_POWERPC_970FX_v20          = 0x003C0200,
76daa3
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
76daa3
index 43afa4e..1765204 100644
76daa3
--- a/target/ppc/kvm.c
76daa3
+++ b/target/ppc/kvm.c
76daa3
@@ -2371,6 +2371,17 @@ static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)
76daa3
 
76daa3
 #if defined(TARGET_PPC64)
76daa3
     pcc->radix_page_info = kvm_get_radix_page_info();
76daa3
+
76daa3
+    if ((pcc->pvr & 0xffffff00) == CPU_POWERPC_POWER9_DD1) {
76daa3
+        /*
76daa3
+         * POWER9 DD1 has some bugs which make it not really ISA 3.00
76daa3
+         * compliant.  More importantly, advertising ISA 3.00
76daa3
+         * architected mode may prevent guests from activating
76daa3
+         * necessary DD1 workarounds.
76daa3
+         */
76daa3
+        pcc->pcr_supported &= ~(PCR_COMPAT_3_00 | PCR_COMPAT_2_07
76daa3
+                                | PCR_COMPAT_2_06 | PCR_COMPAT_2_05);
76daa3
+    }
76daa3
 #endif /* defined(TARGET_PPC64) */
76daa3
 }
76daa3
 
76daa3
-- 
76daa3
1.8.3.1
76daa3