[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 02/10] tools/libxc: Simplify xc_get_static_cpu_featuremask()
Drop XC_FEATUREMASK_DEEP_FEATURES. It isn't used by any callers, and unlike the other static masks, won't be of interest to anyone without other pieces of cpuid-autogen.h In xc_get_static_cpu_featuremask(), use a 2d array instead of individually named variables, and drop the switch statement completely. No practical change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Wei Liu <wl@xxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- tools/libxc/include/xenctrl.h | 1 - tools/libxc/xc_cpuid_x86.c | 46 ++++++++++++------------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 99552a5f73..dec3c5de2b 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2488,7 +2488,6 @@ enum xc_static_cpu_featuremask { XC_FEATUREMASK_PV, XC_FEATUREMASK_HVM_SHADOW, XC_FEATUREMASK_HVM_HAP, - XC_FEATUREMASK_DEEP_FEATURES, }; const uint32_t *xc_get_static_cpu_featuremask(enum xc_static_cpu_featuremask); diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 21b15b86ec..53cb72438a 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -90,43 +90,23 @@ uint32_t xc_get_cpu_featureset_size(void) const uint32_t *xc_get_static_cpu_featuremask( enum xc_static_cpu_featuremask mask) { - const static uint32_t known[FEATURESET_NR_ENTRIES] = INIT_KNOWN_FEATURES, - special[FEATURESET_NR_ENTRIES] = INIT_SPECIAL_FEATURES, - pv[FEATURESET_NR_ENTRIES] = INIT_PV_FEATURES, - hvm_shadow[FEATURESET_NR_ENTRIES] = INIT_HVM_SHADOW_FEATURES, - hvm_hap[FEATURESET_NR_ENTRIES] = INIT_HVM_HAP_FEATURES, - deep_features[FEATURESET_NR_ENTRIES] = INIT_DEEP_FEATURES; - - BUILD_BUG_ON(ARRAY_SIZE(known) != FEATURESET_NR_ENTRIES); - BUILD_BUG_ON(ARRAY_SIZE(special) != FEATURESET_NR_ENTRIES); - BUILD_BUG_ON(ARRAY_SIZE(pv) != FEATURESET_NR_ENTRIES); - BUILD_BUG_ON(ARRAY_SIZE(hvm_shadow) != FEATURESET_NR_ENTRIES); - BUILD_BUG_ON(ARRAY_SIZE(hvm_hap) != FEATURESET_NR_ENTRIES); - BUILD_BUG_ON(ARRAY_SIZE(deep_features) != FEATURESET_NR_ENTRIES); - - switch ( mask ) - { - case XC_FEATUREMASK_KNOWN: - return known; - - case XC_FEATUREMASK_SPECIAL: - return special; - - case XC_FEATUREMASK_PV: - return pv; + const static uint32_t masks[][FEATURESET_NR_ENTRIES] = { +#define MASK(x) [XC_FEATUREMASK_ ## x] = INIT_ ## x ## _FEATURES - case XC_FEATUREMASK_HVM_SHADOW: - return hvm_shadow; + MASK(KNOWN), + MASK(SPECIAL), + MASK(PV), + MASK(HVM_SHADOW), + MASK(HVM_HAP), - case XC_FEATUREMASK_HVM_HAP: - return hvm_hap; +#undef MASK + }; + BUILD_BUG_ON(ARRAY_SIZE(masks[0]) != FEATURESET_NR_ENTRIES); - case XC_FEATUREMASK_DEEP_FEATURES: - return deep_features; - - default: + if ( (unsigned int)mask >= ARRAY_SIZE(masks) ) return NULL; - } + + return masks[mask]; } int xc_get_cpu_policy_size(xc_interface *xch, uint32_t *nr_leaves, -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |