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

37e7a1
From bf60dd793e4a04ab7952aa8e5046436113805c0d Mon Sep 17 00:00:00 2001
37e7a1
From: Suraj Jitindar Singh <sursingh@redhat.com>
37e7a1
Date: Tue, 13 Mar 2018 05:21:34 +0100
37e7a1
Subject: [PATCH 12/17] ppc/spapr-caps: Convert cap-sbbc to custom spapr-cap
37e7a1
37e7a1
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
37e7a1
Message-id: <1520918499-27663-7-git-send-email-sursingh@redhat.com>
37e7a1
Patchwork-id: 79253
37e7a1
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 06/11] ppc/spapr-caps: Convert cap-sbbc 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-sbbc (speculation barrier bounds checking) to a custom
37e7a1
spapr-cap type.
37e7a1
37e7a1
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
37e7a1
[dwg: Removed trailing whitespace]
37e7a1
[dwg: Don't explicitly list "?"/help option, trust convention]
37e7a1
[dwg: Fix some minor style problems]
37e7a1
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
37e7a1
37e7a1
(cherry picked from commit aaf265ffde352c4100a8e2adc554ec11aa6abe08)
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 | 23 ++++++++++++++++++-----
37e7a1
 1 file changed, 18 insertions(+), 5 deletions(-)
37e7a1
37e7a1
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
37e7a1
index b5a991f..8748692 100644
37e7a1
--- a/hw/ppc/spapr_caps.c
37e7a1
+++ b/hw/ppc/spapr_caps.c
37e7a1
@@ -271,14 +271,26 @@ static void cap_safe_cache_apply(sPAPRMachineState *spapr, uint8_t val,
37e7a1
     }
37e7a1
 }
37e7a1
 
37e7a1
+sPAPRCapPossible cap_sbbc_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_bounds_check_apply(sPAPRMachineState *spapr, uint8_t val,
37e7a1
                                         Error **errp)
37e7a1
 {
37e7a1
+    uint8_t kvm_val =  kvmppc_get_cap_safe_bounds_check();
37e7a1
+
37e7a1
     if (tcg_enabled() && val) {
37e7a1
         /* TODO - for now only allow broken for TCG */
37e7a1
-        error_setg(errp, "Requested safe bounds check capability level not supported by tcg, try a different value for cap-sbbc");
37e7a1
-    } else if (kvm_enabled() && (val > kvmppc_get_cap_safe_bounds_check())) {
37e7a1
-        error_setg(errp, "Requested safe bounds check capability level not supported by kvm, try a different value for cap-sbbc");
37e7a1
+        error_setg(errp,
37e7a1
+"Requested safe bounds check capability level not supported by tcg, try a different value for cap-sbbc");
37e7a1
+    } else if (kvm_enabled() && (val > kvm_val)) {
37e7a1
+        error_setg(errp,
37e7a1
+"Requested safe bounds check capability level not supported by kvm, try cap-sbbc=%s",
37e7a1
+                   cap_sbbc_possible.vals[kvm_val]);
37e7a1
     }
37e7a1
 }
37e7a1
 
37e7a1
@@ -339,9 +351,10 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
37e7a1
         .name = "sbbc",
37e7a1
         .description = "Speculation Barrier Bounds Checking" VALUE_DESC_TRISTATE,
37e7a1
         .index = SPAPR_CAP_SBBC,
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_sbbc_possible,
37e7a1
         .apply = cap_safe_bounds_check_apply,
37e7a1
     },
37e7a1
     [SPAPR_CAP_IBS] = {
37e7a1
-- 
37e7a1
1.8.3.1
37e7a1