Blame SOURCES/kvm-spapr-Handle-Decimal-Floating-Point-DFP-as-an-option.patch

4a2fec
From 4e2f29e8fef6d8428bed4a5c366e5cafd7b92a41 Mon Sep 17 00:00:00 2001
4a2fec
From: David Gibson <dgibson@redhat.com>
4a2fec
Date: Fri, 19 Jan 2018 02:34:40 +0100
4a2fec
Subject: [PATCH 12/21] spapr: Handle Decimal Floating Point (DFP) as an
4a2fec
 optional capability
4a2fec
4a2fec
RH-Author: David Gibson <dgibson@redhat.com>
4a2fec
Message-id: <20180119023442.28577-6-dgibson@redhat.com>
4a2fec
Patchwork-id: 78672
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 5/7] spapr: Handle Decimal Floating Point (DFP) as an optional capability
4a2fec
Bugzilla: 1523414
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
From: David Gibson <david@gibson.dropbear.id.au>
4a2fec
4a2fec
Decimal Floating Point has been available on POWER7 and later (server)
4a2fec
cpus.  However, it can be disabled on the hypervisor, meaning that it's
4a2fec
not available to guests.
4a2fec
4a2fec
We currently handle this by conditionally advertising DFP support in the
4a2fec
device tree depending on whether the guest CPU model supports it - which
4a2fec
can also depend on what's allowed in the host for -cpu host.  That can lead
4a2fec
to confusion on migration, since host properties are silently affecting
4a2fec
guest visible properties.
4a2fec
4a2fec
This patch handles it by treating it as an optional capability for the
4a2fec
pseries machine type.
4a2fec
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
Reviewed-by: Greg Kurz <groug@kaod.org>
4a2fec
(cherry picked from commit 2d1fb9bc8e6e78931d8e1bfeb0ed7a4d223b0480)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
Conflicts:
4a2fec
	hw/ppc/spapr.c
4a2fec
4a2fec
Due to differences between upstream and downstream machine type
4a2fec
versions.  As CAP_DFP is enabled for all upstream versions, enable it
4a2fec
for all downsteam as well.
4a2fec
4a2fec
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1523414
4a2fec
4a2fec
Signed-off-by: David Gibson <dgibson@redhat.com>
4a2fec
---
4a2fec
 hw/ppc/spapr.c         |  7 ++++---
4a2fec
 hw/ppc/spapr_caps.c    | 18 ++++++++++++++++++
4a2fec
 include/hw/ppc/spapr.h |  3 +++
4a2fec
 3 files changed, 25 insertions(+), 3 deletions(-)
4a2fec
4a2fec
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
4a2fec
index 0ef2af9..41cb2fa 100644
4a2fec
--- a/hw/ppc/spapr.c
4a2fec
+++ b/hw/ppc/spapr.c
4a2fec
@@ -575,7 +575,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
4a2fec
     /* Advertise DFP (Decimal Floating Point) if available
4a2fec
      *   0 / no property == no DFP
4a2fec
      *   1               == DFP available */
4a2fec
-    if (env->insns_flags2 & PPC2_DFP) {
4a2fec
+    if (spapr_has_cap(spapr, SPAPR_CAP_DFP)) {
4a2fec
         _FDT((fdt_setprop_cell(fdt, offset, "ibm,dfp", 1)));
4a2fec
     }
4a2fec
 
4a2fec
@@ -3650,7 +3650,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
4a2fec
     mc->numa_mem_align_shift = 28;
4a2fec
     smc->has_power9_support = true;
4a2fec
 
4a2fec
-    smc->default_caps = spapr_caps(SPAPR_CAP_VSX);
4a2fec
+    smc->default_caps = spapr_caps(SPAPR_CAP_VSX | SPAPR_CAP_DFP);
4a2fec
     spapr_caps_add_properties(smc, &error_abort);
4a2fec
 }
4a2fec
 
4a2fec
@@ -4056,7 +4056,8 @@ static void spapr_machine_rhel740_class_options(MachineClass *mc)
4a2fec
     smc->has_power9_support = false;
4a2fec
     smc->pre_2_10_has_unused_icps = true;
4a2fec
     smc->resize_hpt_default = SPAPR_RESIZE_HPT_DISABLED;
4a2fec
-    smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX);
4a2fec
+    smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX
4a2fec
+                                   | SPAPR_CAP_DFP);
4a2fec
 }
4a2fec
 
4a2fec
 DEFINE_SPAPR_MACHINE(rhel740, "rhel7.4.0", false);
4a2fec
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
4a2fec
index 9f901fb..2b67ac2 100644
4a2fec
--- a/hw/ppc/spapr_caps.c
4a2fec
+++ b/hw/ppc/spapr_caps.c
4a2fec
@@ -70,6 +70,16 @@ static void cap_vsx_allow(sPAPRMachineState *spapr, Error **errp)
4a2fec
     }
4a2fec
 }
4a2fec
 
4a2fec
+static void cap_dfp_allow(sPAPRMachineState *spapr, Error **errp)
4a2fec
+{
4a2fec
+    PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
4a2fec
+    CPUPPCState *env = &cpu->env;
4a2fec
+
4a2fec
+    if (!(env->insns_flags2 & PPC2_DFP)) {
4a2fec
+        error_setg(errp, "DFP support not available, try cap-dfp=off");
4a2fec
+    }
4a2fec
+}
4a2fec
+
4a2fec
 static sPAPRCapabilityInfo capability_table[] = {
4a2fec
     {
4a2fec
         .name = "htm",
4a2fec
@@ -85,6 +95,13 @@ static sPAPRCapabilityInfo capability_table[] = {
4a2fec
         .allow = cap_vsx_allow,
4a2fec
         /* TODO: add cap_vsx_disallow */
4a2fec
     },
4a2fec
+    {
4a2fec
+        .name = "dfp",
4a2fec
+        .description = "Allow Decimal Floating Point (DFP)",
4a2fec
+        .flag = SPAPR_CAP_DFP,
4a2fec
+        .allow = cap_dfp_allow,
4a2fec
+        /* TODO: add cap_dfp_disallow */
4a2fec
+    },
4a2fec
 };
4a2fec
 
4a2fec
 static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
4a2fec
@@ -104,6 +121,7 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
4a2fec
     if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_06,
4a2fec
                           0, spapr->max_compat_pvr)) {
4a2fec
         caps.mask &= ~SPAPR_CAP_VSX;
4a2fec
+        caps.mask &= ~SPAPR_CAP_DFP;
4a2fec
     }
4a2fec
 
4a2fec
     return caps;
4a2fec
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
4a2fec
index 36f6816..df767c3 100644
4a2fec
--- a/include/hw/ppc/spapr.h
4a2fec
+++ b/include/hw/ppc/spapr.h
4a2fec
@@ -62,6 +62,9 @@ typedef enum {
4a2fec
 /* Vector Scalar Extensions */
4a2fec
 #define SPAPR_CAP_VSX               0x0000000000000002ULL
4a2fec
 
4a2fec
+/* Decimal Floating Point */
4a2fec
+#define SPAPR_CAP_DFP               0x0000000000000004ULL
4a2fec
+
4a2fec
 typedef struct sPAPRCapabilities sPAPRCapabilities;
4a2fec
 struct sPAPRCapabilities {
4a2fec
     uint64_t mask;
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec