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

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