Skip to content

Commit

Permalink
ppc/spapr-caps: Convert cap-cfpc to custom spapr-cap
Browse files Browse the repository at this point in the history
Convert cap-cfpc (cache flush on privilege change) to a custom spapr-cap
type.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
[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 <david@gibson.dropbear.id.au>
  • Loading branch information
sjitindarsingh authored and dgibson committed Mar 6, 2018
1 parent 87175d1 commit f27aa81
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions hw/ppc/spapr_caps.c
Expand Up @@ -149,9 +149,8 @@ static void spapr_cap_set_tristate(Object *obj, Visitor *v, const char *name,
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);
Expand All @@ -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);
Expand Down Expand Up @@ -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]);
}
}

Expand Down Expand Up @@ -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] = {
Expand Down

0 comments on commit f27aa81

Please sign in to comment.