aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/hypervisor.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/include/asm/hypervisor.h')
-rw-r--r--arch/x86/include/asm/hypervisor.h46
1 files changed, 18 insertions, 28 deletions
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 0ead9dbb9130..1b0a5abcd8ae 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -23,11 +23,22 @@
23#ifdef CONFIG_HYPERVISOR_GUEST 23#ifdef CONFIG_HYPERVISOR_GUEST
24 24
25#include <asm/kvm_para.h> 25#include <asm/kvm_para.h>
26#include <asm/x86_init.h>
26#include <asm/xen/hypervisor.h> 27#include <asm/xen/hypervisor.h>
27 28
28/* 29/*
29 * x86 hypervisor information 30 * x86 hypervisor information
30 */ 31 */
32
33enum x86_hypervisor_type {
34 X86_HYPER_NATIVE = 0,
35 X86_HYPER_VMWARE,
36 X86_HYPER_MS_HYPERV,
37 X86_HYPER_XEN_PV,
38 X86_HYPER_XEN_HVM,
39 X86_HYPER_KVM,
40};
41
31struct hypervisor_x86 { 42struct hypervisor_x86 {
32 /* Hypervisor name */ 43 /* Hypervisor name */
33 const char *name; 44 const char *name;
@@ -35,40 +46,19 @@ struct hypervisor_x86 {
35 /* Detection routine */ 46 /* Detection routine */
36 uint32_t (*detect)(void); 47 uint32_t (*detect)(void);
37 48
38 /* Platform setup (run once per boot) */ 49 /* Hypervisor type */
39 void (*init_platform)(void); 50 enum x86_hypervisor_type type;
40
41 /* X2APIC detection (run once per boot) */
42 bool (*x2apic_available)(void);
43 51
44 /* pin current vcpu to specified physical cpu (run rarely) */ 52 /* init time callbacks */
45 void (*pin_vcpu)(int); 53 struct x86_hyper_init init;
46 54
47 /* called during init_mem_mapping() to setup early mappings. */ 55 /* runtime callbacks */
48 void (*init_mem_mapping)(void); 56 struct x86_hyper_runtime runtime;
49}; 57};
50 58
51extern const struct hypervisor_x86 *x86_hyper; 59extern enum x86_hypervisor_type x86_hyper_type;
52
53/* Recognized hypervisors */
54extern const struct hypervisor_x86 x86_hyper_vmware;
55extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
56extern const struct hypervisor_x86 x86_hyper_xen_pv;
57extern const struct hypervisor_x86 x86_hyper_xen_hvm;
58extern const struct hypervisor_x86 x86_hyper_kvm;
59
60extern void init_hypervisor_platform(void); 60extern void init_hypervisor_platform(void);
61extern bool hypervisor_x2apic_available(void);
62extern void hypervisor_pin_vcpu(int cpu);
63
64static inline void hypervisor_init_mem_mapping(void)
65{
66 if (x86_hyper && x86_hyper->init_mem_mapping)
67 x86_hyper->init_mem_mapping();
68}
69#else 61#else
70static inline void init_hypervisor_platform(void) { } 62static inline void init_hypervisor_platform(void) { }
71static inline bool hypervisor_x2apic_available(void) { return false; }
72static inline void hypervisor_init_mem_mapping(void) { }
73#endif /* CONFIG_HYPERVISOR_GUEST */ 63#endif /* CONFIG_HYPERVISOR_GUEST */
74#endif /* _ASM_X86_HYPERVISOR_H */ 64#endif /* _ASM_X86_HYPERVISOR_H */