diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2021-02-02 18:48:05 +0300 |
---|---|---|
committer | David Woodhouse <dwmw@amazon.co.uk> | 2021-02-04 17:19:38 +0300 |
commit | 7d6bbebb7bb0294ede7bda04847272854e34f87c (patch) | |
tree | f406d06318ceeb0e6dffa26c415f0100b69eb9c5 /arch/x86/kvm/xen.h | |
parent | 78e9878cb376969d184a4b7fff392528fe17a3ce (diff) | |
download | linux-7d6bbebb7bb0294ede7bda04847272854e34f87c.tar.xz |
KVM: x86/xen: Add kvm_xen_enabled static key
The code paths for Xen support are all fairly lightweight but if we hide
them behind this, they're even *more* lightweight for any system which
isn't actually hosting Xen guests.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Diffstat (limited to 'arch/x86/kvm/xen.h')
-rw-r--r-- | arch/x86/kvm/xen.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h index 28e9c9892628..ec3d8f6d0ef5 100644 --- a/arch/x86/kvm/xen.h +++ b/arch/x86/kvm/xen.h @@ -9,14 +9,20 @@ #ifndef __ARCH_X86_KVM_XEN_H__ #define __ARCH_X86_KVM_XEN_H__ +#include <linux/jump_label_ratelimit.h> + +extern struct static_key_false_deferred kvm_xen_enabled; + int kvm_xen_hypercall(struct kvm_vcpu *vcpu); int kvm_xen_write_hypercall_page(struct kvm_vcpu *vcpu, u64 data); int kvm_xen_hvm_config(struct kvm *kvm, struct kvm_xen_hvm_config *xhc); +void kvm_xen_destroy_vm(struct kvm *kvm); static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm) { - return kvm->arch.xen_hvm_config.flags & - KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL; + return static_branch_unlikely(&kvm_xen_enabled.key) && + (kvm->arch.xen_hvm_config.flags & + KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL); } #endif /* __ARCH_X86_KVM_XEN_H__ */ |