int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t policy,
const xen_msr_entry_t *msrs, uint32_t nr);
+/* Compatibility calculations. */
+bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t host,
+ const xc_cpu_policy_t guest);
+
int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
uint32_t *nr_features, uint32_t *featureset);
ifeq ($(CONFIG_X86),y) # Add libx86 to the build
vpath %.c ../../../xen/lib/x86
-SRCS-y += cpuid.c msr.c
+SRCS-y += cpuid.c msr.c policy.c
endif
# new domain builder
return rc;
}
+
+bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t host,
+ const xc_cpu_policy_t guest)
+{
+ struct cpu_policy_errors err = INIT_CPU_POLICY_ERRORS;
+ struct cpu_policy h = { &host->cpuid, &host->msr };
+ struct cpu_policy g = { &guest->cpuid, &guest->msr };
+ int rc = x86_cpu_policies_are_compatible(&h, &g, &err);
+
+ if ( !rc )
+ return true;
+
+ if ( err.leaf != -1 )
+ ERROR("Leaf %#x subleaf %#x is not compatible", err.leaf, err.subleaf);
+ if ( err.msr != -1 )
+ ERROR("MSR index %#x is not compatible", err.msr);
+
+ return false;
+}