Blame SOURCES/kvm-ppc-spapr-caps-Convert-cap-cfpc-to-custom-spapr-cap.patch

37e7a1
From e9c565a32315df050f7181931e545270de1641d0 Mon Sep 17 00:00:00 2001
37e7a1
From: Suraj Jitindar Singh <sursingh@redhat.com>
37e7a1
Date: Tue, 13 Mar 2018 05:21:33 +0100
37e7a1
Subject: [PATCH 11/17] ppc/spapr-caps: Convert cap-cfpc to custom spapr-cap
37e7a1
37e7a1
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
37e7a1
Message-id: <1520918499-27663-6-git-send-email-sursingh@redhat.com>
37e7a1
Patchwork-id: 79251
37e7a1
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 05/11] ppc/spapr-caps: Convert cap-cfpc to custom spapr-cap
37e7a1
Bugzilla: 1554957
37e7a1
RH-Acked-by: David Gibson <dgibson@redhat.com>
37e7a1
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
37e7a1
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
37e7a1
37e7a1
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
37e7a1
37e7a1
Convert cap-cfpc (cache flush on privilege change) to a custom spapr-cap
37e7a1
type.
37e7a1
37e7a1
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
37e7a1
[dwg: Don't explicitly list "?"/help option, trusting convention]
37e7a1
[dwg: Strip no-longer-necessary ATTRIBUTE_UNUSED back off]
37e7a1
[dwg: Fix some minor style problems]
37e7a1
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
37e7a1
37e7a1
(cherry picked from commit f27aa81e72b5a5e184a0f3aa3e77061f4fcfb265)
37e7a1
37e7a1
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1548919
37e7a1
37e7a1
Signed-off-by: Suraj Jitindar Singh <sursingh@redhat.com>
37e7a1
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
37e7a1
---
37e7a1
 hw/ppc/spapr_caps.c | 33 ++++++++++++++++++++++-----------
37e7a1
 1 file changed, 22 insertions(+), 11 deletions(-)
37e7a1
37e7a1
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
37e7a1
index 3d8b796..b5a991f 100644
37e7a1
--- a/hw/ppc/spapr_caps.c
37e7a1
+++ b/hw/ppc/spapr_caps.c
37e7a1
@@ -149,9 +149,8 @@ out:
37e7a1
     g_free(val);
37e7a1
 }
37e7a1
 
37e7a1
-static void ATTRIBUTE_UNUSED spapr_cap_get_string(Object *obj, Visitor *v,
37e7a1
-                                                  const char *name,
37e7a1
-                                                  void *opaque, Error **errp)
37e7a1
+static void  spapr_cap_get_string(Object *obj, Visitor *v, const char *name,
37e7a1
+                                  void *opaque, Error **errp)
37e7a1
 {
37e7a1
     sPAPRCapabilityInfo *cap = opaque;
37e7a1
     sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
37e7a1
@@ -169,9 +168,8 @@ static void ATTRIBUTE_UNUSED spapr_cap_get_string(Object *obj, Visitor *v,
37e7a1
     g_free(val);
37e7a1
 }
37e7a1
 
37e7a1
-static void ATTRIBUTE_UNUSED spapr_cap_set_string(Object *obj, Visitor *v,
37e7a1
-                                                  const char *name,
37e7a1
-                                                  void *opaque, Error **errp)
37e7a1
+static void spapr_cap_set_string(Object *obj, Visitor *v, const char *name,
37e7a1
+                                 void *opaque, Error **errp)
37e7a1
 {
37e7a1
     sPAPRCapabilityInfo *cap = opaque;
37e7a1
     sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
37e7a1
@@ -250,14 +248,26 @@ static void cap_dfp_apply(sPAPRMachineState *spapr, uint8_t val, Error **errp)
37e7a1
     }
37e7a1
 }
37e7a1
 
37e7a1
+sPAPRCapPossible cap_cfpc_possible = {
37e7a1
+    .num = 3,
37e7a1
+    .vals = {"broken", "workaround", "fixed"},
37e7a1
+    .help = "broken - no protection, workaround - workaround available,"
37e7a1
+            " fixed - fixed in hardware",
37e7a1
+};
37e7a1
+
37e7a1
 static void cap_safe_cache_apply(sPAPRMachineState *spapr, uint8_t val,
37e7a1
                                  Error **errp)
37e7a1
 {
37e7a1
+    uint8_t kvm_val =  kvmppc_get_cap_safe_cache();
37e7a1
+
37e7a1
     if (tcg_enabled() && val) {
37e7a1
         /* TODO - for now only allow broken for TCG */
37e7a1
-        error_setg(errp, "Requested safe cache capability level not supported by tcg, try a different value for cap-cfpc");
37e7a1
-    } else if (kvm_enabled() && (val > kvmppc_get_cap_safe_cache())) {
37e7a1
-        error_setg(errp, "Requested safe cache capability level not supported by kvm, try a different value for cap-cfpc");
37e7a1
+        error_setg(errp,
37e7a1
+"Requested safe cache capability level not supported by tcg, try a different value for cap-cfpc");
37e7a1
+    } else if (kvm_enabled() && (val > kvm_val)) {
37e7a1
+        error_setg(errp,
37e7a1
+"Requested safe cache capability level not supported by kvm, try cap-cfpc=%s",
37e7a1
+                   cap_cfpc_possible.vals[kvm_val]);
37e7a1
     }
37e7a1
 }
37e7a1
 
37e7a1
@@ -319,9 +329,10 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
37e7a1
         .name = "cfpc",
37e7a1
         .description = "Cache Flush on Privilege Change" VALUE_DESC_TRISTATE,
37e7a1
         .index = SPAPR_CAP_CFPC,
37e7a1
-        .get = spapr_cap_get_tristate,
37e7a1
-        .set = spapr_cap_set_tristate,
37e7a1
+        .get = spapr_cap_get_string,
37e7a1
+        .set = spapr_cap_set_string,
37e7a1
         .type = "string",
37e7a1
+        .possible = &cap_cfpc_possible,
37e7a1
         .apply = cap_safe_cache_apply,
37e7a1
     },
37e7a1
     [SPAPR_CAP_SBBC] = {
37e7a1
-- 
37e7a1
1.8.3.1
37e7a1