Skip to content

Commit 7c97fcb

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: VMX: Expose nested_vmx_allowed() to nested VMX as a non-inline
Exposing only the function allows @nested, i.e. the module param, to be statically defined in vmx.c, ensuring we aren't unnecessarily checking said variable in the nested code. nested_vmx_allowed() is exposed due to the need to verify nested support in vmx_{get,set}_nested_state(). The downside is that nested_vmx_allowed() likely won't be inlined in vmx_{get,set}_nested_state(), but that should be a non-issue as they're not a hot path. Keeping vmx_{get,set}_nested_state() in vmx.c isn't a viable option as they need access to several nested-only functions. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 97b7ead commit 7c97fcb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,15 @@ struct shared_msr_entry *find_msr_entry(struct vcpu_vmx *vmx, u32 msr)
698698
return NULL;
699699
}
700700

701+
void loaded_vmcs_init(struct loaded_vmcs *loaded_vmcs)
702+
{
703+
vmcs_clear(loaded_vmcs->vmcs);
704+
if (loaded_vmcs->shadow_vmcs && loaded_vmcs->launched)
705+
vmcs_clear(loaded_vmcs->shadow_vmcs);
706+
loaded_vmcs->cpu = -1;
707+
loaded_vmcs->launched = 0;
708+
}
709+
701710
#ifdef CONFIG_KEXEC_CORE
702711
/*
703712
* This bitmap is used to indicate whether the vmclear
@@ -1722,7 +1731,7 @@ static u64 vmx_write_l1_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
17221731
* all guests if the "nested" module option is off, and can also be disabled
17231732
* for a single guest by disabling its VMX cpuid bit.
17241733
*/
1725-
static inline bool nested_vmx_allowed(struct kvm_vcpu *vcpu)
1734+
bool nested_vmx_allowed(struct kvm_vcpu *vcpu)
17261735
{
17271736
return nested && guest_cpuid_has(vcpu, X86_FEATURE_VMX);
17281737
}

arch/x86/kvm/vmx/vmx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ struct kvm_vmx {
267267
spinlock_t ept_pointer_lock;
268268
};
269269

270+
bool nested_vmx_allowed(struct kvm_vcpu *vcpu);
270271
void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
271272
void vmx_vcpu_put(struct kvm_vcpu *vcpu);
272273
int allocate_vpid(void);

0 commit comments

Comments
 (0)