Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-27 Thread Borislav Petkov
On Sat, Jan 26, 2013 at 05:26:40PM -0800, H. Peter Anvin wrote:
> Out-of-tree code is responsible for keeping up, not the other way around.

Ok, this actually a "doh, Boris, of course". If code wants to work with
linux, it should be upstream in the first place. Otherwise, it has to
keep up. Cool.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-27 Thread Borislav Petkov
On Sat, Jan 26, 2013 at 05:26:40PM -0800, H. Peter Anvin wrote:
 Out-of-tree code is responsible for keeping up, not the other way around.

Ok, this actually a doh, Boris, of course. If code wants to work with
linux, it should be upstream in the first place. Otherwise, it has to
keep up. Cool.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-26 Thread H. Peter Anvin

On 01/25/2013 10:43 AM, Borislav Petkov wrote:

On Fri, Jan 25, 2013 at 07:35:07PM +0100, Borislav Petkov wrote:

Ok, if you prefer. We can definitely make all .o's which depend on
x86_hyper also depend on CONFIG_HYPERVISOR_GUEST - this solves the
whole deal trivially.

I'll respin the patches.


... provided, of course, nothing out-of-tree is using x86_hyper. Can we
assume that?



Out-of-tree code is responsible for keeping up, not the other way around.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-26 Thread H. Peter Anvin

On 01/25/2013 10:43 AM, Borislav Petkov wrote:

On Fri, Jan 25, 2013 at 07:35:07PM +0100, Borislav Petkov wrote:

Ok, if you prefer. We can definitely make all .o's which depend on
x86_hyper also depend on CONFIG_HYPERVISOR_GUEST - this solves the
whole deal trivially.

I'll respin the patches.


... provided, of course, nothing out-of-tree is using x86_hyper. Can we
assume that?



Out-of-tree code is responsible for keeping up, not the other way around.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:42:32AM -0800, Dmitry Torokhov wrote:
> No, not really as EXPORT_SYMBOL_GPL() in no way implies that the code
> using it lives in the mainline.

I didn't say that - I said "any code (proprietary included) can link to
those symbols" meaning that I cannot possibly convert proprietary code
to which I don't have access to, vs GPL code which is out there.

> Also, EXPORT_SYMBOL() does not imply that it forms an ABI and can't be
> changed ever.

And yet, I don't want to be on the receiving end of the complaints when
those do change. But that's beside the point.

So I think we're on the same page: I'll make everything using x86_hyper*
depend on CONFIG_HYPERVISOR_GUEST and all are happy.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
On Fri, Jan 25, 2013 at 07:32:13PM +0100, Borislav Petkov wrote:
> On Fri, Jan 25, 2013 at 10:12:51AM -0800, Dmitry Torokhov wrote:
> > Hi Borislav,
> > 
> > On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
> > > From: Borislav Petkov 
> > > 
> > > Put all config options needed to run Linux as a guest behind a
> > > CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
> > > default but selected by the user. Also, move x86_hyper into an
> > > unconditionally-built compilation unit because it is exported with the
> > > non-GPL flavour and we can't know whatever uses it on the outside.
> > 
> > I am confused by this statement... How can EXPORT_SYMBOL() vs
> > EXPORT_SYMBOL_GPL() help you determining if it is used out of tree or
> > not?
> 
> Maybe this wasn't formulated clear enough - I wanted to say that with
> the !GPL flavor, any code (proprietary included) can link to those
> symbols and we cannot know who uses it and if we hide that symbol,
> someone would probably come crying.
> 
> Because if we could, I would've done trivial accessor functions which
> would return NULL when CONFIG_HYPERVISOR_GUEST is not set so that those
> cases build and boot fine, and we wouldn't have the need to have this
> symbol always present (like is the case now and I had to move it to
> setup.c).
> 
> If it were _GPL, we would've fixed all its users to switch to the
> accessors.
> 
> Makes more sense?

No, not really as EXPORT_SYMBOL_GPL() in no way implies that the code
using it lives in the mainline. Also, EXPORT_SYMBOL() does not imply
that it forms an ABI and can't be changed ever.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 07:35:07PM +0100, Borislav Petkov wrote:
> Ok, if you prefer. We can definitely make all .o's which depend on
> x86_hyper also depend on CONFIG_HYPERVISOR_GUEST - this solves the
> whole deal trivially.
>
> I'll respin the patches.

