RFC - Cleaned up hypervisor layer
H. Peter Anvin
reviewerThis patch implements a cleaned up hypervisor layer, plus cleans up some of the aspects of both Hank's MS-HyperV patch and the existing VMware driver. In particular, the MS-HyperV information is private information, per system, not per CPU, and can thus simply be stored in an ordinary global variable. This also turns the hypervisor detection into an information structure instead of just an identifier.
-hpa
arch/x86/include/asm/hyperv.h +3 -2
@@ -1,5 +1,5 @@ -#ifndef _ASM_X86_KVM_HYPERV_H -#define _ASM_X86_KVM_HYPERV_H +#ifndef _ASM_X86_HYPERV_H +#define _ASM_X86_HYPERV_H#include <linux/types.h>
@@ -16,6 +16,7 @@#define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000#define HYPERV_CPUID_MIN 0x40000005 +#define HYPERV_CPUID_MAX 0x4000ffff/* * Feature identification. EAX indicates which features are available
arch/x86/include/asm/hypervisor.h +25 -2
@@ -17,10 +17,33 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * */ -#ifndef ASM_X86__HYPERVISOR_H -#define ASM_X86__HYPERVISOR_H +#ifndef _ASM_X86_HYPERVISOR_H +#define _ASM_X86_HYPERVISOR_Hextern void init_hypervisor (struct cpuinfo_x86 *c);extern void init_hypervisor_platform (void ); +/* +* x86 hypervisor information +*/ +struct hypervisor_x86 { +/* Hypervisor name */ +const char *name; + +/* Detection routine */ +bool (*detect)(void ); + +/* Adjust CPU feature bits (run once per CPU) */ +void (*set_cpu_features)(struct cpuinfo_x86 *); + +/* Platform setup (run once per boot) */ +void (*init_platform)(void ); +}; + +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; +#endif
arch/x86/include/asm/mshyperv.h +11 -4
@@ -1,7 +1,14 @@ -#ifndef ASM_X86__MSHYPER_H -#define ASM_X86__MSHYPER_H +#ifndef _ASM_X86_MSHYPER_H +#define _ASM_X86_MSHYPER_H -int ms_hyperv_platform (void ); -void __cpuinit ms_hyperv_set_feature_bits (struct cpuinfo_x86 *c); +#include <linux/types.h> +#include <asm/hyperv.h> + +struct ms_hyperv_info { +u32 features; +u32 hints; +}; + +extern struct ms_hyperv_info ms_hyperv;#endif
arch/x86/include/asm/processor.h +0 -7
@@ -113,9 +113,6 @@ struct cpuinfo_x86 {/* Index into per_cpu list: */ u16 cpu_index;#endif -unsigned int x86_hyper_vendor; -/* The layout of this field is hypervisor specific */ -unsigned int x86_hyper_features; } __attribute__((__aligned__(SMP_CACHE_BYTES)));#define X86_VENDOR_INTEL 0
@@ -129,10 +126,6 @@ struct cpuinfo_x86 {#define X86_VENDOR_UNKNOWN 0xff -#define X86_HYPER_VENDOR_NONE 0 -#define X86_HYPER_VENDOR_VMWARE 1 -#define X86_HYPER_VENDOR_MSFT 2 -/* * capabilities of CPUs */
arch/x86/include/asm/vmware.h deleted +0 -27
@@ -1,27 +0,0 @@ -/* -* Copyright (C) 2008, VMware, Inc. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or -* NON INFRINGEMENT. See the GNU General Public License for more -* details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -* -*/ -#ifndef ASM_X86__VMWARE_H -#define ASM_X86__VMWARE_H - -extern void vmware_platform_setup (void ); -extern int vmware_platform (void ); -extern void vmware_set_feature_bits (struct cpuinfo_x86 *c); - -#endif
arch/x86/kernel/cpu/hypervisor.c +34 -22
74 lines not on this page · raw message
arch/x86/kernel/cpu/mshyperv.c +24 -27
69 lines not on this page · raw message
arch/x86/kernel/cpu/vmware.c +20 -16
@@ -23,8 +23,8 @@#include <linux/dmi.h> #include <asm/div64.h> -#include <asm/vmware.h> #include <asm/x86_init.h> +#include <asm/hypervisor.h> #define CPUID_VMWARE_INFO_LEAF 0x40000000#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
@@ -64,7 +64,7 @@ static unsigned long vmware_get_tsc_khz(void)return tsc_hz; } -void __init vmware_platform_setup (void ) +static void __init vmware_platform_setup (void ) {uint32_t eax, ebx, ecx, edx;
@@ -82,24 +82,21 @@ void __init vmware_platform_setup(void)* serial key should be enough, as this will always have a VMware * specific string when running under VMware hypervisor. */ -int vmware_platform (void ) +static bool __init vmware_platform (void ) {if (cpu_has_hypervisor) { -unsigned int eax, ebx, ecx, edx; -char hyper_vendor_id[13 ]; - -cpuid (CPUID_VMWARE_INFO_LEAF , &eax, &ebx, &ecx, &edx); -memcpy (hyper_vendor_id +0 , &ebx,4 ); -memcpy (hyper_vendor_id +4 , &ecx,4 ); -memcpy (hyper_vendor_id +8 , &edx,4 ); - hyper_vendor_id[12 ] ='\0' ; -if (!strcmp (hyper_vendor_id,"VMwareVMware" )) -return 1 ; +unsigned int eax; +unsigned int hyper_vendor_id[3 ]; + +cpuid (CPUID_VMWARE_INFO_LEAF , &eax, &hyper_vendor_id[0 ], + &hyper_vendor_id[1 ], &hyper_vendor_id[2 ]); +if (!memcmp (hyper_vendor_id,"VMwareVMware" ,12 )) +return true; }else if (dmi_available &&dmi_name_in_serial ("VMware" ) &&__vmware_platform ()) -return 1 ; +return true; -return 0 ; +return false; }/*
@@ -114,8 +111,15 @@ int vmware_platform(void)* so that the kernel could just trust the hypervisor with providing a * reliable virtual TSC that is suitable for timekeeping. */ -void __cpuinit vmware_set_feature_bits (struct cpuinfo_x86 *c) +static void __cpuinit vmware_set_cpu_features (struct cpuinfo_x86 *c) {set_cpu_cap (c,X86_FEATURE_CONSTANT_TSC );set_cpu_cap (c,X86_FEATURE_TSC_RELIABLE ); } + +const __refconst struct hypervisor_x86 x86_hyper_vmware = { + .name ="VMware" , + .detect = vmware_platform, + .set_cpu_features = vmware_set_cpu_features, + .init_platform = vmware_platform_setup, +};
Quoted 6 lines · H. Peter Anvin
This patch implements a cleaned up hypervisor layer, plus cleans up some of the aspects of both Hank's MS-HyperV patch and the existing VMware driver. In particular, the MS-HyperV information is private information, per system, not per CPU, and can thus simply be stored in an ordinary global variable. This also turns the hypervisor detection into an information structure instead of just an identifier.
This looks great to me, thanks for doing this work.
As this is a diff on top of my previous patch, do you want me to merge it in with it and resend it, or will you?
thanks,
greg k-h
H. Peter Anvin
reviewerQuoted 8 lines · Greg KH
Quoted 6 lines · H. Peter Anvin
This patch implements a cleaned up hypervisor layer, plus cleans up some of the aspects of both Hank's MS-HyperV patch and the existing VMware driver. In particular, the MS-HyperV information is private information, per system, not per CPU, and can thus simply be stored in an ordinary global variable. This also turns the hypervisor detection into an information structure instead of just an identifier.
Quoted 5 lines
This looks great to me, thanks for doing this work.
As this is a diff on top of my previous patch, do you want me to merge it in with it and resend it, or will you?
I was planning to put this on top of your patch as a second commit, just to preserve history and authorship.
-ha
Quoted 9 lines · H. Peter Anvin
Quoted 8 lines · Greg KH
Quoted 6 lines · H. Peter Anvin
This patch implements a cleaned up hypervisor layer, plus cleans up some of the aspects of both Hank's MS-HyperV patch and the existing VMware driver. In particular, the MS-HyperV information is private information, per system, not per CPU, and can thus simply be stored in an ordinary global variable. This also turns the hypervisor detection into an information structure instead of just an identifier.
Quoted 8 lines
Quoted 5 lines
This looks great to me, thanks for doing this work.
As this is a diff on top of my previous patch, do you want me to merge it in with it and resend it, or will you?
I was planning to put this on top of your patch as a second commit, just to preserve history and authorship.
Wonderful.
Ah, I just realized that we cut-and-pasted the GPL lines from the vmware file, I don't want the "v2 or later" marking on the new file KY added. Want me to send an add-on patch to fix that up?
thanks,
greg k-h
H. Peter Anvin
reviewerQuoted 16 lines · Greg KH
Quoted 15 lines · H. Peter Anvin
Quoted 13 lines · Greg KH
Quoted 6 lines · H. Peter Anvin
This patch implements a cleaned up hypervisor layer, plus cleans up some of the aspects of both Hank's MS-HyperV patch and the existing VMware driver. In particular, the MS-HyperV information is private information, per system, not per CPU, and can thus simply be stored in an ordinary global variable. This also turns the hypervisor detection into an information structure instead of just an identifier.
This looks great to me, thanks for doing this work.
As this is a diff on top of my previous patch, do you want me to merge it in with it and resend it, or will you?
Quoted 9 lines
Quoted 2 lines
I was planning to put this on top of your patch as a second commit, just to preserve history and authorship.
Wonderful.
Ah, I just realized that we cut-and-pasted the GPL lines from the vmware file, I don't want the "v2 or later" marking on the new file KY added. Want me to send an add-on patch to fix that up?
Yes please.
-hpa
PATCH 1/1 HyperV: fix up the license to mshyperv.c
From: Greg Kroah-Hartman <[email protected]>
This should have been GPLv2 only, we cut and pasted from the wrong file originally, sorry.
Also removed some unneeded boilerplate license code, we all know where to find the GPLv2, and that there's no warranty as that is implicit from the license.
--- arch/x86/kernel/cpu/mshyperv.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +1 -12
@@ -6,18 +6,7 @@* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or -* NON INFRINGEMENT. See the GNU General Public License for more -* details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* the Free Software Foundation; version 2 of the License. * */
[tip:x86/cpu] x86, HyperV: fix up the license to mshyperv.c
Commit-ID: 9fa02317429449e8176c9bb6da3ac00eb14d52d3 Gitweb: http://git.kernel.org/tip/9fa02317429449e8176c9bb6da3ac00eb14d52d3 Author: Greg Kroah-Hartman <[email protected]> AuthorDate: Fri, 7 May 2010 16:55:41 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Fri, 7 May 2010 17:00:25 -0700
x86, HyperV: fix up the license to mshyperv.c
This should have been GPLv2 only, we cut and pasted from the wrong file originally, sorry.
Also removed some unneeded boilerplate license code, we all know where to find the GPLv2, and that there's no warranty as that is implicit from the license.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/mshyperv.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +1 -12
@@ -6,18 +6,7 @@* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or -* NON INFRINGEMENT. See the GNU General Public License for more -* details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* the Free Software Foundation; version 2 of the License. * */
tip-bot for H. Peter Anvin
reviewer[tip:x86/cpu] x86: Clean up the hypervisor layer
In reply to H. Peter AnvinCommit-ID: e08cae4181af9483b04ecfac48f01c8e5a5f27bf Gitweb: http://git.kernel.org/tip/e08cae4181af9483b04ecfac48f01c8e5a5f27bf Author: H. Peter Anvin <[email protected]> AuthorDate: Fri, 7 May 2010 16:57:28 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Fri, 7 May 2010 17:13:04 -0700
x86: Clean up the hypervisor layer
Clean up the hypervisor layer and the hypervisor drivers, using an ops structure instead of an enumeration with if statements.
The identity of the hypervisor, if needed, can be tested by testing the pointer value in x86_hyper.
The MS-HyperV private state is moved into a normal global variable (it's per-system state, not per-CPU state). Being a normal bss variable, it will be left at all zero on non-HyperV platforms, and so can generally be tested for HyperV-specific features without additional qualification.
LKML-Reference: <[email protected]>
--- arch/x86/include/asm/hyperv.h | 5 ++- arch/x86/include/asm/hypervisor.h | 27 ++++++++++++++++- arch/x86/include/asm/mshyperv.h | 15 +++++++-- arch/x86/include/asm/processor.h | 7 ---- arch/x86/include/asm/vmware.h | 27 ------------------ arch/x86/kernel/cpu/hypervisor.c | 56 ++++++++++++++++++++++-------------- arch/x86/kernel/cpu/mshyperv.c | 51 ++++++++++++++++------------------ arch/x86/kernel/cpu/vmware.c | 36 +++++++++++++---------- 8 files changed, 117 insertions(+), 107 deletions(-)
arch/x86/include/asm/hyperv.h +3 -2
@@ -1,5 +1,5 @@ -#ifndef _ASM_X86_KVM_HYPERV_H -#define _ASM_X86_KVM_HYPERV_H +#ifndef _ASM_X86_HYPERV_H +#define _ASM_X86_HYPERV_H#include <linux/types.h>
@@ -16,6 +16,7 @@#define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000#define HYPERV_CPUID_MIN 0x40000005 +#define HYPERV_CPUID_MAX 0x4000ffff/* * Feature identification. EAX indicates which features are available
arch/x86/include/asm/hypervisor.h +25 -2
@@ -17,10 +17,33 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * */ -#ifndef ASM_X86__HYPERVISOR_H -#define ASM_X86__HYPERVISOR_H +#ifndef _ASM_X86_HYPERVISOR_H +#define _ASM_X86_HYPERVISOR_Hextern void init_hypervisor (struct cpuinfo_x86 *c);extern void init_hypervisor_platform (void ); +/* +* x86 hypervisor information +*/ +struct hypervisor_x86 { +/* Hypervisor name */ +const char *name; + +/* Detection routine */ +bool (*detect)(void ); + +/* Adjust CPU feature bits (run once per CPU) */ +void (*set_cpu_features)(struct cpuinfo_x86 *); + +/* Platform setup (run once per boot) */ +void (*init_platform)(void ); +}; + +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; +#endif
arch/x86/include/asm/mshyperv.h +11 -4
@@ -1,7 +1,14 @@ -#ifndef ASM_X86__MSHYPER_H -#define ASM_X86__MSHYPER_H +#ifndef _ASM_X86_MSHYPER_H +#define _ASM_X86_MSHYPER_H -int ms_hyperv_platform (void ); -void __cpuinit ms_hyperv_set_feature_bits (struct cpuinfo_x86 *c); +#include <linux/types.h> +#include <asm/hyperv.h> + +struct ms_hyperv_info { +u32 features; +u32 hints; +}; + +extern struct ms_hyperv_info ms_hyperv;#endif
arch/x86/include/asm/processor.h +0 -7
@@ -113,9 +113,6 @@ struct cpuinfo_x86 {/* Index into per_cpu list: */ u16 cpu_index;#endif -unsigned int x86_hyper_vendor; -/* The layout of this field is hypervisor specific */ -unsigned int x86_hyper_features; } __attribute__((__aligned__(SMP_CACHE_BYTES)));#define X86_VENDOR_INTEL 0
@@ -129,10 +126,6 @@ struct cpuinfo_x86 {#define X86_VENDOR_UNKNOWN 0xff -#define X86_HYPER_VENDOR_NONE 0 -#define X86_HYPER_VENDOR_VMWARE 1 -#define X86_HYPER_VENDOR_MSFT 2 -/* * capabilities of CPUs */
arch/x86/include/asm/vmware.h deleted +0 -27
@@ -1,27 +0,0 @@ -/* -* Copyright (C) 2008, VMware, Inc. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or -* NON INFRINGEMENT. See the GNU General Public License for more -* details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -* -*/ -#ifndef ASM_X86__VMWARE_H -#define ASM_X86__VMWARE_H - -extern void vmware_platform_setup (void ); -extern int vmware_platform (void ); -extern void vmware_set_feature_bits (struct cpuinfo_x86 *c); - -#endif
arch/x86/kernel/cpu/hypervisor.c +34 -22
74 lines not on this page · raw message
arch/x86/kernel/cpu/mshyperv.c +24 -27
69 lines not on this page · raw message
arch/x86/kernel/cpu/vmware.c +20 -16
@@ -23,8 +23,8 @@#include <linux/dmi.h> #include <asm/div64.h> -#include <asm/vmware.h> #include <asm/x86_init.h> +#include <asm/hypervisor.h> #define CPUID_VMWARE_INFO_LEAF 0x40000000#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
@@ -64,7 +64,7 @@ static unsigned long vmware_get_tsc_khz(void)return tsc_hz; } -void __init vmware_platform_setup (void ) +static void __init vmware_platform_setup (void ) {uint32_t eax, ebx, ecx, edx;
@@ -82,24 +82,21 @@ void __init vmware_platform_setup(void)* serial key should be enough, as this will always have a VMware * specific string when running under VMware hypervisor. */ -int vmware_platform (void ) +static bool __init vmware_platform (void ) {if (cpu_has_hypervisor) { -unsigned int eax, ebx, ecx, edx; -char hyper_vendor_id[13 ]; - -cpuid (CPUID_VMWARE_INFO_LEAF , &eax, &ebx, &ecx, &edx); -memcpy (hyper_vendor_id +0 , &ebx,4 ); -memcpy (hyper_vendor_id +4 , &ecx,4 ); -memcpy (hyper_vendor_id +8 , &edx,4 ); - hyper_vendor_id[12 ] ='\0' ; -if (!strcmp (hyper_vendor_id,"VMwareVMware" )) -return 1 ; +unsigned int eax; +unsigned int hyper_vendor_id[3 ]; + +cpuid (CPUID_VMWARE_INFO_LEAF , &eax, &hyper_vendor_id[0 ], + &hyper_vendor_id[1 ], &hyper_vendor_id[2 ]); +if (!memcmp (hyper_vendor_id,"VMwareVMware" ,12 )) +return true; }else if (dmi_available &&dmi_name_in_serial ("VMware" ) &&__vmware_platform ()) -return 1 ; +return true; -return 0 ; +return false; }/*
@@ -114,8 +111,15 @@ int vmware_platform(void)* so that the kernel could just trust the hypervisor with providing a * reliable virtual TSC that is suitable for timekeeping. */ -void __cpuinit vmware_set_feature_bits (struct cpuinfo_x86 *c) +static void __cpuinit vmware_set_cpu_features (struct cpuinfo_x86 *c) {set_cpu_cap (c,X86_FEATURE_CONSTANT_TSC );set_cpu_cap (c,X86_FEATURE_TSC_RELIABLE ); } + +const __refconst struct hypervisor_x86 x86_hyper_vmware = { + .name ="VMware" , + .detect = vmware_platform, + .set_cpu_features = vmware_set_cpu_features, + .init_platform = vmware_platform_setup, +};
arch/x86/kernel/cpu/vmware.c void __init vmware_platform_setup(void) · line 87
Quoted 8 lines · H. Peter Anvin
arch/x86/kernel/cpu/vmware.c +1
-1@@ -82,24 +82,21 @@ void __init vmware_platform_setup(void)* serial key should be enough, as this will always have a VMware * specific string when running under VMware hypervisor. */ -int vmware_platform (void ) +static bool __init vmware_platform (void )
This will break our balloon driver which uses vmware_platform() to detect whether it should run or not.
Thanks.
Signature · 1 line
Dmitry
Re: [tip:x86/cpu] x86: Clean up the hypervisor layer
In reply to tip-bot for H. Peter AnvinQuoted 27 lines · tip-bot for H. Peter Anvin
Commit-ID: e08cae4181af9483b04ecfac48f01c8e5a5f27bf Gitweb: http://git.kernel.org/tip/e08cae4181af9483b04ecfac48f01c8e5a5f27bf Author: H. Peter Anvin <[email protected]> AuthorDate: Fri, 7 May 2010 16:57:28 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Fri, 7 May 2010 17:13:04 -0700x86: Clean up the hypervisor layer
Clean up the hypervisor layer and the hypervisor drivers, using an ops structure instead of an enumeration with if statements.
The identity of the hypervisor, if needed, can be tested by testing the pointer value in
x86_hyper.The MS-HyperV private state is moved into a normal global variable (it's per-system state, not per-CPU state). Being a normal bss variable, it will be left at all zero on non-HyperV platforms, and so can generally be tested for HyperV-specific features without additional qualification.
Signed-off-by H. Peter Anvin <[email protected]>Acked-by Greg KH <[email protected]>Cc Hank Janssen <[email protected]>Cc Alok Kataria <[email protected]>Cc Ky Srinivasan <[email protected]>LKML-Reference: <[email protected]>
Quoted 10 lines
--- arch/x86/include/asm/hyperv.h | 5 ++- arch/x86/include/asm/hypervisor.h | 27 ++++++++++++++++- arch/x86/include/asm/mshyperv.h | 15 +++++++-- arch/x86/include/asm/processor.h | 7 ---- arch/x86/include/asm/vmware.h | 27 ------------------ arch/x86/kernel/cpu/hypervisor.c | 56 ++++++++++++++++++++++-------------- arch/x86/kernel/cpu/mshyperv.c | 51 ++++++++++++++++------------------ arch/x86/kernel/cpu/vmware.c | 36 +++++++++++++---------- 8 files changed, 117 insertions(+), 107 deletions(-)
Note, this patch breaks the build of the new vmware baloon driver:
drivers/misc/vmware_balloon.c:44:24: error: asm/vmware.h: No such file or directory
CONFIG_VMWARE_BALLOON=y
Thanks,
Ingo
tip-bot for H. Peter Anvin
reviewer[tip:x86/cpu] x86, hypervisor: Export the x86_hyper* symbols
In reply to H. Peter AnvinCommit-ID: 96f6e775b58687d85ee33004d414419b5ec34106 Gitweb: http://git.kernel.org/tip/96f6e775b58687d85ee33004d414419b5ec34106 Author: H. Peter Anvin <[email protected]> AuthorDate: Sun, 9 May 2010 01:10:34 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Sun, 9 May 2010 01:10:34 -0700
x86, hypervisor: Export the x86_hyper* symbols
Export x86_hyper and the related specific structures, allowing for hypervisor identification by modules.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/hypervisor.c | 1 + arch/x86/kernel/cpu/mshyperv.c | 1 + arch/x86/kernel/cpu/vmware.c | 2 +- 3 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/hypervisor.c +1 -0
@@ -36,6 +36,7 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] = };const struct hypervisor_x86 *x86_hyper; +EXPORT_SYMBOL (x86_hyper);static inline void __init detect_hypervisor_vendor (void )
arch/x86/kernel/cpu/mshyperv.c +1 -0
@@ -51,3 +51,4 @@ const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = { .detect = ms_hyperv_platform, .init_platform = ms_hyperv_init_platform, }; +EXPORT_SYMBOL (x86_hyper_ms_hyperv);
arch/x86/kernel/cpu/vmware.c +1 -1
@@ -99,7 +99,6 @@ static bool __init vmware_platform(void)return false; } -EXPORT_SYMBOL (vmware_platform);/* * VMware hypervisor takes care of exporting a reliable TSC to the guest.
@@ -125,3 +124,4 @@ const __refconst struct hypervisor_x86 x86_hyper_vmware = { .set_cpu_features = vmware_set_cpu_features, .init_platform = vmware_platform_setup, }; +EXPORT_SYMBOL (x86_hyper_vmware);
tip-bot for H. Peter Anvin
reviewer[tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
In reply to H. Peter AnvinCommit-ID: a10a569806e43b9be5fce60b21f836b50b1010e4 Gitweb: http://git.kernel.org/tip/a10a569806e43b9be5fce60b21f836b50b1010e4 Author: H. Peter Anvin <[email protected]> AuthorDate: Sun, 9 May 2010 01:13:42 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Sun, 9 May 2010 01:13:42 -0700
Modify the VMware balloon driver for the new x86_hyper API
Modify the VMware balloon driver to match the new x86_hyper API.
LKML-Reference: <[email protected]>
--- drivers/misc/vmware_balloon.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/vmware_balloon.c +2 -2
@@ -41,7 +41,7 @@#include <linux/workqueue.h> #include <linux/debugfs.h> #include <linux/seq_file.h> -#include <asm/vmware.h> +#include <asm/hypervisor.h> MODULE_AUTHOR ("VMware, Inc." );MODULE_DESCRIPTION ("VMware Memory Control (Balloon) Driver" );
@@ -767,7 +767,7 @@ static int __init vmballoon_init(void)* Check if we are running on VMware's hypervisor and bail out * if we are not. */ -if (!vmware_platform ()) +if (x86_hyper != &x86_hyper_vmware)return -ENODEV ; vmballoon_wq =create_freezeable_workqueue ("vmmemctl" );
H. Peter Anvin
reviewerRe: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
drivers/misc/vmware_balloon.c static int __init vmballoon_init(void) · line 773
Quoted 12 lines · tip-bot for H. Peter Anvin
MODULE_AUTHOR("VMware, Inc.");MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");drivers/misc/vmware_balloon.c +1
-1@@ -767,7 +767,7 @@ static int __init vmballoon_init(void)* Check if we are running on VMware's hypervisor and bail out * if we are not. */ -if (!vmware_platform ()) +if (x86_hyper != &x86_hyper_vmware)return -ENODEV ; vmballoon_wq =create_freezeable_workqueue ("vmmemctl" );
Note: I did not change the existing code, but this is an example of a very common bug: the appropriate error code for "hardware is not present" is ENXIO, not ENODEV.
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Re: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
In reply to tip-bot for H. Peter AnvinQuoted 10 lines · tip-bot for H. Peter Anvin
Commit-ID: a10a569806e43b9be5fce60b21f836b50b1010e4 Gitweb: http://git.kernel.org/tip/a10a569806e43b9be5fce60b21f836b50b1010e4 Author: H. Peter Anvin <[email protected]> AuthorDate: Sun, 9 May 2010 01:13:42 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Sun, 9 May 2010 01:13:42 -0700Modify the VMware balloon driver for the new
x86_hyperAPIModify the VMware balloon driver to match the new
x86_hyperAPI.
FYI, this is still not enough - now the allmodconfig build fails with:
ERROR: "x86_hyper" [drivers/misc/vmware_balloon.ko] undefined!
Ingo
tip-bot for H. Peter Anvin
reviewer[tip:x86/cpu] x86, hypervisor: add missing <linux/module.h>
In reply to H. Peter AnvinCommit-ID: 3998d095354d2a3062bdaa821ef07a1e1c82873c Gitweb: http://git.kernel.org/tip/3998d095354d2a3062bdaa821ef07a1e1c82873c Author: H. Peter Anvin <[email protected]> AuthorDate: Sun, 9 May 2010 22:46:54 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Sun, 9 May 2010 22:46:54 -0700
x86, hypervisor: add missing <linux/module.h>
EXPORT_SYMBOL() needs <linux/module.h> to be included; fixes modular builds of the VMware balloon driver, and any future modular drivers which depends on the hypervisor.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/hypervisor.c | 1 + arch/x86/kernel/cpu/mshyperv.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/hypervisor.c +1 -0
@@ -21,6 +21,7 @@* */ +#include <linux/module.h> #include <asm/processor.h> #include <asm/hypervisor.h>
arch/x86/kernel/cpu/mshyperv.c +1 -0
@@ -11,6 +11,7 @@*/ #include <linux/types.h> +#include <linux/module.h> #include <asm/processor.h> #include <asm/hypervisor.h> #include <asm/hyperv.h>
Re: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
In reply to H. Peter AnvinQuoted 13 lines · H. Peter Anvin
Quoted 12 lines · tip-bot for H. Peter Anvin
MODULE_AUTHOR("VMware, Inc.");MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");drivers/misc/vmware_balloon.c +1
-1@@ -767,7 +767,7 @@ static int __init vmballoon_init(void)* Check if we are running on VMware's hypervisor and bail out * if we are not. */ -if (!vmware_platform ()) +if (x86_hyper != &x86_hyper_vmware)
Quoted 8 lines
drivers/misc/vmware_balloon.c static int __init vmballoon_init(void) · line 773
Quoted 3 lines
drivers/misc/vmware_balloon.c +0
-0return -ENODEV ; vmballoon_wq =create_freezeable_workqueue ("vmmemctl" );Note: I did not change the existing code, but this is an example of a very common bug: the appropriate error code for "hardware is not present" is ENXIO, not ENODEV.
Source please? I was not aware that there was a standard governing returns code for module init methods.
Signature · 1 line
Dmitry
H. Peter Anvin
reviewerRe: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
Quoted 4 lines · Dmitry Torokhov
Source please? I was not aware that there was a standard governing returns code for module init methods.
ENODEV means "not a device node."
ENXIO means "hardware not present."
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Re: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
Quoted 7 lines · H. Peter Anvin
Quoted 2 lines · Dmitry Torokhov
Source please? I was not aware that there was a standard governing returns code for module init methods.
ENODEV means "not a device node."
ENXIO means "hardware not present."
There is no device node in question. Again, could you please point me to the list of allowed error codes for init methods? According to SUS, we need to follow ERROR section of the appropriate function, and I do not believe that spec covers cases if driver binding and module loading.
FWIW -ENODEV is explicitly allowed in our device core and means "device not found", especially in context of platform devices. I do not see the need of changing that.
Thanks.
Signature · 1 line
Dmitry
H. Peter Anvin
reviewerRe: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
Quoted 9 lines · Dmitry Torokhov
Quoted 7 lines · H. Peter Anvin
Quoted 2 lines · Dmitry Torokhov
Source please? I was not aware that there was a standard governing returns code for module init methods.
ENODEV means "not a device node."
ENXIO means "hardware not present."
Quoted 9 lines
There is no device node in question. Again, could you please point me to the list of allowed error codes for init methods? According to SUS, we need to follow ERROR section of the appropriate function, and I do not believe that spec covers cases if driver binding and module loading.
FWIW
-ENODEVis explicitly allowed in our device core and means "device not found", especially in context of platform devices. I do not see the need of changing that.
The problem with this abuse of ENODEV is that people start using it elsewhere, where it *DOES* matter than ENXIO is the proper return code.
Yes, we handle incorrect uses of ENODEV, but the right thing to do is
to teach people to use ENXIO properly.
-hpa
Re: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
Quoted 14 lines · H. Peter Anvin
Quoted 13 lines · Dmitry Torokhov
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines · Dmitry Torokhov
Source please? I was not aware that there was a standard governing returns code for module init methods.
ENODEV means "not a device node."
ENXIO means "hardware not present."There is no device node in question. Again, could you please point me to the list of allowed error codes for init methods? According to SUS, we need to follow ERROR section of the appropriate function, and I do not believe that spec covers cases if driver binding and module loading.
Quoted 8 lines
Quoted 3 lines
FWIW
-ENODEVis explicitly allowed in our device core and means "device not found", especially in context of platform devices. I do not see the need of changing that.The problem with this abuse of ENODEV is that people start using it elsewhere, where it *DOES* matter than ENXIO is the proper return code.
Yes, we handle incorrect uses of ENODEV, but the right thing to do is
to teach people to use ENXIO properly.
The usage that you mention only valid in the context of working with device nodes. In other cases it can be used to indicate different errors altogether:
mmap:
[ENODEV]
The fildes argument refers to a file whose type is not supported by mmap().
fallocate:
[ENODEV]
The fd argument does not refer to a regular file.
Linux mount:
ENODEV filesystemtype not configured in the kernel.
ENXIO The major number of the block device source is out of range.
Solaris ldi:
ENODEV
Requested device does not exist.
ENXIO
Unsupported device operation or access mode.
and so on...
Signature · 1 line
Dmitry
H. Peter Anvin
reviewerRe: [tip:x86/cpu] Modify the VMware balloon driver for the new x86_hyper API
Quoted 13 lines · Dmitry Torokhov
The usage that you mention only valid in the context of working with device nodes. In other cases it can be used to indicate different errors altogether:
mmap:
[ENODEV]
The fildes argument refers to a file whose type is not supported bymmap().fallocate:
Quoted 9 lines
[ENODEV]
The fd argument does not refer to a regular file.Linux mount:
ENODEV filesystemtype not configured in the kernel.
ENXIO The major number of the block device source is out of range.
"The major number of the block device source is out of range" is really nothing but confusion on the part of the man page author. It's exactly this kind of confusion which I try to clamp down on, because we have *so* many instances of it in the existing codebase. It seems, in fact, to be one of the most common mistakes
ENXIO really means exactly the same thing as it does elsewhere: no hardware for the specified device. For example, create /dev/hda on a system with no IDE:
mount("/dev/hda", "/mnt", "ext2", MS_MGC_VAL, NULL) = -1 ENXIO (No such device or address)
[no "out of range" anything there...]
The kernel does indeed return ENODEV for a nonexistent filesystem name, which can only best be described as "severely confusing", but probably have to be considered grandfathered in by now. (mount returns ENOTBLK for a non-devicenode, which is somewhat accurate -- a non-device is not a block device, after all...)
-hpa
Re: [PATCH] Hyperv: Export the symbol that tracks hyperv features and recommendations
In reply to Ky SrinivasanQuoted 12 lines · Ky Srinivasan
From: K. Y. Srinivasan <[email protected]>
Subject: Export the symbol for hyperv drivers to access hyperv features and recommendations.Signed-off-by K. Y. Srinivasan <[email protected]>Index:
linux.trees.git/arch/x86/kernel/cpu/mshyperv.c
===================================================================
arch/x86/kernel/cpu/mshyperv.c line 21
Quoted 4 lines
arch/x86/kernel/cpu/mshyperv.c +1
-0@@ -18,6 +18,7 @@#include <asm/mshyperv.h> struct ms_hyperv_info ms_hyperv; +EXPORT_SYMBOL (ms_hyperv);
EXPORT_SYMBOL_GPL() perhaps?
thanks,
greg k-h
PATCH 1/1 Hyperv: Export the symbol that tracks hyperv features and recommendations
In reply to tip-bot for H. Peter AnvinFrom: K. Y. Srinivasan <[email protected]>
Subject: Export the symbol for hyperv drivers to access hyperv features and recommendations.
arch/x86/kernel/cpu/mshyperv.c +1 -0
@@ -18,6 +18,7 @@#include <asm/mshyperv.h> struct ms_hyperv_info ms_hyperv; +EXPORT_SYMBOL (ms_hyperv);static bool __init ms_hyperv_platform (void ) {