aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2017-11-09 08:27:36 -0500
committerIngo Molnar <mingo@kernel.org>2017-11-10 04:03:12 -0500
commit03b2a320b19f1424e9ac9c21696be9c60b6d0d93 (patch)
tree90a3a16cf837ea9a25cdd991771b1bdcfd8746a1
parentf72e38e8ec8869ac0ba5a75d7d2f897d98a1454e (diff)
x86/virt: Add enum for hypervisors to replace x86_hyper
The x86_hyper pointer is only used for checking whether a virtual device is supporting the hypervisor the system is running on. Use an enum for that purpose instead and drop the x86_hyper pointer. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Xavier Deguillard <xdeguillard@vmware.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: akataria@vmware.com Cc: arnd@arndb.de Cc: boris.ostrovsky@oracle.com Cc: devel@linuxdriverproject.org Cc: dmitry.torokhov@gmail.com Cc: gregkh@linuxfoundation.org Cc: haiyangz@microsoft.com Cc: kvm@vger.kernel.org Cc: kys@microsoft.com Cc: linux-graphics-maintainer@vmware.com Cc: linux-input@vger.kernel.org Cc: moltmann@vmware.com Cc: pbonzini@redhat.com Cc: pv-drivers@vmware.com Cc: rkrcmar@redhat.com Cc: sthemmin@microsoft.com Cc: virtualization@lists.linux-foundation.org Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/20171109132739.23465-3-jgross@suse.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/hyperv/hv_init.c2
-rw-r--r--arch/x86/include/asm/hypervisor.h23
-rw-r--r--arch/x86/kernel/cpu/hypervisor.c12
-rw-r--r--arch/x86/kernel/cpu/mshyperv.c4
-rw-r--r--arch/x86/kernel/cpu/vmware.c4
-rw-r--r--arch/x86/kernel/kvm.c4
-rw-r--r--arch/x86/xen/enlighten_hvm.c4
-rw-r--r--arch/x86/xen/enlighten_pv.c4
-rw-r--r--drivers/hv/vmbus_drv.c2
-rw-r--r--drivers/input/mouse/vmmouse.c10
-rw-r--r--drivers/misc/vmw_balloon.c2
11 files changed, 40 insertions, 31 deletions
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index a5db63f728a2..a0b86cf486e0 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -113,7 +113,7 @@ void hyperv_init(void)
113 u64 guest_id; 113 u64 guest_id;
114 union hv_x64_msr_hypercall_contents hypercall_msr; 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 return; 117 return;
118 118
119 /* Allocate percpu VP index */ 119 /* Allocate percpu VP index */
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 0eca7239a7aa..1b0a5abcd8ae 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -29,6 +29,16 @@
29/* 29/*
30 * x86 hypervisor information 30 * x86 hypervisor information
31 */ 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
32struct hypervisor_x86 { 42struct hypervisor_x86 {
33 /* Hypervisor name */ 43 /* Hypervisor name */
34 const char *name; 44 const char *name;
@@ -36,6 +46,9 @@ struct hypervisor_x86 {
36 /* Detection routine */ 46 /* Detection routine */
37 uint32_t (*detect)(void); 47 uint32_t (*detect)(void);
38 48
49 /* Hypervisor type */
50 enum x86_hypervisor_type type;
51
39 /* init time callbacks */ 52 /* init time callbacks */
40 struct x86_hyper_init init; 53 struct x86_hyper_init init;
41 54
@@ -43,15 +56,7 @@ struct hypervisor_x86 {
43 struct x86_hyper_runtime runtime; 56 struct x86_hyper_runtime runtime;
44}; 57};
45 58
46extern const struct hypervisor_x86 *x86_hyper; 59extern enum x86_hypervisor_type x86_hyper_type;
47
48/* Recognized hypervisors */
49extern const struct hypervisor_x86 x86_hyper_vmware;
50extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
51extern const struct hypervisor_x86 x86_hyper_xen_pv;
52extern const struct hypervisor_x86 x86_hyper_xen_hvm;
53extern const struct hypervisor_x86 x86_hyper_kvm;
54
55extern void init_hypervisor_platform(void); 60extern void init_hypervisor_platform(void);
56#else 61#else
57static inline void init_hypervisor_platform(void) { } 62static inline void init_hypervisor_platform(void) { }
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 22226c1bf092..bea8d3e24f50 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -26,6 +26,12 @@
26#include <asm/processor.h> 26#include <asm/processor.h>
27#include <asm/hypervisor.h> 27#include <asm/hypervisor.h>
28 28
29extern const struct hypervisor_x86 x86_hyper_vmware;
30extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
31extern const struct hypervisor_x86 x86_hyper_xen_pv;
32extern const struct hypervisor_x86 x86_hyper_xen_hvm;
33extern const struct hypervisor_x86 x86_hyper_kvm;
34
29static const __initconst struct hypervisor_x86 * const hypervisors[] = 35static const __initconst struct hypervisor_x86 * const hypervisors[] =
30{ 36{
31#ifdef CONFIG_XEN_PV 37#ifdef CONFIG_XEN_PV
@@ -41,8 +47,8 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
41#endif 47#endif
42}; 48};
43 49
44const struct hypervisor_x86 *x86_hyper; 50enum x86_hypervisor_type x86_hyper_type;
45EXPORT_SYMBOL(x86_hyper); 51EXPORT_SYMBOL(x86_hyper_type);
46 52
47static inline const struct hypervisor_x86 * __init 53static inline const struct hypervisor_x86 * __init
48detect_hypervisor_vendor(void) 54detect_hypervisor_vendor(void)
@@ -87,6 +93,6 @@ void __init init_hypervisor_platform(void)
87 copy_array(&h->init, &x86_init.hyper, sizeof(h->init)); 93 copy_array(&h->init, &x86_init.hyper, sizeof(h->init));
88 copy_array(&h->runtime, &x86_platform.hyper, sizeof(h->runtime)); 94 copy_array(&h->runtime, &x86_platform.hyper, sizeof(h->runtime));
89 95
90 x86_hyper = h; 96 x86_hyper_type = h->type;
91 x86_init.hyper.init_platform(); 97 x86_init.hyper.init_platform();
92} 98}
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 6bb84d655e4b..85eb5fc180c8 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -254,9 +254,9 @@ static void __init ms_hyperv_init_platform(void)
254#endif 254#endif
255} 255}
256 256
257const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = { 257const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
258 .name = "Microsoft Hyper-V", 258 .name = "Microsoft Hyper-V",
259 .detect = ms_hyperv_platform, 259 .detect = ms_hyperv_platform,
260 .type = X86_HYPER_MS_HYPERV,
260 .init.init_platform = ms_hyperv_init_platform, 261 .init.init_platform = ms_hyperv_init_platform,
261}; 262};
262EXPORT_SYMBOL(x86_hyper_ms_hyperv);
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 4804c1d063c8..8e005329648b 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -205,10 +205,10 @@ static bool __init vmware_legacy_x2apic_available(void)
205 (eax & (1 << VMWARE_PORT_CMD_LEGACY_X2APIC)) != 0; 205 (eax & (1 << VMWARE_PORT_CMD_LEGACY_X2APIC)) != 0;
206} 206}
207 207
208const __refconst struct hypervisor_x86 x86_hyper_vmware = { 208const __initconst struct hypervisor_x86 x86_hyper_vmware = {
209 .name = "VMware", 209 .name = "VMware",
210 .detect = vmware_platform, 210 .detect = vmware_platform,
211 .type = X86_HYPER_VMWARE,
211 .init.init_platform = vmware_platform_setup, 212 .init.init_platform = vmware_platform_setup,
212 .init.x2apic_available = vmware_legacy_x2apic_available, 213 .init.x2apic_available = vmware_legacy_x2apic_available,
213}; 214};
214EXPORT_SYMBOL(x86_hyper_vmware);
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 9dca8437c795..a94de09edbed 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -544,12 +544,12 @@ static uint32_t __init kvm_detect(void)
544 return kvm_cpuid_base(); 544 return kvm_cpuid_base();
545} 545}
546 546
547const struct hypervisor_x86 x86_hyper_kvm __refconst = { 547const __initconst struct hypervisor_x86 x86_hyper_kvm = {
548 .name = "KVM", 548 .name = "KVM",
549 .detect = kvm_detect, 549 .detect = kvm_detect,
550 .type = X86_HYPER_KVM,
550 .init.x2apic_available = kvm_para_available, 551 .init.x2apic_available = kvm_para_available,
551}; 552};
552EXPORT_SYMBOL_GPL(x86_hyper_kvm);
553 553
554static __init int activate_jump_labels(void) 554static __init int activate_jump_labels(void)
555{ 555{
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 7b1622089f96..754d5391d9fa 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -226,12 +226,12 @@ static uint32_t __init xen_platform_hvm(void)
226 return xen_cpuid_base(); 226 return xen_cpuid_base();
227} 227}
228 228
229const struct hypervisor_x86 x86_hyper_xen_hvm = { 229const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
230 .name = "Xen HVM", 230 .name = "Xen HVM",
231 .detect = xen_platform_hvm, 231 .detect = xen_platform_hvm,
232 .type = X86_HYPER_XEN_HVM,
232 .init.init_platform = xen_hvm_guest_init, 233 .init.init_platform = xen_hvm_guest_init,
233 .init.x2apic_available = xen_x2apic_para_available, 234 .init.x2apic_available = xen_x2apic_para_available,
234 .init.init_mem_mapping = xen_hvm_init_mem_mapping, 235 .init.init_mem_mapping = xen_hvm_init_mem_mapping,
235 .runtime.pin_vcpu = xen_pin_vcpu, 236 .runtime.pin_vcpu = xen_pin_vcpu,
236}; 237};
237EXPORT_SYMBOL(x86_hyper_xen_hvm);
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 69d1a7054ddb..168efb2534c0 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1460,9 +1460,9 @@ static uint32_t __init xen_platform_pv(void)
1460 return 0; 1460 return 0;
1461} 1461}
1462 1462
1463const struct hypervisor_x86 x86_hyper_xen_pv = { 1463const __initconst struct hypervisor_x86 x86_hyper_xen_pv = {
1464 .name = "Xen PV", 1464 .name = "Xen PV",
1465 .detect = xen_platform_pv, 1465 .detect = xen_platform_pv,
1466 .type = X86_HYPER_XEN_PV,
1466 .runtime.pin_vcpu = xen_pin_vcpu, 1467 .runtime.pin_vcpu = xen_pin_vcpu,
1467}; 1468};
1468EXPORT_SYMBOL(x86_hyper_xen_pv);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 937801ac2fe0..2cd134dd94d2 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1534,7 +1534,7 @@ static int __init hv_acpi_init(void)
1534{ 1534{
1535 int ret, t; 1535 int ret, t;
1536 1536
1537 if (x86_hyper != &x86_hyper_ms_hyperv) 1537 if (x86_hyper_type != X86_HYPER_MS_HYPERV)
1538 return -ENODEV; 1538 return -ENODEV;
1539 1539
1540 init_completion(&probe_event); 1540 init_completion(&probe_event);
diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index 0f586780ceb4..1ae5c1ef3f5b 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -316,11 +316,9 @@ static int vmmouse_enable(struct psmouse *psmouse)
316/* 316/*
317 * Array of supported hypervisors. 317 * Array of supported hypervisors.
318 */ 318 */
319static const struct hypervisor_x86 *vmmouse_supported_hypervisors[] = { 319static enum x86_hypervisor_type vmmouse_supported_hypervisors[] = {
320 &x86_hyper_vmware, 320 X86_HYPER_VMWARE,
321#ifdef CONFIG_KVM_GUEST 321 X86_HYPER_KVM,
322 &x86_hyper_kvm,
323#endif
324}; 322};
325 323
326/** 324/**
@@ -331,7 +329,7 @@ static bool vmmouse_check_hypervisor(void)
331 int i; 329 int i;
332 330
333 for (i = 0; i < ARRAY_SIZE(vmmouse_supported_hypervisors); i++) 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 return true; 333 return true;
336 334
337 return false; 335 return false;
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 1e688bfec567..9047c0a529b2 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -1271,7 +1271,7 @@ static int __init vmballoon_init(void)
1271 * Check if we are running on VMware's hypervisor and bail out 1271 * Check if we are running on VMware's hypervisor and bail out
1272 * if we are not. 1272 * if we are not.
1273 */ 1273 */
1274 if (x86_hyper != &x86_hyper_vmware) 1274 if (x86_hyper_type != X86_HYPER_VMWARE)
1275 return -ENODEV; 1275 return -ENODEV;
1276 1276
1277 for (is_2m_pages = 0; is_2m_pages < VMW_BALLOON_NUM_PAGE_SIZES; 1277 for (is_2m_pages = 0; is_2m_pages < VMW_BALLOON_NUM_PAGE_SIZES;