... provided, of course, nothing out-of-tree is using x86_hyper. Can we
assume that?

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:29:25AM -0800, Dmitry Torokhov wrote:
> Can't we make the balloon driver depend on CONFIG_HYPERVISOR_GUEST?

We certainly can do that, AFAICT.

> We do not _need_ more and have no plans to introduce new ones AFAIK,
> but I think that comparing an address of a structure instead of string
> comparison is much more elegant and it is safer from typos.

Ok, if you prefer. We can definitely make all .o's which depend on
x86_hyper also depend on CONFIG_HYPERVISOR_GUEST - this solves the whole
deal trivially.

I'll respin the patches.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
On Fri, Jan 25, 2013 at 07:23:35PM +0100, Borislav Petkov wrote:
> On Fri, Jan 25, 2013 at 10:07:31AM -0800, Dmitry Torokhov wrote:
> > > - if (x86_hyper != _hyper_ms_hyperv)
> > > + if (!x86_hyper || strncmp(x86_hyper->name, "VMware", 6))
> > >   return -ENODEV;
> > 
> > I assume this is a typo as I doubt MS is using the same signature as we
> > do.
> 
> Yeah, Vmware is assimilating Microsoft. :-)
> 
> Damn copy-paste crap. Sorry, will fix.
> 
> > > diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> > > index cb56e270da11..85f15a6d8798 100644
> > > --- a/drivers/misc/vmw_balloon.c
> > > +++ b/drivers/misc/vmw_balloon.c
> > > @@ -786,7 +786,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 != _hyper_vmware)
> > > + if (!x86_hyper || strncmp(x86_hyper->name, "VMware", 6))
> > >   return -ENODEV;
> > >
> > 
> > I wonder why you decided to switch from address matching (which is quite
> > precise and would potentially allow adding signatures without needing
> > to change the drivers) to string matching?
> 
> Ok, this is a bit more involved. If we put all hypervisor stuff behind
> CONFIG_HYPERVISOR_GUEST and in the cases where this is disabled,
> the build fails because the x86_hyper_vmware symbol is undefined.
> Alternatively, this doesn't happen when we look at the name.

Can't we make the balloon driver depend on CONFIG_HYPERVISOR_GUEST?

> 
> But why would you want to add signatures? Isn't "VMware" enough as a
> name for the vmware hypervisor and why would you need more? And besides,
> hypervisor_x86.name is only a single const char * so you'd need to
> change that struct to add more names...Hm.

We do not _need_ more and have no plans to introduce new ones AFAIK, but
I think that comparing an address of a structure instead of string
comparison is much more elegant and it is safer from typos.

Thanks,
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:12:51AM -0800, Dmitry Torokhov wrote:
> Hi Borislav,
> 
> On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
> > From: Borislav Petkov 
> > 
> > Put all config options needed to run Linux as a guest behind a
> > CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
> > default but selected by the user. Also, move x86_hyper into an
> > unconditionally-built compilation unit because it is exported with the
> > non-GPL flavour and we can't know whatever uses it on the outside.
> 
> I am confused by this statement... How can EXPORT_SYMBOL() vs
> EXPORT_SYMBOL_GPL() help you determining if it is used out of tree or
> not?

Maybe this wasn't formulated clear enough - I wanted to say that with
the !GPL flavor, any code (proprietary included) can link to those
symbols and we cannot know who uses it and if we hide that symbol,
someone would probably come crying.

Because if we could, I would've done trivial accessor functions which
would return NULL when CONFIG_HYPERVISOR_GUEST is not set so that those
cases build and boot fine, and we wouldn't have the need to have this
symbol always present (like is the case now and I had to move it to
setup.c).

If it were _GPL, we would've fixed all its users to switch to the
accessors.

Makes more sense?

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:07:31AM -0800, Dmitry Torokhov wrote:
> > -   if (x86_hyper != _hyper_ms_hyperv)
> > +   if (!x86_hyper || strncmp(x86_hyper->name, "VMware", 6))
> > return -ENODEV;
> 
> I assume this is a typo as I doubt MS is using the same signature as we
> do.

Yeah, Vmware is assimilating Microsoft. :-)

Damn copy-paste crap. Sorry, will fix.

> > diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> > index cb56e270da11..85f15a6d8798 100644
> > --- a/drivers/misc/vmw_balloon.c
> > +++ b/drivers/misc/vmw_balloon.c
> > @@ -786,7 +786,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 != _hyper_vmware)
> > +   if (!x86_hyper || strncmp(x86_hyper->name, "VMware", 6))
> > return -ENODEV;
> >
> 
> I wonder why you decided to switch from address matching (which is quite
> precise and would potentially allow adding signatures without needing
> to change the drivers) to string matching?

Ok, this is a bit more involved. If we put all hypervisor stuff behind
CONFIG_HYPERVISOR_GUEST and in the cases where this is disabled,
the build fails because the x86_hyper_vmware symbol is undefined.
Alternatively, this doesn't happen when we look at the name.

But why would you want to add signatures? Isn't "VMware" enough as a
name for the vmware hypervisor and why would you need more? And besides,
hypervisor_x86.name is only a single const char * so you'd need to
change that struct to add more names...Hm.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
Hi Borislav,

On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
> From: Borislav Petkov 
> 
> Put all config options needed to run Linux as a guest behind a
> CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
> default but selected by the user. Also, move x86_hyper into an
> unconditionally-built compilation unit because it is exported with the
> non-GPL flavour and we can't know whatever uses it on the outside.

I am confused by this statement... How can EXPORT_SYMBOL() vs
EXPORT_SYMBOL_GPL() help you determining if it is used out of tree or
not?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
Hi Borislav,

On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 8e1a9ec53003..cb467656e684 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -724,7 +724,7 @@ static int __init hv_acpi_init(void)
>  {
>   int ret, t;
>  
> - if (x86_hyper != _hyper_ms_hyperv)
> + if (!x86_hyper || strncmp(x86_hyper->name, "VMware", 6))
>   return -ENODEV;

I assume this is a typo as I doubt MS is using the same signature as we
do.

>  
>   init_completion(_event);
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index cb56e270da11..85f15a6d8798 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -786,7 +786,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 != _hyper_vmware)
> + if (!x86_hyper || strncmp(x86_hyper->name, "VMware", 6))
>   return -ENODEV;
>

I wonder why you decided to switch from address matching (which is quite
precise and would potentially allow adding signatures without needing
to change the drivers) to string matching?

Thanks,
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
From: Borislav Petkov 

Put all config options needed to run Linux as a guest behind a
CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
default but selected by the user. Also, move x86_hyper into an
unconditionally-built compilation unit because it is exported with the
non-GPL flavour and we can't know whatever uses it on the outside.

Then, make sure x86 hypervisor platform descriptor is present and do a
proper check whether we're running on a vmware hypervisor by looking at
its name before continuing with the initialization further.

While at it, adjust text to changes, remove redundant select.

Signed-off-by: Borislav Petkov 
Cc: Dmitry Torokhov 
Cc: K. Y. Srinivasan 
Cc: Haiyang Zhang 
Cc: de...@linuxdriverproject.org
---
 arch/x86/Kconfig  | 21 +++--
 arch/x86/include/asm/hypervisor.h | 12 
 arch/x86/kernel/cpu/Makefile  |  3 ++-
 arch/x86/kernel/cpu/hypervisor.c  |  3 ---
 arch/x86/kernel/setup.c   |  4 +++-
 drivers/hv/vmbus_drv.c|  2 +-
 drivers/misc/vmw_balloon.c|  2 +-
 7 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 201b8aa93f8f..2380a52f0c8c 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -379,7 +379,7 @@ config X86_NUMACHIP
 
 config X86_VSMP
bool "ScaleMP vSMP"
-   select PARAVIRT_GUEST
+   select HYPERVISOR_GUEST
select PARAVIRT
depends on X86_64 && PCI
depends on X86_EXTENDED_PLATFORM
@@ -568,15 +568,17 @@ config SCHED_OMIT_FRAME_POINTER
 
  If in doubt, say "Y".
 
-menuconfig PARAVIRT_GUEST
-   bool "Paravirtualized guest support"
+menuconfig HYPERVISOR_GUEST
+   bool "Linux guest support"
---help---
- Say Y here to get to see options related to running Linux under
- various hypervisors.  This option alone does not add any kernel code.
+ Say Y here to enable options for running Linux under various hyper-
+ visors. This option enables basic hypervisor detection and platform
+ setup.
 
- If you say N, all options in this submenu will be skipped and 
disabled.
+ If you say N, all options in this submenu will be skipped and
+ disabled, and Linux guest support won't be built in.
 
