]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
x86/virt: Add enum for hypervisors to replace x86_hyper
authorJuergen Gross <jgross@suse.com>
Thu, 9 Nov 2017 13:27:36 +0000 (14:27 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 10 Nov 2017 09:03:12 +0000 (10:03 +0100)
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>
arch/x86/hyperv/hv_init.c
arch/x86/include/asm/hypervisor.h
arch/x86/kernel/cpu/hypervisor.c
arch/x86/kernel/cpu/mshyperv.c
arch/x86/kernel/cpu/vmware.c
arch/x86/kernel/kvm.c
arch/x86/xen/enlighten_hvm.c
arch/x86/xen/enlighten_pv.c
drivers/hv/vmbus_drv.c
drivers/input/mouse/vmmouse.c
drivers/misc/vmw_balloon.c

index a5db63f728a2f985bde0f1b98f87be4537913cdc..a0b86cf486e0adcf1e7d505bd003056a3e2a1b87 100644 (file)
@@ -113,7 +113,7 @@ void hyperv_init(void)
        u64 guest_id;
        union hv_x64_msr_hypercall_contents hypercall_msr;
 
-       if (x86_hyper != &x86_hyper_ms_hyperv)
+       if (x86_hyper_type != X86_HYPER_MS_HYPERV)
                return;
 
        /* Allocate percpu VP index */
index 0eca7239a7aadee920ade2b3eab5e99adaa2fca2..1b0a5abcd8aeb6e700013c5434aaeb0bba7a152f 100644 (file)
 /*
  * x86 hypervisor information
  */
+
+enum x86_hypervisor_type {
+       X86_HYPER_NATIVE = 0,
+       X86_HYPER_VMWARE,
+       X86_HYPER_MS_HYPERV,
+       X86_HYPER_XEN_PV,
+       X86_HYPER_XEN_HVM,
+       X86_HYPER_KVM,
+};
+
 struct hypervisor_x86 {
        /* Hypervisor name */
        const char      *name;
@@ -36,6 +46,9 @@ struct hypervisor_x86 {
        /* Detection routine */
        uint32_t        (*detect)(void);
 
+       /* Hypervisor type */
+       enum x86_hypervisor_type type;
+
        /* init time callbacks */
        struct x86_hyper_init init;
 
@@ -43,15 +56,7 @@ struct hypervisor_x86 {
        struct x86_hyper_runtime runtime;
 };
 
-extern const struct hypervisor_x86 *x86_hyper;
-
-/* Recognized hypervisors */
-extern const struct hypervisor_x86 x86_hyper_vmware;
-extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
-extern const struct hypervisor_x86 x86_hyper_xen_pv;
-extern const struct hypervisor_x86 x86_hyper_xen_hvm;
-extern const struct hypervisor_x86 x86_hyper_kvm;
-
+extern enum x86_hypervisor_type x86_hyper_type;
 extern void init_hypervisor_platform(void);
 #else
 static inline void init_hypervisor_platform(void) { }
index 22226c1bf092a32b9ffc53d7f60ce9ada3badc29..bea8d3e24f508704ca80210e6b864bd07e51bfc5 100644 (file)
 #include <asm/processor.h>
 #include <asm/hypervisor.h>
 
+extern const struct hypervisor_x86 x86_hyper_vmware;
+extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
+extern const struct hypervisor_x86 x86_hyper_xen_pv;
+extern const struct hypervisor_x86 x86_hyper_xen_hvm;
+extern const struct hypervisor_x86 x86_hyper_kvm;
+
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
 #ifdef CONFIG_XEN_PV
@@ -41,8 +47,8 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
 #endif
 };
 
-const struct hypervisor_x86 *x86_hyper;
-EXPORT_SYMBOL(x86_hyper);
+enum x86_hypervisor_type x86_hyper_type;
+EXPORT_SYMBOL(x86_hyper_type);
 
 static inline const struct hypervisor_x86 * __init
 detect_hypervisor_vendor(void)
@@ -87,6 +93,6 @@ void __init init_hypervisor_platform(void)
        copy_array(&h->init, &x86_init.hyper, sizeof(h->init));
        copy_array(&h->runtime, &x86_platform.hyper, sizeof(h->runtime));
 
-       x86_hyper = h;
+       x86_hyper_type = h->type;
        x86_init.hyper.init_platform();
 }
index 6bb84d655e4b7df59abc40d32ba98d2f1892dd40..85eb5fc180c8194f473529182237897386dd927a 100644 (file)
@@ -254,9 +254,9 @@ static void __init ms_hyperv_init_platform(void)
 #endif
 }
 
-const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
+const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
        .name                   = "Microsoft Hyper-V",
        .detect                 = ms_hyperv_platform,
+       .type                   = X86_HYPER_MS_HYPERV,
        .init.init_platform     = ms_hyperv_init_platform,
 };
-EXPORT_SYMBOL(x86_hyper_ms_hyperv);
index 4804c1d063c84f46cd6e70d3fc6654ae2082e509..8e005329648b6b49d9afe671062368fe25db38e9 100644 (file)
@@ -205,10 +205,10 @@ static bool __init vmware_legacy_x2apic_available(void)
               (eax & (1 << VMWARE_PORT_CMD_LEGACY_X2APIC)) != 0;
 }
 
