qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-ppc] [RFC for-2.12 8/8] spapr: Handle Decimal Floating Point (DFP)


From: David Gibson
Subject: [Qemu-ppc] [RFC for-2.12 8/8] spapr: Handle Decimal Floating Point (DFP) as an optional capability
Date: Mon, 11 Dec 2017 18:08:08 +1100

Decimal Floating Point has been available on POWER7 and later (server)
cpus.  However, it can be disabled on the hypervisor, meaning that it's
not available to guests.

We currently handle this by conditionally advertising DFP support in the
device tree depending on whether the guest CPU model supports it - which
can also depend on what's allowed in the host for -cpu host.  That can lead
to confusion on migration, since host properties are silently affecting
guest visible properties.

This patch handles it by treating it as an optional capability for the
pseries machine type.

Signed-off-by: David Gibson <address@hidden>
---
 hw/ppc/spapr.c         |  5 +++--
 hw/ppc/spapr_caps.c    | 17 +++++++++++++++++
 include/hw/ppc/spapr.h |  3 +++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 6b37511e8f..cca3789b35 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -571,7 +571,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, 
int offset,
     /* Advertise DFP (Decimal Floating Point) if available
      *   0 / no property == no DFP
      *   1               == DFP available */
-    if (env->insns_flags2 & PPC2_DFP) {
+    if (spapr_has_cap(spapr, SPAPR_CAP_DFP)) {
         _FDT((fdt_setprop_cell(fdt, offset, "ibm,dfp", 1)));
     }
 
@@ -3831,7 +3831,8 @@ static void spapr_machine_class_init(ObjectClass *oc, 
void *data)
      */
     mc->numa_mem_align_shift = 28;
 
-    smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX);
+    smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX
+                                   | SPAPR_CAP_DFP);
     spapr_capability_properties(smc, &error_abort);
 }
 
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index b19a9f4417..49c2e10d27 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -49,6 +49,11 @@ static sPAPRCapabilityInfo capability_table[] = {
         .description = "Allow Vector Scalar Extensions (VSX)",
         .bit = SPAPR_CAP_VSX,
     },
+    {
+        .name = "dfp",
+        .description = "Allow Decimal Floating Point (DFP)",
+        .bit = SPAPR_CAP_DFP,
+    },
 };
 
 static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, 
CPUState *cs)
@@ -67,6 +72,7 @@ static sPAPRCapabilities 
default_caps_with_cpu(sPAPRMachineState *spapr, CPUStat
     if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_06,
                           0, spapr->max_compat_pvr)) {
         caps.mask &= ~SPAPR_CAP_VSX;
+        caps.mask &= ~SPAPR_CAP_DFP;
     }
 
     return caps;
@@ -184,6 +190,13 @@ static void spapr_allow_caps(sPAPRMachineState *spapr, 
Error **errp)
         }
     }
 
+    if (spapr_has_cap(spapr, SPAPR_CAP_DFP)) {
+        if (!(env->insns_flags2 & PPC2_DFP)) {
+            error_setg(&err, "DFP support not available, try cap-dfp=off");
+            goto out;
+        }
+    }
+
 out:
     if (err) {
         error_propagate(errp, err);
@@ -199,6 +212,10 @@ static void spapr_enforce_caps(sPAPRMachineState *spapr, 
Error **errp)
     if (!spapr_has_cap(spapr, SPAPR_CAP_VSX)) {
         /* TODO: Any way to disable VSX? */
     }
+
+    if (!spapr_has_cap(spapr, SPAPR_CAP_VSX)) {
+        /* TODO: Any way to disable DFP? */
+    }
 }
 
 void spapr_caps_reset(sPAPRMachineState *spapr)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 4c173cb40c..ef4f7427de 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -62,6 +62,9 @@ typedef enum {
 /* Vector Scalar Extensions */
 #define SPAPR_CAP_VSX               0x0000000000000002ULL
 
+/* Decimal Floating Point */
+#define SPAPR_CAP_DFP               0x0000000000000004ULL
+
 typedef struct sPAPRCapabilities sPAPRCapabilities;
 struct sPAPRCapabilities {
     uint64_t mask;
-- 
2.14.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]