-if PARAVIRT_GUEST
+if HYPERVISOR_GUEST
 
 config PARAVIRT_TIME_ACCOUNTING
bool "Paravirtual steal time accounting"
@@ -595,9 +597,8 @@ source "arch/x86/xen/Kconfig"
 config KVM_GUEST
bool "KVM Guest support (including kvmclock)"
select PARAVIRT
-   select PARAVIRT
select PARAVIRT_CLOCK
-   default y if PARAVIRT_GUEST
+   default y
---help---
  This option enables various optimizations for running under the KVM
  hypervisor. It includes a paravirtualized clock, so that instead
@@ -638,7 +639,7 @@ config PARAVIRT_DEBUG
  Enable to debug paravirt_ops internals.  Specifically, BUG if
  a paravirt_op is missing when it is called.
 
-endif #PARAVIRT_GUEST
+endif #HYPERVISOR_GUEST
 
 config NO_BOOTMEM
def_bool y
diff --git a/arch/x86/include/asm/hypervisor.h 
b/arch/x86/include/asm/hypervisor.h
index b518c7509933..cd06ed8733cb 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -23,9 +23,6 @@
 #include 
 #include 
 
-extern void init_hypervisor(struct cpuinfo_x86 *c);
-extern void init_hypervisor_platform(void);
-
 /*
  * x86 hypervisor information
  */
@@ -60,4 +57,11 @@ static inline bool hypervisor_x2apic_available(void)
return false;
 }
 
-#endif
+#ifdef CONFIG_PARAVIRT
+extern void init_hypervisor(struct cpuinfo_x86 *c);
+extern void init_hypervisor_platform(void);
+#else
+static inline void init_hypervisor(struct cpuinfo_x86 *c) { }
+static inline void init_hypervisor_platform(void) { }
+#endif /* CONFIG_PARAVIRT */
+#endif /* _ASM_X86_HYPERVISOR_H */
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index a0e067d3d96c..8d04c7cd7cd3 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -14,7 +14,6 @@ CFLAGS_common.o   := $(nostackp)
 
 obj-y  := intel_cacheinfo.o scattered.o topology.o
 obj-y  += proc.o capflags.o powerflags.o common.o
-obj-y  += vmware.o hypervisor.o mshyperv.o
 obj-y  += rdrand.o
 obj-y  += match.o
 
@@ -42,6 +41,8 @@ obj-$(CONFIG_MTRR)+= mtrr/
 
 obj-$(CONFIG_X86_LOCAL_APIC)   += perfctr-watchdog.o 
perf_event_amd_ibs.o
 
+obj-$(CONFIG_PARAVIRT) += vmware.o hypervisor.o mshyperv.o
+
 quiet_cmd_mkcapflags = MKCAP   $@
   cmd_mkcapflags = $(PERL) $(srctree)/$(src)/mkcapflags.pl $< $@
 
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index a8f8fa9769d6..fd6e77f6765e 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -42,9 +42,6 @@ 

[PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
From: Borislav Petkov b...@suse.de

Put all config options needed to run Linux as a guest behind a
CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
default but selected by the user. Also, move x86_hyper into an
unconditionally-built compilation unit because it is exported with the
non-GPL flavour and we can't know whatever uses it on the outside.

Then, make sure x86 hypervisor platform descriptor is present and do a
proper check whether we're running on a vmware hypervisor by looking at
its name before continuing with the initialization further.

While at it, adjust text to changes, remove redundant select.

Signed-off-by: Borislav Petkov b...@suse.de
Cc: Dmitry Torokhov d...@vmware.com
Cc: K. Y. Srinivasan k...@microsoft.com
Cc: Haiyang Zhang haiya...@microsoft.com
Cc: de...@linuxdriverproject.org
---
 arch/x86/Kconfig  | 21 +++--
 arch/x86/include/asm/hypervisor.h | 12 
 arch/x86/kernel/cpu/Makefile  |  3 ++-
 arch/x86/kernel/cpu/hypervisor.c  |  3 ---
 arch/x86/kernel/setup.c   |  4 +++-
 drivers/hv/vmbus_drv.c|  2 +-
 drivers/misc/vmw_balloon.c|  2 +-
 7 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 201b8aa93f8f..2380a52f0c8c 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -379,7 +379,7 @@ config X86_NUMACHIP
 
 config X86_VSMP
bool ScaleMP vSMP
-   select PARAVIRT_GUEST
+   select HYPERVISOR_GUEST
select PARAVIRT
depends on X86_64  PCI
depends on X86_EXTENDED_PLATFORM
@@ -568,15 +568,17 @@ config SCHED_OMIT_FRAME_POINTER
 
  If in doubt, say Y.
 
-menuconfig PARAVIRT_GUEST
-   bool Paravirtualized guest support
+menuconfig HYPERVISOR_GUEST
+   bool Linux guest support
---help---
- Say Y here to get to see options related to running Linux under
- various hypervisors.  This option alone does not add any kernel code.
+ Say Y here to enable options for running Linux under various hyper-
+ visors. This option enables basic hypervisor detection and platform
+ setup.
 
- If you say N, all options in this submenu will be skipped and 
disabled.
+ If you say N, all options in this submenu will be skipped and
+ disabled, and Linux guest support won't be built in.
 
-if PARAVIRT_GUEST
+if HYPERVISOR_GUEST
 
 config PARAVIRT_TIME_ACCOUNTING
bool Paravirtual steal time accounting
@@ -595,9 +597,8 @@ source arch/x86/xen/Kconfig
 config KVM_GUEST
bool KVM Guest support (including kvmclock)
select PARAVIRT
-   select PARAVIRT
select PARAVIRT_CLOCK
-   default y if PARAVIRT_GUEST
+   default y
---help---
  This option enables various optimizations for running under the KVM
  hypervisor. It includes a paravirtualized clock, so that instead
@@ -638,7 +639,7 @@ config PARAVIRT_DEBUG
  Enable to debug paravirt_ops internals.  Specifically, BUG if
  a paravirt_op is missing when it is called.
 
-endif #PARAVIRT_GUEST
+endif #HYPERVISOR_GUEST
 
 config NO_BOOTMEM
def_bool y
diff --git a/arch/x86/include/asm/hypervisor.h 
b/arch/x86/include/asm/hypervisor.h
index b518c7509933..cd06ed8733cb 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -23,9 +23,6 @@
 #include asm/kvm_para.h
 #include asm/xen/hypervisor.h
 
-extern void init_hypervisor(struct cpuinfo_x86 *c);
-extern void init_hypervisor_platform(void);
-
 /*
  * x86 hypervisor information
  */
@@ -60,4 +57,11 @@ static inline bool hypervisor_x2apic_available(void)
return false;
 }
 
-#endif
+#ifdef CONFIG_PARAVIRT
+extern void init_hypervisor(struct cpuinfo_x86 *c);
+extern void init_hypervisor_platform(void);
+#else
+static inline void init_hypervisor(struct cpuinfo_x86 *c) { }
+static inline void init_hypervisor_platform(void) { }
+#endif /* CONFIG_PARAVIRT */
+#endif /* _ASM_X86_HYPERVISOR_H */
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index a0e067d3d96c..8d04c7cd7cd3 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -14,7 +14,6 @@ CFLAGS_common.o   := $(nostackp)
 
 obj-y  := intel_cacheinfo.o scattered.o topology.o
 obj-y  += proc.o capflags.o powerflags.o common.o
-obj-y  += vmware.o hypervisor.o mshyperv.o
 obj-y  += rdrand.o
 obj-y  += match.o
 
@@ -42,6 +41,8 @@ obj-$(CONFIG_MTRR)+= mtrr/
 
 obj-$(CONFIG_X86_LOCAL_APIC)   += perfctr-watchdog.o 
perf_event_amd_ibs.o
 
+obj-$(CONFIG_PARAVIRT) += vmware.o hypervisor.o mshyperv.o
+
 quiet_cmd_mkcapflags = MKCAP   $@
   cmd_mkcapflags = $(PERL) $(srctree)/$(src)/mkcapflags.pl $ $@
 
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index a8f8fa9769d6..fd6e77f6765e 100644

Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
Hi Borislav,

On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
 index 8e1a9ec53003..cb467656e684 100644
 --- a/drivers/hv/vmbus_drv.c
 +++ b/drivers/hv/vmbus_drv.c
 @@ -724,7 +724,7 @@ static int __init hv_acpi_init(void)
  {
   int ret, t;
  
 - if (x86_hyper != x86_hyper_ms_hyperv)
 + if (!x86_hyper || strncmp(x86_hyper-name, VMware, 6))
   return -ENODEV;

I assume this is a typo as I doubt MS is using the same signature as we
do.

  
   init_completion(probe_event);
 diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
 index cb56e270da11..85f15a6d8798 100644
 --- a/drivers/misc/vmw_balloon.c
 +++ b/drivers/misc/vmw_balloon.c
 @@ -786,7 +786,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 || strncmp(x86_hyper-name, VMware, 6))
   return -ENODEV;


