@@ -425,6 +425,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
{
d->arch.emulation_flags = 0;
d->arch.cpuid = ZERO_BLOCK_PTR; /* Catch stray misuses. */
+ d->arch.vmx_msr = ZERO_BLOCK_PTR;
}
else
{
@@ -470,6 +471,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
if ( (rc = init_domain_cpuid_policy(d)) )
goto fail;
+ if ( (rc = init_domain_vmx_msr_policy(d)) )
+ goto fail;
+
d->arch.ioport_caps =
rangeset_new(d, "I/O Ports", RANGESETF_prettyprint_hex);
rc = -ENOMEM;
@@ -541,6 +545,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
cleanup_domain_irq_mapping(d);
free_xenheap_page(d->shared_info);
xfree(d->arch.cpuid);
+ xfree(d->arch.vmx_msr);
if ( paging_initialised )
paging_final_teardown(d);
free_perdomain_mappings(d);
@@ -555,6 +560,7 @@ void arch_domain_destroy(struct domain *d)
xfree(d->arch.e820);
xfree(d->arch.cpuid);
+ xfree(d->arch.vmx_msr);
free_domain_pirqs(d);
if ( !is_idle_domain(d) )
@@ -2072,6 +2072,18 @@ void __init calculate_vvmx_max_policy(void)
MSR_IA32_VMX_VMFUNC);
}
+int init_domain_vmx_msr_policy(struct domain *d)
+{
+ d->arch.vmx_msr = xmalloc(struct vmx_msr_policy);
+
+ if ( !d->arch.vmx_msr )
+ return -ENOMEM;
+
+ *d->arch.vmx_msr = vvmx_max_msr_policy;
+
+ return 0;
+}
+
/*
* Capability reporting
*/
@@ -2079,7 +2091,7 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content)
{
struct vcpu *v = current;
struct domain *d = v->domain;
- const struct vmx_msr_policy *p = &vvmx_max_msr_policy;
+ const struct vmx_msr_policy *p = d->arch.vmx_msr;
int r = 1;
/* VMX capablity MSRs are available only when guest supports VMX. */
@@ -359,6 +359,8 @@ struct arch_domain
/* CPUID Policy. */
struct cpuid_policy *cpuid;
+ struct vmx_msr_policy *vmx_msr;
+
struct PITState vpit;
/* TSC management (emulation, pv, scaling, stats) */
@@ -246,5 +246,6 @@ int nvmx_cpu_up_prepare(unsigned int cpu);
void nvmx_cpu_dead(unsigned int cpu);
void calculate_vvmx_max_policy(void);
+int init_domain_vmx_msr_policy(struct domain *d);
#endif /* __ASM_X86_HVM_VVMX_H__ */