Blame SOURCES/kvm-target-ppc-Don-t-require-private-l1d-cache-on-POWER8.patch

357786
From 9d53600d84c407efde9e186b814badca245cc6ab Mon Sep 17 00:00:00 2001
357786
From: Suraj Jitindar Singh <sursingh@redhat.com>
357786
Date: Thu, 21 Jun 2018 06:56:48 +0200
357786
Subject: [PATCH 53/54] target/ppc: Don't require private l1d cache on POWER8
357786
 for cap_ppc_safe_cache
357786
357786
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
357786
Message-id: <1529564209-30369-3-git-send-email-sursingh@redhat.com>
357786
Patchwork-id: 80930
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/3] target/ppc: Don't require private l1d cache on POWER8 for cap_ppc_safe_cache
357786
Bugzilla: 1560847
357786
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
357786
RH-Acked-by: David Gibson <dgibson@redhat.com>
357786
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
357786
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
357786
357786
For cap_ppc_safe_cache to be set to workaround, we require both a l1d
357786
cache flush instruction and private l1d cache.
357786
357786
On POWER8 don't require private l1d cache. This means a guest on a
357786
POWER8 machine can make use of the cache flush workarounds.
357786
357786
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
357786
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
357786
(cherry picked from commit 072f416a53ead5211c987cb2068ee9dbd7ba06cc)
357786
357786
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1560847
357786
357786
Signed-off-by: Suraj Jitindar Singh <sursingh@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 target/ppc/kvm.c | 19 ++++++++++++++++++-
357786
 1 file changed, 18 insertions(+), 1 deletion(-)
357786
357786
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
357786
index d787032..192c40d 100644
357786
--- a/target/ppc/kvm.c
357786
+++ b/target/ppc/kvm.c
357786
@@ -2461,11 +2461,28 @@ bool kvmppc_has_cap_mmu_hash_v3(void)
357786
     return cap_mmu_hash_v3;
357786
 }
357786
 
357786
+static bool kvmppc_power8_host(void)
357786
+{
357786
+    bool ret = false;
357786
+#ifdef TARGET_PPC64
357786
+    {
357786
+        uint32_t base_pvr = CPU_POWERPC_POWER_SERVER_MASK & mfpvr();
357786
+        ret = (base_pvr == CPU_POWERPC_POWER8E_BASE) ||
357786
+              (base_pvr == CPU_POWERPC_POWER8NVL_BASE) ||
357786
+              (base_pvr == CPU_POWERPC_POWER8_BASE);
357786
+    }
357786
+#endif /* TARGET_PPC64 */
357786
+    return ret;
357786
+}
357786
+
357786
 static int parse_cap_ppc_safe_cache(struct kvm_ppc_cpu_char c)
357786
 {
357786
+    bool l1d_thread_priv_req = !kvmppc_power8_host();
357786
+
357786
     if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_L1D_FLUSH_PR) {
357786
         return 2;
357786
-    } else if ((c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) &&
357786
+    } else if ((!l1d_thread_priv_req ||
357786
+                c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) &&
357786
                (c.character & c.character_mask
357786
                 & (H_CPU_CHAR_L1D_FLUSH_ORI30 | H_CPU_CHAR_L1D_FLUSH_TRIG2))) {
357786
         return 1;
357786
-- 
357786
1.8.3.1
357786