ppc/spapr-caps: Change migration macro to take full spapr-cap name
PATCH 1/3 ppc/spapr-caps: Change migration macro to take full spapr-cap name
Change the macro that generates the vmstate migration field and the needed function for the spapr-caps to take the full spapr-cap name. This has the benefit of meaning this instance will be picked up when greping for the spapr-caps and making it more obvious what this macro is doing.
--- hw/ppc/spapr_caps.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
hw/ppc/spapr_caps.c +15 -15
@@ -350,34 +350,34 @@ int spapr_caps_post_migration(sPAPRMachineState *spapr) }/* Used to generate the migration field and needed function for a spapr cap */ -#define SPAPR_CAP_MIG_STATE (cap, ccap) \ -static bool spapr_cap_##cap##_needed(void *opaque) \ +#define SPAPR_CAP_MIG_STATE (sname, cap) \ +static bool spapr_cap_##sname##_needed(void *opaque) \ { \ sPAPRMachineState *spapr = opaque; \ \ - return spapr->cmd_line_caps[SPAPR_CAP_##ccap] && \ - (spapr->eff.caps[SPAPR_CAP_##ccap] != \ - spapr->def.caps[SPAPR_CAP_##ccap]); \ + return spapr->cmd_line_caps[cap] && \ + (spapr->eff.caps[cap] != \ + spapr->def.caps[cap]); \ } \ \ -const VMStateDescription vmstate_spapr_cap_##cap = { \ - .name = "spapr/cap/" #cap, \ +const VMStateDescription vmstate_spapr_cap_##sname = { \ + .name = "spapr/cap/" #sname, \ .version_id = 1, \ .minimum_version_id = 1, \ - .needed = spapr_cap_##cap##_needed, \ + .needed = spapr_cap_##sname##_needed, \ .fields = (VMStateField[]) { \ - VMSTATE_UINT8(mig.caps[SPAPR_CAP_##ccap], \ + VMSTATE_UINT8(mig.caps[cap], \ sPAPRMachineState), \ VMSTATE_END_OF_LIST() \ }, \ } -SPAPR_CAP_MIG_STATE (htm,HTM ); -SPAPR_CAP_MIG_STATE (vsx,VSX ); -SPAPR_CAP_MIG_STATE (dfp,DFP ); -SPAPR_CAP_MIG_STATE (cfpc,CFPC ); -SPAPR_CAP_MIG_STATE (sbbc,SBBC ); -SPAPR_CAP_MIG_STATE (ibs,IBS ); +SPAPR_CAP_MIG_STATE (htm,SPAPR_CAP_HTM ); +SPAPR_CAP_MIG_STATE (vsx,SPAPR_CAP_VSX ); +SPAPR_CAP_MIG_STATE (dfp,SPAPR_CAP_DFP ); +SPAPR_CAP_MIG_STATE (cfpc,SPAPR_CAP_CFPC ); +SPAPR_CAP_MIG_STATE (sbbc,SPAPR_CAP_SBBC ); +SPAPR_CAP_MIG_STATE (ibs,SPAPR_CAP_IBS );void spapr_caps_reset (sPAPRMachineState *spapr) {
Signature · 1 line
2.13.6
PATCH 2/3 ppc/spapr-caps: Disallow setting workaround for spapr-cap-ibs
The spapr-cap cap-ibs can only have values broken or fixed as there is no workaround. Currently setting the value workaround will hit an assert if the guest makes the hcall h_get_cpu_characteristics.
Report an error when attempting to apply the setting with a more helpful error message.
--- hw/ppc/spapr_caps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/ppc/spapr_caps.c +3 -1
@@ -205,7 +205,9 @@ static void cap_safe_bounds_check_apply(sPAPRMachineState *spapr, uint8_t val,static void cap_safe_indirect_branch_apply (sPAPRMachineState *spapr,uint8_t val,Error **errp) { -if (tcg_enabled () && val) { +if (val ==SPAPR_CAP_WORKAROUND ) {/* Can only be Broken or Fixed */ +error_setg (errp,"Requested safe indirect branch capability level \"workaround\" not valid, try cap-ibs=fixed" ); + }else if (tcg_enabled () && val) {/* TODO - for now only allow broken for TCG */ error_setg (errp,"Requested safe indirect branch capability level not supported by tcg, try a different value for cap-ibs" ); }else if (kvm_enabled () && (val >kvmppc_get_cap_safe_indirect_branch ())) {
Signature · 1 line
2.13.6
PATCH 3/3 ppc/spapr-caps: For pseries-2.12 change spapr-cap defaults
In reply to Suraj Jitindar SinghFor the pseries-2.12 machine type, make the spapr-caps SPAPR_CAP_CFPC and SPAPR_CAP_SBBC default to workaround. This means the guest will be able to take advantage of these workarounds by default, so long as the host is capable.
--- hw/ppc/spapr.c | 11 ++++++++++- hw/ppc/spapr_caps.c | 10 ++++++++++ include/hw/compat.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +10 -1
@@ -3941,13 +3941,20 @@ static const TypeInfo spapr_machine_info = {/* * pseries-2.12 */ +#define SPAPR_COMPAT_2_12 \ + HW_COMPAT_2_12 +static void spapr_machine_2_12_instance_options (MachineState *machine) { }static void spapr_machine_2_12_class_options (MachineClass *mc) { -/* Defaults for the latest behaviour inherited from the base class */ +sPAPRMachineClass *smc =SPAPR_MACHINE_CLASS (mc); + + smc->default_caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_WORKAROUND ; + smc->default_caps.caps[SPAPR_CAP_SBBC ] =SPAPR_CAP_WORKAROUND ; +SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_12 ); } DEFINE_SPAPR_MACHINE(2_12, "2.12", true);
@@ -3969,6 +3976,8 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)spapr_machine_2_12_class_options (mc); smc->default_caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_ON ; + smc->default_caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ; + smc->default_caps.caps[SPAPR_CAP_SBBC ] =SPAPR_CAP_BROKEN ;SET_MACHINE_COMPAT (mc,SPAPR_COMPAT_2_11 ); }
hw/ppc/spapr_caps.c +10 -0
@@ -283,11 +283,21 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, caps = smc->default_caps; +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_3_00 , +0 , spapr->max_compat_pvr)) { + caps.caps[SPAPR_CAP_CFPC ] =SPAPR_CAP_BROKEN ; + } +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_07 ,0 , spapr->max_compat_pvr)) { caps.caps[SPAPR_CAP_HTM ] =SPAPR_CAP_OFF ; } +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_06_PLUS , +0 , spapr->max_compat_pvr)) { + caps.caps[SPAPR_CAP_SBBC ] =SPAPR_CAP_BROKEN ; + } +if (!ppc_check_compat (cpu,CPU_POWERPC_LOGICAL_2_06 ,0 , spapr->max_compat_pvr)) { caps.caps[SPAPR_CAP_VSX ] =SPAPR_CAP_OFF ;
include/hw/compat.h +2 -0
@@ -1,6 +1,8 @@#ifndef HW_COMPAT_H #define HW_COMPAT_H +#define HW_COMPAT_2_12 +#define HW_COMPAT_2_11 \ {\ .driver = "hpet",\
Signature · 1 line
2.13.6