RE: [PATCH v2 2/5] x86: add enum for hypervisors to replace x86_hyper
> -Original Message- > From: Dmitry Torokhov [mailto:dmitry.torok...@gmail.com] > Sent: Friday, November 10, 2017 10:26 AM > To: Juergen Gross > Cc: linux-ker...@vger.kernel.org; t...@linutronix.de; mi...@redhat.com; > h...@zytor.com; x...@kernel.org; KY Srinivasan ; > Haiyang Zhang ; Stephen Hemminger > ; akata...@vmware.com; > pbonz...@redhat.com; rkrc...@redhat.com; boris.ostrov...@oracle.com; > de...@linuxdriverproject.org; virtualization@lists.linux-foundation.org; > k...@vger.kernel.org; xen-de...@lists.xenproject.org; linux-graphics- > maintai...@vmware.com; pv-driv...@vmware.com; > xdeguill...@vmware.com; moltm...@vmware.com; a...@arndb.de; > gre...@linuxfoundation.org; linux-in...@vger.kernel.org > Subject: Re: [PATCH v2 2/5] x86: add enum for hypervisors to replace > x86_hyper > > On Thu, Nov 09, 2017 at 02:27:36PM +0100, Juergen Gross wrote: > > 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. > > > > Cc: k...@microsoft.com > > Cc: haiya...@microsoft.com > > Cc: sthem...@microsoft.com > > Cc: akata...@vmware.com > > Cc: pbonz...@redhat.com > > Cc: rkrc...@redhat.com > > Cc: boris.ostrov...@oracle.com > > Cc: de...@linuxdriverproject.org > > Cc: virtualization@lists.linux-foundation.org > > Cc: k...@vger.kernel.org > > Cc: xen-de...@lists.xenproject.org > > Cc: linux-graphics-maintai...@vmware.com > > Cc: pv-driv...@vmware.com > > Cc: dmitry.torok...@gmail.com > > Cc: xdeguill...@vmware.com > > Cc: moltm...@vmware.com > > Cc: a...@arndb.de > > Cc: gre...@linuxfoundation.org > > Cc: linux-in...@vger.kernel.org > > > > Signed-off-by: Juergen Gross > > --- > > arch/x86/hyperv/hv_init.c | 2 +- > > arch/x86/include/asm/hypervisor.h | 23 ++- > > arch/x86/kernel/cpu/hypervisor.c | 12 +--- > > arch/x86/kernel/cpu/mshyperv.c| 4 ++-- > > arch/x86/kernel/cpu/vmware.c | 4 ++-- > > arch/x86/kernel/kvm.c | 4 ++-- > > arch/x86/xen/enlighten_hvm.c | 4 ++-- > > arch/x86/xen/enlighten_pv.c | 4 ++-- > > drivers/hv/vmbus_drv.c| 2 +- > > drivers/input/mouse/vmmouse.c | 10 -- > > Acked-by: Dmitry Torokhov Acked-by: K. Y. Srinivasan > > > drivers/misc/vmw_balloon.c| 2 +- > > 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) > > 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 */ > > 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 @@ > > /* > > * 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_
Re: [PATCH v2 2/5] x86: add enum for hypervisors to replace x86_hyper
On Thu, Nov 09, 2017 at 02:27:36PM +0100, Juergen Gross wrote: > 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. > > Cc: k...@microsoft.com > Cc: haiya...@microsoft.com > Cc: sthem...@microsoft.com > Cc: akata...@vmware.com > Cc: pbonz...@redhat.com > Cc: rkrc...@redhat.com > Cc: boris.ostrov...@oracle.com > Cc: de...@linuxdriverproject.org > Cc: virtualization@lists.linux-foundation.org > Cc: k...@vger.kernel.org > Cc: xen-de...@lists.xenproject.org > Cc: linux-graphics-maintai...@vmware.com > Cc: pv-driv...@vmware.com > Cc: dmitry.torok...@gmail.com > Cc: xdeguill...@vmware.com > Cc: moltm...@vmware.com > Cc: a...@arndb.de > Cc: gre...@linuxfoundation.org > Cc: linux-in...@vger.kernel.org > > Signed-off-by: Juergen Gross > --- > arch/x86/hyperv/hv_init.c | 2 +- > arch/x86/include/asm/hypervisor.h | 23 ++- > arch/x86/kernel/cpu/hypervisor.c | 12 +--- > arch/x86/kernel/cpu/mshyperv.c| 4 ++-- > arch/x86/kernel/cpu/vmware.c | 4 ++-- > arch/x86/kernel/kvm.c | 4 ++-- > arch/x86/xen/enlighten_hvm.c | 4 ++-- > arch/x86/xen/enlighten_pv.c | 4 ++-- > drivers/hv/vmbus_drv.c| 2 +- > drivers/input/mouse/vmmouse.c | 10 -- Acked-by: Dmitry Torokhov > drivers/misc/vmw_balloon.c| 2 +- > 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) > 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 */ > 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 @@ > /* > * 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) { } > diff --git a/arch/x86/kernel/cpu/hypervisor.c > b/arch/x86/kernel/cpu/hypervisor.c > index 6c1bf092..bea8d3e24f50 100644 > --- a/arch/x86/kernel/cpu/hypervisor.c > +++ b/arch/x86/kernel/cpu/hypervisor.c > @@ -26,6 +26,12 @@ > #include > #include > > +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(); > } > 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
Re: [PATCH v2 2/5] x86: add enum for hypervisors to replace x86_hyper
Hello Juergen, The changes to vmw_balloon.c looks good. Acked-by: Xavier Deguillard Xavier On Thu, Nov 09, 2017 at 02:27:36PM +0100, Juergen Gross wrote: > 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. > > Cc: k...@microsoft.com > Cc: haiya...@microsoft.com > Cc: sthem...@microsoft.com > Cc: akata...@vmware.com > Cc: pbonz...@redhat.com > Cc: rkrc...@redhat.com > Cc: boris.ostrov...@oracle.com > Cc: de...@linuxdriverproject.org > Cc: virtualization@lists.linux-foundation.org > Cc: k...@vger.kernel.org > Cc: xen-de...@lists.xenproject.org > Cc: linux-graphics-maintai...@vmware.com > Cc: pv-driv...@vmware.com > Cc: dmitry.torok...@gmail.com > Cc: xdeguill...@vmware.com > Cc: moltm...@vmware.com > Cc: a...@arndb.de > Cc: gre...@linuxfoundation.org > Cc: linux-in...@vger.kernel.org > > Signed-off-by: Juergen Gross > --- > arch/x86/hyperv/hv_init.c | 2 +- > arch/x86/include/asm/hypervisor.h | 23 ++- > arch/x86/kernel/cpu/hypervisor.c | 12 +--- > arch/x86/kernel/cpu/mshyperv.c| 4 ++-- > arch/x86/kernel/cpu/vmware.c | 4 ++-- > arch/x86/kernel/kvm.c | 4 ++-- > arch/x86/xen/enlighten_hvm.c | 4 ++-- > arch/x86/xen/enlighten_pv.c | 4 ++-- > drivers/hv/vmbus_drv.c| 2 +- > drivers/input/mouse/vmmouse.c | 10 -- > drivers/misc/vmw_balloon.c| 2 +- > 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) > 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 */ > 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 @@ > /* > * 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) { } > diff --git a/arch/x86/kernel/cpu/hypervisor.c > b/arch/x86/kernel/cpu/hypervisor.c > index 6c1bf092..bea8d3e24f50 100644 > --- a/arch/x86/kernel/cpu/hypervisor.c > +++ b/arch/x86/kernel/cpu/hypervisor.c > @@ -26,6 +26,12 @@ > #include > #include > > +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(); > } > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > index 6bb84d655e4b..85eb5fc180c8 100644 > --- a/arch/x86/kerne
[PATCH v2 2/5] x86: 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. Cc: k...@microsoft.com Cc: haiya...@microsoft.com Cc: sthem...@microsoft.com Cc: akata...@vmware.com Cc: pbonz...@redhat.com Cc: rkrc...@redhat.com Cc: boris.ostrov...@oracle.com Cc: de...@linuxdriverproject.org Cc: virtualization@lists.linux-foundation.org Cc: k...@vger.kernel.org Cc: xen-de...@lists.xenproject.org Cc: linux-graphics-maintai...@vmware.com Cc: pv-driv...@vmware.com Cc: dmitry.torok...@gmail.com Cc: xdeguill...@vmware.com Cc: moltm...@vmware.com Cc: a...@arndb.de Cc: gre...@linuxfoundation.org Cc: linux-in...@vger.kernel.org Signed-off-by: Juergen Gross --- arch/x86/hyperv/hv_init.c | 2 +- arch/x86/include/asm/hypervisor.h | 23 ++- arch/x86/kernel/cpu/hypervisor.c | 12 +--- arch/x86/kernel/cpu/mshyperv.c| 4 ++-- arch/x86/kernel/cpu/vmware.c | 4 ++-- arch/x86/kernel/kvm.c | 4 ++-- arch/x86/xen/enlighten_hvm.c | 4 ++-- arch/x86/xen/enlighten_pv.c | 4 ++-- drivers/hv/vmbus_drv.c| 2 +- drivers/input/mouse/vmmouse.c | 10 -- drivers/misc/vmw_balloon.c| 2 +- 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) 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 */ 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 @@ /* * 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) { } diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c index 6c1bf092..bea8d3e24f50 100644 --- a/arch/x86/kernel/cpu/hypervisor.c +++ b/arch/x86/kernel/cpu/hypervisor.c @@ -26,6 +26,12 @@ #include #include +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(); } 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) #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