I wonder why you decided to switch from address matching (which is quite
precise and would potentially allow adding signatures without needing
to change the drivers) to string matching?

Thanks,
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
Hi Borislav,

On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
 From: Borislav Petkov b...@suse.de
 
 Put all config options needed to run Linux as a guest behind a
 CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
 default but selected by the user. Also, move x86_hyper into an
 unconditionally-built compilation unit because it is exported with the
 non-GPL flavour and we can't know whatever uses it on the outside.

I am confused by this statement... How can EXPORT_SYMBOL() vs
EXPORT_SYMBOL_GPL() help you determining if it is used out of tree or
not?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:07:31AM -0800, Dmitry Torokhov wrote:
  -   if (x86_hyper != x86_hyper_ms_hyperv)
  +   if (!x86_hyper || strncmp(x86_hyper-name, VMware, 6))
  return -ENODEV;
 
 I assume this is a typo as I doubt MS is using the same signature as we
 do.

Yeah, Vmware is assimilating Microsoft. :-)

Damn copy-paste crap. Sorry, will fix.

  diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
  index cb56e270da11..85f15a6d8798 100644
  --- a/drivers/misc/vmw_balloon.c
  +++ b/drivers/misc/vmw_balloon.c
  @@ -786,7 +786,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 || strncmp(x86_hyper-name, VMware, 6))
  return -ENODEV;
 
 
 I wonder why you decided to switch from address matching (which is quite
 precise and would potentially allow adding signatures without needing
 to change the drivers) to string matching?

Ok, this is a bit more involved. If we put all hypervisor stuff behind
CONFIG_HYPERVISOR_GUEST and in the cases where this is disabled,
the build fails because the x86_hyper_vmware symbol is undefined.
Alternatively, this doesn't happen when we look at the name.

But why would you want to add signatures? Isn't VMware enough as a
name for the vmware hypervisor and why would you need more? And besides,
hypervisor_x86.name is only a single const char * so you'd need to
change that struct to add more names...Hm.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
On Fri, Jan 25, 2013 at 07:23:35PM +0100, Borislav Petkov wrote:
 On Fri, Jan 25, 2013 at 10:07:31AM -0800, Dmitry Torokhov wrote:
   - if (x86_hyper != x86_hyper_ms_hyperv)
   + if (!x86_hyper || strncmp(x86_hyper-name, VMware, 6))
 return -ENODEV;
  
  I assume this is a typo as I doubt MS is using the same signature as we
  do.
 
 Yeah, Vmware is assimilating Microsoft. :-)
 
 Damn copy-paste crap. Sorry, will fix.
 
   diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
   index cb56e270da11..85f15a6d8798 100644
   --- a/drivers/misc/vmw_balloon.c
   +++ b/drivers/misc/vmw_balloon.c
   @@ -786,7 +786,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 || strncmp(x86_hyper-name, VMware, 6))
 return -ENODEV;
  
  
  I wonder why you decided to switch from address matching (which is quite
  precise and would potentially allow adding signatures without needing
  to change the drivers) to string matching?
 
 Ok, this is a bit more involved. If we put all hypervisor stuff behind
 CONFIG_HYPERVISOR_GUEST and in the cases where this is disabled,
 the build fails because the x86_hyper_vmware symbol is undefined.
 Alternatively, this doesn't happen when we look at the name.

Can't we make the balloon driver depend on CONFIG_HYPERVISOR_GUEST?

 
 But why would you want to add signatures? Isn't VMware enough as a
 name for the vmware hypervisor and why would you need more? And besides,
 hypervisor_x86.name is only a single const char * so you'd need to
 change that struct to add more names...Hm.

We do not _need_ more and have no plans to introduce new ones AFAIK, but
I think that comparing an address of a structure instead of string
comparison is much more elegant and it is safer from typos.

