File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ void hyperv_init(void)
113113 u64 guest_id ;
114114 union hv_x64_msr_hypercall_contents hypercall_msr ;
115115
116- if (x86_hyper != & x86_hyper_ms_hyperv )
116+ if (x86_hyper_type != X86_HYPER_MS_HYPERV )
117117 return ;
118118
119119 /* Allocate percpu VP index */
Original file line number Diff line number Diff line change 2929/*
3030 * x86 hypervisor information
3131 */
32+
33+ enum 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+
3242struct hypervisor_x86 {
3343 /* Hypervisor name */
3444 const char * name ;
3545
3646 /* Detection routine */
3747 uint32_t (* detect )(void );
3848
49+ /* Hypervisor type */
50+ enum x86_hypervisor_type type ;
51+
3952 /* init time callbacks */
4053 struct x86_hyper_init init ;
4154
4255 /* runtime callbacks */
4356 struct x86_hyper_runtime runtime ;
4457};
4558
46- extern const struct hypervisor_x86 * x86_hyper ;
47-
48- /* Recognized hypervisors */
49- extern const struct hypervisor_x86 x86_hyper_vmware ;
50- extern const struct hypervisor_x86 x86_hyper_ms_hyperv ;
51- extern const struct hypervisor_x86 x86_hyper_xen_pv ;
52- extern const struct hypervisor_x86 x86_hyper_xen_hvm ;
53- extern const struct hypervisor_x86 x86_hyper_kvm ;
54-
59+ extern enum x86_hypervisor_type x86_hyper_type ;
5560extern void init_hypervisor_platform (void );
5661#else
5762static inline void init_hypervisor_platform (void ) { }
Original file line number Diff line number Diff line change 2626#include <asm/processor.h>
2727#include <asm/hypervisor.h>
2828
29+ extern const struct hypervisor_x86 x86_hyper_vmware ;
30+ extern const struct hypervisor_x86 x86_hyper_ms_hyperv ;
31+ extern const struct hypervisor_x86 x86_hyper_xen_pv ;
32+ extern const struct hypervisor_x86 x86_hyper_xen_hvm ;
33+ extern const struct hypervisor_x86 x86_hyper_kvm ;
34+
2935static const __initconst struct hypervisor_x86 * const hypervisors [] =
3036{
3137#ifdef CONFIG_XEN_PV
@@ -41,8 +47,8 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
4147#endif
4248};
4349
44- const struct hypervisor_x86 * x86_hyper ;
45- EXPORT_SYMBOL (x86_hyper );
50+ enum x86_hypervisor_type x86_hyper_type ;
51+ EXPORT_SYMBOL (x86_hyper_type );
4652
4753static inline const struct hypervisor_x86 * __init
4854detect_hypervisor_vendor (void )
@@ -87,6 +93,6 @@ void __init init_hypervisor_platform(void)
8793 copy_array (& h -> init , & x86_init .hyper , sizeof (h -> init ));
8894 copy_array (& h -> runtime , & x86_platform .hyper , sizeof (h -> runtime ));
8995
90- x86_hyper = h ;
96+ x86_hyper_type = h -> type ;
9197 x86_init .hyper .init_platform ();
9298}
Original file line number Diff line number Diff line change @@ -254,9 +254,9 @@ static void __init ms_hyperv_init_platform(void)
254254#endif
255255}
256256
257- const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
257+ const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
258258 .name = "Microsoft Hyper-V" ,
259259 .detect = ms_hyperv_platform ,
260+ .type = X86_HYPER_MS_HYPERV ,
260261 .init .init_platform = ms_hyperv_init_platform ,
261262};
262- EXPORT_SYMBOL (x86_hyper_ms_hyperv );
Original file line number Diff line number Diff line change @@ -205,10 +205,10 @@ static bool __init vmware_legacy_x2apic_available(void)
205205 (eax & (1 << VMWARE_PORT_CMD_LEGACY_X2APIC )) != 0 ;
206206}
207207
208- const __refconst struct hypervisor_x86 x86_hyper_vmware = {
208+ const __initconst struct hypervisor_x86 x86_hyper_vmware = {
209209 .name = "VMware" ,
210210 .detect = vmware_platform ,
211+ .type = X86_HYPER_VMWARE ,
211212 .init .init_platform = vmware_platform_setup ,
212213 .init .x2apic_available = vmware_legacy_x2apic_available ,
213214};
214- EXPORT_SYMBOL (x86_hyper_vmware );
Original file line number Diff line number Diff line change @@ -544,12 +544,12 @@ static uint32_t __init kvm_detect(void)
544544 return kvm_cpuid_base ();
545545}
546546
547- const struct hypervisor_x86 x86_hyper_kvm __refconst = {
547+ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
548548 .name = "KVM" ,
549549 .detect = kvm_detect ,
550+ .type = X86_HYPER_KVM ,
550551 .init .x2apic_available = kvm_para_available ,
551552};
552- EXPORT_SYMBOL_GPL (x86_hyper_kvm );
553553
554554static __init int activate_jump_labels (void )
555555{
Original file line number Diff line number Diff line change @@ -226,12 +226,12 @@ static uint32_t __init xen_platform_hvm(void)
226226 return xen_cpuid_base ();
227227}
228228
229- const struct hypervisor_x86 x86_hyper_xen_hvm = {
229+ const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
230230 .name = "Xen HVM" ,
231231 .detect = xen_platform_hvm ,
232+ .type = X86_HYPER_XEN_HVM ,
232233 .init .init_platform = xen_hvm_guest_init ,
233234 .init .x2apic_available = xen_x2apic_para_available ,
234235 .init .init_mem_mapping = xen_hvm_init_mem_mapping ,
235236 .runtime .pin_vcpu = xen_pin_vcpu ,
236237};
237- EXPORT_SYMBOL (x86_hyper_xen_hvm );
Original file line number Diff line number Diff line change @@ -1459,9 +1459,9 @@ static uint32_t __init xen_platform_pv(void)
14591459 return 0 ;
14601460}
14611461
1462- const struct hypervisor_x86 x86_hyper_xen_pv = {
1462+ const __initconst struct hypervisor_x86 x86_hyper_xen_pv = {
14631463 .name = "Xen PV" ,
14641464 .detect = xen_platform_pv ,
1465+ .type = X86_HYPER_XEN_PV ,
14651466 .runtime .pin_vcpu = xen_pin_vcpu ,
14661467};
1467- EXPORT_SYMBOL (x86_hyper_xen_pv );
Original file line number Diff line number Diff line change @@ -1534,7 +1534,7 @@ static int __init hv_acpi_init(void)
15341534{
15351535 int ret , t ;
15361536
1537- if (x86_hyper != & x86_hyper_ms_hyperv )
1537+ if (x86_hyper_type != X86_HYPER_MS_HYPERV )
15381538 return - ENODEV ;
15391539
15401540 init_completion (& probe_event );
Original file line number Diff line number Diff line change @@ -316,11 +316,9 @@ static int vmmouse_enable(struct psmouse *psmouse)
316316/*
317317 * Array of supported hypervisors.
318318 */
319- static const struct hypervisor_x86 * vmmouse_supported_hypervisors [] = {
320- & x86_hyper_vmware ,
321- #ifdef CONFIG_KVM_GUEST
322- & x86_hyper_kvm ,
323- #endif
319+ static enum x86_hypervisor_type vmmouse_supported_hypervisors [] = {
320+ X86_HYPER_VMWARE ,
321+ X86_HYPER_KVM ,
324322};
325323
326324/**
@@ -331,7 +329,7 @@ static bool vmmouse_check_hypervisor(void)
331329 int i ;
332330
333331 for (i = 0 ; i < ARRAY_SIZE (vmmouse_supported_hypervisors ); i ++ )
334- if (vmmouse_supported_hypervisors [i ] == x86_hyper )
332+ if (vmmouse_supported_hypervisors [i ] == x86_hyper_type )
335333 return true;
336334
337335 return false;
You can’t perform that action at this time.
0 commit comments