-const __refconst struct hypervisor_x86 x86_hyper_vmware = {
+const __initconst struct hypervisor_x86 x86_hyper_vmware = {
        .name                   = "VMware",
        .detect                 = vmware_platform,
+       .type                   = X86_HYPER_VMWARE,
        .init.init_platform     = vmware_platform_setup,
        .init.x2apic_available  = vmware_legacy_x2apic_available,
 };
-EXPORT_SYMBOL(x86_hyper_vmware);
index 9dca8437c79504219143a1e3607f715bddcda12f..a94de09edbed25cf0571f002fa65fe67773c665c 100644 (file)
@@ -544,12 +544,12 @@ static uint32_t __init kvm_detect(void)
        return kvm_cpuid_base();
 }
 
-const struct hypervisor_x86 x86_hyper_kvm __refconst = {
+const __initconst struct hypervisor_x86 x86_hyper_kvm = {
        .name                   = "KVM",
        .detect                 = kvm_detect,
+       .type                   = X86_HYPER_KVM,
        .init.x2apic_available  = kvm_para_available,
 };
-EXPORT_SYMBOL_GPL(x86_hyper_kvm);
 
 static __init int activate_jump_labels(void)
 {
index 7b1622089f96595d3fd082bfca6ed5ab02918e4a..754d5391d9fa766b72c2a9c1b5ba4b6098f46d7b 100644 (file)
@@ -226,12 +226,12 @@ static uint32_t __init xen_platform_hvm(void)
        return xen_cpuid_base();
 }
 
-const struct hypervisor_x86 x86_hyper_xen_hvm = {
+const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = {
        .name                   = "Xen HVM",
        .detect                 = xen_platform_hvm,
+       .type                   = X86_HYPER_XEN_HVM,
        .init.init_platform     = xen_hvm_guest_init,
        .init.x2apic_available  = xen_x2apic_para_available,
        .init.init_mem_mapping  = xen_hvm_init_mem_mapping,
        .runtime.pin_vcpu       = xen_pin_vcpu,
 };
-EXPORT_SYMBOL(x86_hyper_xen_hvm);
index 69d1a7054ddb75ec1540bc4c924e008371ae9c1d..168efb2534c0ecc9956dc499f7489d1604838bf8 100644 (file)
@@ -1460,9 +1460,9 @@ static uint32_t __init xen_platform_pv(void)
        return 0;
 }
 
-const struct hypervisor_x86 x86_hyper_xen_pv = {
+const __initconst struct hypervisor_x86 x86_hyper_xen_pv = {
        .name                   = "Xen PV",
        .detect                 = xen_platform_pv,
+       .type                   = X86_HYPER_XEN_PV,
        .runtime.pin_vcpu       = xen_pin_vcpu,
 };
-EXPORT_SYMBOL(x86_hyper_xen_pv);
index 937801ac2fe0eafb3d148072a604c4e50a159572..2cd134dd94d2140c0ee49a87d1b2ca7f89d56ddc 100644 (file)
@@ -1534,7 +1534,7 @@ static int __init hv_acpi_init(void)
 {
        int ret, t;
 
-       if (x86_hyper != &x86_hyper_ms_hyperv)
+       if (x86_hyper_type != X86_HYPER_MS_HYPERV)
                return -ENODEV;
 
        init_completion(&probe_event);
index 0f586780ceb4bee18a38428b889dba8d994ea4c7..1ae5c1ef3f5bbbc0c8cd0e4e35c24d37e493f703 100644 (file)
@@ -316,11 +316,9 @@ static int vmmouse_enable(struct psmouse *psmouse)
 /*
  * Array of supported hypervisors.
  */
-static const struct hypervisor_x86 *vmmouse_supported_hypervisors[] = {
-       &x86_hyper_vmware,
-#ifdef CONFIG_KVM_GUEST
-       &x86_hyper_kvm,
-#endif
+static enum x86_hypervisor_type vmmouse_supported_hypervisors[] = {
+       X86_HYPER_VMWARE,
+       X86_HYPER_KVM,
 };
 
 /**
@@ -331,7 +329,7 @@ static bool vmmouse_check_hypervisor(void)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(vmmouse_supported_hypervisors); i++)
-               if (vmmouse_supported_hypervisors[i] == x86_hyper)
+               if (vmmouse_supported_hypervisors[i] == x86_hyper_type)
                        return true;
 
        return false;
index 1e688bfec56728c3d00ebc353031c26fde29f187..9047c0a529b28221da8458668cd0673c0c5144d0 100644 (file)
@@ -1271,7 +1271,7 @@ static int __init vmballoon_init(void)
         * Check if we are running on VMware's hypervisor and bail out
         * if we are not.
         */
-       if (x86_hyper != &x86_hyper_vmware)
+       if (x86_hyper_type != X86_HYPER_VMWARE)
                return -ENODEV;
 
        for (is_2m_pages = 0; is_2m_pages < VMW_BALLOON_NUM_PAGE_SIZES;