Thanks,
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:12:51AM -0800, Dmitry Torokhov wrote:
 Hi Borislav,
 
 On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
  From: Borislav Petkov b...@suse.de
  
  Put all config options needed to run Linux as a guest behind a
  CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
  default but selected by the user. Also, move x86_hyper into an
  unconditionally-built compilation unit because it is exported with the
  non-GPL flavour and we can't know whatever uses it on the outside.
 
 I am confused by this statement... How can EXPORT_SYMBOL() vs
 EXPORT_SYMBOL_GPL() help you determining if it is used out of tree or
 not?

Maybe this wasn't formulated clear enough - I wanted to say that with
the !GPL flavor, any code (proprietary included) can link to those
symbols and we cannot know who uses it and if we hide that symbol,
someone would probably come crying.

Because if we could, I would've done trivial accessor functions which
would return NULL when CONFIG_HYPERVISOR_GUEST is not set so that those
cases build and boot fine, and we wouldn't have the need to have this
symbol always present (like is the case now and I had to move it to
setup.c).

If it were _GPL, we would've fixed all its users to switch to the
accessors.

Makes more sense?

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:29:25AM -0800, Dmitry Torokhov wrote:
 Can't we make the balloon driver depend on CONFIG_HYPERVISOR_GUEST?

We certainly can do that, AFAICT.

 We do not _need_ more and have no plans to introduce new ones AFAIK,
 but I think that comparing an address of a structure instead of string
 comparison is much more elegant and it is safer from typos.

Ok, if you prefer. We can definitely make all .o's which depend on
x86_hyper also depend on CONFIG_HYPERVISOR_GUEST - this solves the whole
deal trivially.

I'll respin the patches.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 07:35:07PM +0100, Borislav Petkov wrote:
 Ok, if you prefer. We can definitely make all .o's which depend on
 x86_hyper also depend on CONFIG_HYPERVISOR_GUEST - this solves the
 whole deal trivially.

 I'll respin the patches.

... provided, of course, nothing out-of-tree is using x86_hyper. Can we
assume that?

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Dmitry Torokhov
On Fri, Jan 25, 2013 at 07:32:13PM +0100, Borislav Petkov wrote:
 On Fri, Jan 25, 2013 at 10:12:51AM -0800, Dmitry Torokhov wrote:
  Hi Borislav,
  
  On Fri, Jan 25, 2013 at 06:59:37PM +0100, Borislav Petkov wrote:
   From: Borislav Petkov b...@suse.de
   
   Put all config options needed to run Linux as a guest behind a
   CONFIG_HYPERVISOR_GUEST menu so that they don't get built-in by
   default but selected by the user. Also, move x86_hyper into an
   unconditionally-built compilation unit because it is exported with the
   non-GPL flavour and we can't know whatever uses it on the outside.
  
  I am confused by this statement... How can EXPORT_SYMBOL() vs
  EXPORT_SYMBOL_GPL() help you determining if it is used out of tree or
  not?
 
 Maybe this wasn't formulated clear enough - I wanted to say that with
 the !GPL flavor, any code (proprietary included) can link to those
 symbols and we cannot know who uses it and if we hide that symbol,
 someone would probably come crying.
 
 Because if we could, I would've done trivial accessor functions which
 would return NULL when CONFIG_HYPERVISOR_GUEST is not set so that those
 cases build and boot fine, and we wouldn't have the need to have this
 symbol always present (like is the case now and I had to move it to
 setup.c).
 
 If it were _GPL, we would've fixed all its users to switch to the
 accessors.
 
 Makes more sense?

No, not really as EXPORT_SYMBOL_GPL() in no way implies that the code
using it lives in the mainline. Also, EXPORT_SYMBOL() does not imply
that it forms an ABI and can't be changed ever.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH -v2 2/2] x86: Make Linux guest support optional

2013-01-25 Thread Borislav Petkov
On Fri, Jan 25, 2013 at 10:42:32AM -0800, Dmitry Torokhov wrote:
 No, not really as EXPORT_SYMBOL_GPL() in no way implies that the code
 using it lives in the mainline.

I didn't say that - I said any code (proprietary included) can link to
those symbols meaning that I cannot possibly convert proprietary code
to which I don't have access to, vs GPL code which is out there.

 Also, EXPORT_SYMBOL() does not imply that it forms an ABI and can't be
 changed ever.

And yet, I don't want to be on the receiving end of the complaints when
those do change. But that's beside the point.

So I think we're on the same page: I'll make everything using x86_hyper*
depend on CONFIG_HYPERVISOR_GUEST and all are happy.

Thanks.

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/