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