#include <xen/sched.h>
#include <asm/cpuid.h>
#include <asm/hvm/hvm.h>
+#include <asm/hvm/nestedhvm.h>
#include <asm/hvm/vmx/vmcs.h>
#include <asm/processor.h>
#include <asm/xstate.h>
cpuid_policy_to_featureset(p, fs);
cpuid_policy_to_featureset(max, max_fs);
- /*
- * HVM domains using Shadow paging have further restrictions on their
- * available paging features.
- */
- if ( is_hvm_domain(d) && !hap_enabled(d) )
+ if ( is_hvm_domain(d) )
{
- for ( i = 0; i < ARRAY_SIZE(max_fs); i++ )
- max_fs[i] &= hvm_shadow_featuremask[i];
+ /*
+ * HVM domains using Shadow paging have further restrictions on their
+ * available paging features.
+ */
+ if ( !hap_enabled(d) )
+ {
+ for ( i = 0; i < ARRAY_SIZE(max_fs); i++ )
+ max_fs[i] &= hvm_shadow_featuremask[i];
+ }
+
+ /* Hide nested-virt if it hasn't been explicitly configured. */
+ if ( !nestedhvm_enabled(d) )
+ {
+ __clear_bit(X86_FEATURE_VMX, max_fs);
+ __clear_bit(X86_FEATURE_SVM, max_fs);
+ }
}
/*
/* Nested HVM on/off per domain */
bool nestedhvm_enabled(const struct domain *d)
{
- return is_hvm_domain(d) && d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM];
+ return is_hvm_domain(d) && d->arch.hvm_domain.params &&
+ d->arch.hvm_domain.params[HVM_PARAM_NESTEDHVM];
}
/* Nested VCPU */