return NULL;
}
+int init_domain_cpuid_policy(struct domain *d)
+{
+ d->arch.cpuid = xmalloc(struct cpuid_policy);
+
+ if ( !d->arch.cpuid )
+ return -ENOMEM;
+
+ *d->arch.cpuid = is_pv_domain(d) ? pv_max_policy : hvm_max_policy;
+
+ return 0;
+}
+
void guest_cpuid(const struct vcpu *v, uint32_t leaf,
uint32_t subleaf, struct cpuid_leaf *res)
{
if ( is_idle_domain(d) )
{
d->arch.emulation_flags = 0;
+ d->arch.cpuid = ZERO_BLOCK_PTR; /* Catch stray misuses. */
}
else
{
goto fail;
paging_initialised = 1;
+ if ( (rc = init_domain_cpuid_policy(d)) )
+ goto fail;
+
d->arch.cpuids = xmalloc_array(cpuid_input_t, MAX_CPUID_INPUT);
rc = -ENOMEM;
if ( d->arch.cpuids == NULL )
cleanup_domain_irq_mapping(d);
free_xenheap_page(d->shared_info);
xfree(d->arch.cpuids);
+ xfree(d->arch.cpuid);
if ( paging_initialised )
paging_final_teardown(d);
free_perdomain_mappings(d);
xfree(d->arch.e820);
xfree(d->arch.cpuids);
+ xfree(d->arch.cpuid);
free_domain_pirqs(d);
if ( !is_idle_domain(d) )
if ( !tboot_protect_mem_regions() )
panic("Could not protect TXT memory regions");
+ init_guest_cpuid();
+
if ( opt_dom0pvh )
domcr_flags |= DOMCRF_pvh | DOMCRF_hap;
"Multiple initrd candidates, picking module #%u\n",
initrdidx);
- init_guest_cpuid();
-
/*
* Temporarily clear SMAP in CR4 to allow user-accesses in construct_dom0().
* This saves a large number of corner cases interactions with
* - Guest accurate:
* - All FEATURESET_* words
*
+ * Per-domain objects:
+ *
+ * - Host accurate:
+ * - max_{,sub}leaf
+ * - {xcr0,xss}_{high,low}
+ * - All FEATURESET_* words
+ *
+ * - Guest accurate:
+ * - Nothing
+ *
* Everything else should be considered inaccurate, and not necesserily 0.
*/
#define pv_featureset pv_max_policy.fs
#define hvm_featureset hvm_max_policy.fs
+/* Allocate and initialise a CPUID policy suitable for the domain. */
+int init_domain_cpuid_policy(struct domain *d);
+
void guest_cpuid(const struct vcpu *v, uint32_t leaf,
uint32_t subleaf, struct cpuid_leaf *res);
cpuid_input_t *cpuids;
+ /* CPUID Policy. */
+ struct cpuid_policy *cpuid;
+
struct PITState vpit;
/* TSC management (emulation, pv, scaling, stats) */