File tree Expand file tree Collapse file tree 11 files changed +40
-31
lines changed Expand file tree Collapse file tree 11 files changed +40
-31
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ void hyperv_init(void)
113
113
u64 guest_id ;
114
114
union hv_x64_msr_hypercall_contents hypercall_msr ;
115
115
116
- if (x86_hyper != & x86_hyper_ms_hyperv )
116
+ if (x86_hyper_type != X86_HYPER_MS_HYPERV )
117
117
return ;
118
118
119
119
/* Allocate percpu VP index */
Original file line number Diff line number Diff line change 29
29
/*
30
30
* x86 hypervisor information
31
31
*/
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
+
32
42
struct hypervisor_x86 {
33
43
/* Hypervisor name */
34
44
const char * name ;
35
45
36
46
/* Detection routine */
37
47
uint32_t (* detect )(void );
38
48
49
+ /* Hypervisor type */
50
+ enum x86_hypervisor_type type ;
51
+
39
52
/* init time callbacks */
40
53
struct x86_hyper_init init ;
41
54
42
55
/* runtime callbacks */
43
56
struct x86_hyper_runtime runtime ;
44
57
};
45
58
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 ;
55
60
extern void init_hypervisor_platform (void );
56
61
#else
57
62
static inline void init_hypervisor_platform (void ) { }
Original file line number Diff line number Diff line change 26
26
#include <asm/processor.h>
27
27
#include <asm/hypervisor.h>
28
28
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
+
29
35
static const __initconst struct hypervisor_x86 * const hypervisors [] =
30
36
{
31
37
#ifdef CONFIG_XEN_PV
@@ -41,8 +47,8 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
41
47
#endif
42
48
};
43
49
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 );
46
52
47
53
static inline const struct hypervisor_x86 * __init
48
54
detect_hypervisor_vendor (void )
@@ -87,6 +93,6 @@ void __init init_hypervisor_platform(void)
87
93
copy_array (& h -> init , & x86_init .hyper , sizeof (h -> init ));
88
94
copy_array (& h -> runtime , & x86_platform .hyper , sizeof (h -> runtime ));
89
95
90
- x86_hyper = h ;
96
+ x86_hyper_type = h -> type ;
91
97
x86_init .hyper .init_platform ();
92
98
}
Original file line number Diff line number Diff line change @@ -254,9 +254,9 @@ static void __init ms_hyperv_init_platform(void)
254
254
#endif
255
255
}
256
256
257
- const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
257
+ const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
258
258
.name = "Microsoft Hyper-V" ,
259
259
.detect = ms_hyperv_platform ,
260
+ .type = X86_HYPER_MS_HYPERV ,
260
261
.init .init_platform = ms_hyperv_init_platform ,
261
262
};
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)
205
205
(eax & (1 << VMWARE_PORT_CMD_LEGACY_X2APIC )) != 0 ;
206
206
}
207
207
208
- const __refconst struct hypervisor_x86 x86_hyper_vmware = {
208
+ const __initconst struct hypervisor_x86 x86_hyper_vmware = {
209
209
.name = "VMware" ,
210
210
.detect = vmware_platform ,
211
+ .type = X86_HYPER_VMWARE ,
211
212
.init .init_platform = vmware_platform_setup ,
212
213
.init .x2apic_available = vmware_legacy_x2apic_available ,
213
214
};
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)
544
544
return kvm_cpuid_base ();
545
545
}
546
546
547
- const struct hypervisor_x86 x86_hyper_kvm __refconst = {
547
+ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
548
548
.name = "KVM" ,
549
549
.detect = kvm_detect ,
550
+ .type = X86_HYPER_KVM ,
550
551
.init .x2apic_available = kvm_para_available ,
551
552
};
552
- EXPORT_SYMBOL_GPL (x86_hyper_kvm );
553
553
554
554
static __init int activate_jump_labels (void )
555
555
{
Original file line number Diff line number Diff line change @@ -226,12 +226,12 @@ static uint32_t __init xen_platform_hvm(void)
226
226
return xen_cpuid_base ();
227
227
}
228
228
229
- const struct hypervisor_x86 x86_hyper_xen_hvm = {
229
+ const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
230
230
.name = "Xen HVM" ,
231
231
.detect = xen_platform_hvm ,
232
+ .type = X86_HYPER_XEN_HVM ,
232
233
.init .init_platform = xen_hvm_guest_init ,
233
234
.init .x2apic_available = xen_x2apic_para_available ,
234
235
.init .init_mem_mapping = xen_hvm_init_mem_mapping ,
235
236
.runtime .pin_vcpu = xen_pin_vcpu ,
236
237
};
237
- EXPORT_SYMBOL (x86_hyper_xen_hvm );
Original file line number Diff line number Diff line change @@ -1460,9 +1460,9 @@ static uint32_t __init xen_platform_pv(void)
1460
1460
return 0 ;
1461
1461
}
1462
1462
1463
- const struct hypervisor_x86 x86_hyper_xen_pv = {
1463
+ const __initconst struct hypervisor_x86 x86_hyper_xen_pv = {
1464
1464
.name = "Xen PV" ,
1465
1465
.detect = xen_platform_pv ,
1466
+ .type = X86_HYPER_XEN_PV ,
1466
1467
.runtime .pin_vcpu = xen_pin_vcpu ,
1467
1468
};
1468
- 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)
1534
1534
{
1535
1535
int ret , t ;
1536
1536
1537
- if (x86_hyper != & x86_hyper_ms_hyperv )
1537
+ if (x86_hyper_type != X86_HYPER_MS_HYPERV )
1538
1538
return - ENODEV ;
1539
1539
1540
1540
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)
316
316
/*
317
317
* Array of supported hypervisors.
318
318
*/
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 ,
324
322
};
325
323
326
324
/**
@@ -331,7 +329,7 @@ static bool vmmouse_check_hypervisor(void)
331
329
int i ;
332
330
333
331
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 )
335
333
return true;
336
334
337
335
return false;
You can’t perform that action at this time.
0 commit comments