Re: kvm_intel: Could not allocate 42 bytes percpu data

2013-06-24 Thread Prarit Bhargava


On 06/24/2013 03:01 PM, Chegu Vinod wrote:
> 
> Hello,
> 
> Lots (~700+) of the following messages are showing up in the dmesg of a 
> 3.10-rc1
> based kernel (Host OS is running on a large socket count box with HT-on).
> 
> [   82.270682] PERCPU: allocation failed, size=42 align=16, alloc from 
> reserved
> chunk failed
> [   82.272633] kvm_intel: Could not allocate 42 bytes percpu data

On 3.10?  Geez.  I thought we had fixed this.  I'll grab a big machine and see
if I can debug.

Rusty -- any ideas off the top of your head?'
> 
> ... also call traces like the following...
> 
> [  101.852136]  c901ad5aa090 88084675dd08 81633743 
> 88084675ddc8
> [  101.860889]  81145053 81f3fa78 88084809dd40 
> 8907d1cfd2e8
> [  101.869466]  8907d1cfd280 88087fffdb08 88084675c010 
> 88084675dfd8
> [  101.878190] Call Trace:
> [  101.880953]  [] dump_stack+0x19/0x1e
> [  101.886679]  [] pcpu_alloc+0x9a3/0xa40
> [  101.892754]  [] __alloc_reserved_percpu+0x13/0x20
> [  101.899733]  [] load_module+0x35f/0x1a70
> [  101.905835]  [] ? do_page_fault+0xe/0x10
> [  101.911953]  [] SyS_init_module+0xfb/0x140
> [  101.918287]  [] system_call_fastpath+0x16/0x1b
> [  101.924981] kvm_intel: Could not allocate 42 bytes percpu data
> 
> 
> Wondering if anyone else has seen this with the recent [3.10] based kernels 
> esp.
> on larger boxes?
> 
> There was a similar issue that was reported earlier (where modules were being
> loaded per cpu without checking if an instance was already 
> loaded/being-loaded).
> That issue seems to have been addressed in the recent past (e.g.
> https://lkml.org/lkml/2013/1/24/659 along with a couple of follow on 
> cleanups)  
> Is the above yet another variant of the original issue or perhaps some race
> condition that got exposed when there are lot more threads ?

Hmm ... not sure but yeah, that's the likely culprit.

P.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack() [v4]

2012-10-30 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point
and set x86_hyper.  We can use this to output additional debug
information during a panic/oops/stack trace.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org

[v2]: Modifications suggested by Ingo and added changes for similar output
  from process.c

[v3]: Unify common code and move output to end of line
---
 arch/x86/kernel/dumpstack.c |6 +-
 arch/x86/kernel/process.c   |   14 --
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..96d40ed 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -188,11 +188,7 @@ void dump_stack(void)
unsigned long stack;
 
bp = stack_frame(current, NULL);
-   printk("Pid: %d, comm: %.20s %s %s %.*s\n",
-   current->pid, current->comm, print_tainted(),
-   init_utsname()->release,
-   (int)strcspn(init_utsname()->version, " "),
-   init_utsname()->version);
+   show_regs_common();
show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index b644e1c..7ea4692 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -124,6 +125,13 @@ void exit_thread(void)
 void show_regs_common(void)
 {
const char *vendor, *product, *board;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
if (!vendor)
@@ -135,14 +143,16 @@ void show_regs_common(void)
/* Board Name is optional */
board = dmi_get_system_info(DMI_BOARD_NAME);
 
-   printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+   printk(KERN_DEFAULT
+  "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s [%s %s kernel]\n",
   current->pid, current->comm, print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
   init_utsname()->version,
   vendor, product,
   board ? "/" : "",
-  board ? board : "");
+  board ? board : "",
+  machine_name, kernel_type);
 }
 
 void flush_thread(void)
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack() [v3]

2012-10-30 Thread Prarit Bhargava


On 10/30/2012 03:14 PM, Prarit Bhargava wrote:
> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
> bare-metal boots can get difficult very quickly.  While there are ways to
> decipher the output and determine if the output is from a virtual guest,
> the in-kernel hypervisors now have a single registration point
> and set x86_hyper.  We can use this to output additional debug
> information during a panic/oops/stack trace.
> 
> Signed-off-by: Prarit Bhargava 
> Cc: Avi Kivity 
> Cc: Gleb Natapov 
> Cc: Alex Williamson 
> Cc: Marcelo Tostatti 
> Cc: Ingo Molnar 
> Cc: kvm@vger.kernel.org
> Cc: x...@kernel.org
> 
> [v2]: Modifications suggested by Ingo and added changes for similar output
>   from process.c
> 
> [v3]: Unify common code and move output to end of line
> ---
>  arch/x86/kernel/dumpstack.c |6 +-
>  arch/x86/kernel/process.c   |   12 +++-
>  2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index ae42418b..96d40ed 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -188,11 +188,7 @@ void dump_stack(void)
>   unsigned long stack;
>  
>   bp = stack_frame(current, NULL);
> - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
> - current->pid, current->comm, print_tainted(),
> - init_utsname()->release,
> - (int)strcspn(init_utsname()->version, " "),
> - init_utsname()->version);
> + show_regs_common();
>   show_trace(NULL, NULL, &stack, bp);
>  }
>  EXPORT_SYMBOL(dump_stack);
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index b644e1c..14bd064 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
> @@ -124,6 +125,13 @@ void exit_thread(void)
>  void show_regs_common(void)
>  {
>   const char *vendor, *product, *board;
> + const char *machine_name = "x86";
> + const char *kernel_type = "native";
> +
> + if (x86_hyper) {
> + machine_name = x86_hyper->name;
> + kernel_type = "guest";
> + }
>  
>   vendor = dmi_get_system_info(DMI_SYS_VENDOR);
>   if (!vendor)
> @@ -135,7 +143,9 @@ void show_regs_common(void)
>   /* Board Name is optional */
>   board = dmi_get_system_info(DMI_BOARD_NAME);
>  
> - printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> + printk(KERN_DEFAULT
> +"[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> +machine_name, kernel_type,

Ugh ... self-nak.  I sent the wrong version of this patch.  Sorry Ingo :(

P.

>  current->pid, current->comm, print_tainted(),
>  init_utsname()->release,
>  (int)strcspn(init_utsname()->version, " "),
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack() [v3]

2012-10-30 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point
and set x86_hyper.  We can use this to output additional debug
information during a panic/oops/stack trace.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org

[v2]: Modifications suggested by Ingo and added changes for similar output
  from process.c

[v3]: Unify common code and move output to end of line
---
 arch/x86/kernel/dumpstack.c |6 +-
 arch/x86/kernel/process.c   |   12 +++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..96d40ed 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -188,11 +188,7 @@ void dump_stack(void)
unsigned long stack;
 
bp = stack_frame(current, NULL);
-   printk("Pid: %d, comm: %.20s %s %s %.*s\n",
-   current->pid, current->comm, print_tainted(),
-   init_utsname()->release,
-   (int)strcspn(init_utsname()->version, " "),
-   init_utsname()->version);
+   show_regs_common();
show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index b644e1c..14bd064 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -124,6 +125,13 @@ void exit_thread(void)
 void show_regs_common(void)
 {
const char *vendor, *product, *board;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
if (!vendor)
@@ -135,7 +143,9 @@ void show_regs_common(void)
/* Board Name is optional */
board = dmi_get_system_info(DMI_BOARD_NAME);
 
-   printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+   printk(KERN_DEFAULT
+  "[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+  machine_name, kernel_type,
   current->pid, current->comm, print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack() [v2]

2012-10-26 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point
and set x86_hyper.  We can use this to output additional debug
information during a panic/oops/stack trace.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org

[v2]: Modifications suggested by Ingo and added changes for similar output
  from process.c
---
 arch/x86/kernel/dumpstack.c |   11 ++-
 arch/x86/kernel/process.c   |   12 +++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..5dd680f 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 
@@ -186,9 +187,17 @@ void dump_stack(void)
 {
unsigned long bp;
unsigned long stack;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
bp = stack_frame(current, NULL);
-   printk("Pid: %d, comm: %.20s %s %s %.*s\n",
+   printk("[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s\n",
+   machine_name, kernel_type,
current->pid, current->comm, print_tainted(),
init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index b644e1c..14bd064 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -124,6 +125,13 @@ void exit_thread(void)
 void show_regs_common(void)
 {
const char *vendor, *product, *board;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
if (!vendor)
@@ -135,7 +143,9 @@ void show_regs_common(void)
/* Board Name is optional */
board = dmi_get_system_info(DMI_BOARD_NAME);
 
-   printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+   printk(KERN_DEFAULT
+  "[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+  machine_name, kernel_type,
   current->pid, current->comm, print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack()

2012-10-24 Thread Prarit Bhargava


On 10/24/2012 05:49 AM, Ingo Molnar wrote:
> 
> * Prarit Bhargava  wrote:
> 
>> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
>> bare-metal boots can get difficult very quickly.  While there are ways to
>> decipher the output and determine if the output is from a virtual guest,
>> the in-kernel hypervisors now have a single registration point and set
>> x86_hyper.  We can use this to output a single extra line on virtual
>> machines that indicates the hypervisor type.
>>
>> Signed-off-by: Prarit Bhargava 
>> Cc: Avi Kivity 
>> Cc: Gleb Natapov 
>> Cc: Alex Williamson 
>> Cc: Marcelo Tostatti 
>> Cc: Ingo Molnar 
>> Cc: kvm@vger.kernel.org
>> Cc: x...@kernel.org
>> ---
>>  arch/x86/kernel/dumpstack.c |3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
>> index ae42418b..75a635e 100644
>> --- a/arch/x86/kernel/dumpstack.c
>> +++ b/arch/x86/kernel/dumpstack.c
>> @@ -17,6 +17,7 @@
>>  #include 
>>  
>>  #include 
>> +#include 
>>  
>>  
>>  int panic_on_unrecovered_nmi;
>> @@ -193,6 +194,8 @@ void dump_stack(void)
>>  init_utsname()->release,
>>  (int)strcspn(init_utsname()->version, " "),
>>  init_utsname()->version);
>> +if (x86_hyper && x86_hyper->name)
>> +printk("Hypervisor: %s\n",  x86_hyper->name);
>>  show_trace(NULL, NULL, &stack, bp);
> 
> Looks useful, but please don't waste a full new line on it but 
> embedd it in the already existing status line that prints 
> details like release and version.

Ingo, I thought about doing that but since x86_hyper can be NULL (... maybe it
should initialized to "Bare-metal" or "No Hypervisor"?) I didn't want to break
up the printk line.  I'll look into doing it a different way...

P.

> 
> Thanks,
> 
>   Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack()

2012-10-10 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point and set
x86_hyper.  We can use this to output a single extra line on virtual
machines that indicates the hypervisor type.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org
---
 arch/x86/kernel/dumpstack.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..75a635e 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -17,6 +17,7 @@
 #include 
 
 #include 
+#include 
 
 
 int panic_on_unrecovered_nmi;
@@ -193,6 +194,8 @@ void dump_stack(void)
init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
init_utsname()->version);
+   if (x86_hyper && x86_hyper->name)
+   printk("Hypervisor: %s\n",  x86_hyper->name);
show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kvm build error: undefined reference to `x86_hyper_kvm'

2012-07-18 Thread Prarit Bhargava


On 07/17/2012 10:42 PM, Ren, Yongjie wrote:
> kvm.git next branch
> commit: ebf7d2e9
> 
> arch/x86/built-in.o: In function `init_hypervisor_platform':
> (.init.text+0x56b1): undefined reference to `x86_hyper_kvm'
> arch/x86/built-in.o: In function `init_hypervisor_platform':
> (.init.text+0x56bc): undefined reference to `x86_hyper_kvm'
> make: *** [vmlinux] Error 1
> 

Ah, never mind my previous email.  I see that Avi quickly found the issue.

http://marc.info/?l=kvm&m=134260159617733&w=2

Sorry 'bout that,

P.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kvm build error: undefined reference to `x86_hyper_kvm'

2012-07-18 Thread Prarit Bhargava


On 07/17/2012 10:42 PM, Ren, Yongjie wrote:
> kvm.git next branch
> commit: ebf7d2e9
> 
> arch/x86/built-in.o: In function `init_hypervisor_platform':
> (.init.text+0x56b1): undefined reference to `x86_hyper_kvm'
> arch/x86/built-in.o: In function `init_hypervisor_platform':
> (.init.text+0x56bc): undefined reference to `x86_hyper_kvm'
> make: *** [vmlinux] Error 1
> 

That's odd, can you send me your .config?  It compiles for me...

P.

> 
> Best Regards,
>  Yongjie (Jay)
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] kvm, Add x86_hyper_kvm to complete detect_hypervisor_platform check [v2]

2012-07-06 Thread Prarit Bhargava


On 07/06/2012 07:27 AM, Marcelo Tosatti wrote:
> On Thu, Jul 05, 2012 at 09:37:00AM -0400, Prarit Bhargava wrote:
>>
>>
>> On 07/05/2012 09:26 AM, Avi Kivity wrote:
>>> Please copy at least kvm@vger.kernel.org, and preferably Marcelo as well
>>> (the other kvm co-maintainer).
>>>
>>>
>>
>> While debugging I noticed that unlike all the other hypervisor code in the
>> kernel, kvm does not have an entry for x86_hyper which is used in
>> detect_hypervisor_platform() which results in a nice printk in the
>> syslog.  This is only really a stub function but it
>> does make kvm more consistent with the other hypervisors.
>>
>> [v2]: add detect and _GPL export
>>
>> Signed-off-by: Prarit Bhargava 
>> Cc: Avi Kivity 
>> Cc: Gleb Natapov 
>> Cc: Alex Williamson 
>> Cc: Konrad Rzeszutek Wilk 
> 
> Looks good, please regenerate:
> 
> Hunk #1 FAILED at 39.
> Hunk #2 succeeded at 484 (offset 51 lines).
> 1 out of 2 hunks FAILED -- saving rejects to file
> arch/x86/kernel/kvm.c.rej

Oops.  Sorry about that Marcelo.  I didn't know about kvm next :(  My bad.
8<-

[PATCH 1/2] kvm, Add x86_hyper_kvm to complete detect_hypervisor_platform check 
[v3]

While debugging I noticed that unlike all the other hypervisor code in the
kernel, kvm does not have an entry for x86_hyper which is used in
detect_hypervisor_platform() which results in a nice printk in the
syslog.  This is only really a stub function but it
does make kvm more consistent with the other hypervisors.

[v2]: add detect and _GPL export
[v3]: patch against kvm next

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Konrad Rzeszutek Wilk 
Cc: Marcelo Tostatti 
Cc: kvm@vger.kernel.org
---
 arch/x86/include/asm/hypervisor.h |1 +
 arch/x86/kernel/cpu/hypervisor.c  |1 +
 arch/x86/kernel/kvm.c |   14 ++
 3 files changed, 16 insertions(+)

diff --git a/arch/x86/include/asm/hypervisor.h 
b/arch/x86/include/asm/hypervisor.h
index 7a15153..b518c75 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper;
 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_hvm;
+extern const struct hypervisor_x86 x86_hyper_kvm;

 static inline bool hypervisor_x2apic_available(void)
 {
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 755f64f..6d6dd7a 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -37,6 +37,7 @@ static const __initconst struct hypervisor_x86 * const
hypervisors[] =
 #endif
&x86_hyper_vmware,
&x86_hyper_ms_hyperv,
+   &x86_hyper_kvm,
 };

 const struct hypervisor_x86 *x86_hyper;
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 75ab94c..299cf14 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 

 static int kvmapf = 1;

@@ -483,6 +484,19 @@ void __init kvm_guest_init(void)
 #endif
 }

+static bool __init kvm_detect(void)
+{
+   if (!kvm_para_available())
+   return false;
+   return true;
+}
+
+const struct hypervisor_x86 x86_hyper_kvm __refconst = {
+   .name   = "KVM",
+   .detect = kvm_detect,
+};
+EXPORT_SYMBOL_GPL(x86_hyper_kvm);
+
 static __init int activate_jump_labels(void)
 {
if (has_steal_clock) {
-- 
1.7.10.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] kvm, Add x86_hyper_kvm to complete detect_hypervisor_platform check [v2]

2012-07-05 Thread Prarit Bhargava


On 07/05/2012 09:26 AM, Avi Kivity wrote:
> Please copy at least kvm@vger.kernel.org, and preferably Marcelo as well
> (the other kvm co-maintainer).
> 
> 

While debugging I noticed that unlike all the other hypervisor code in the
kernel, kvm does not have an entry for x86_hyper which is used in
detect_hypervisor_platform() which results in a nice printk in the
syslog.  This is only really a stub function but it
does make kvm more consistent with the other hypervisors.

[v2]: add detect and _GPL export

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Konrad Rzeszutek Wilk 
---
 arch/x86/include/asm/hypervisor.h |1 +
 arch/x86/kernel/cpu/hypervisor.c  |1 +
 arch/x86/kernel/kvm.c |   14 ++
 3 files changed, 16 insertions(+)

diff --git a/arch/x86/include/asm/hypervisor.h 
b/arch/x86/include/asm/hypervisor.h
index 7a15153..b518c75 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper;
 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_hvm;
+extern const struct hypervisor_x86 x86_hyper_kvm;

 static inline bool hypervisor_x2apic_available(void)
 {
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 755f64f..6d6dd7a 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -37,6 +37,7 @@ static const __initconst struct hypervisor_x86 * const
hypervisors[] =
 #endif
&x86_hyper_vmware,
&x86_hyper_ms_hyperv,
+   &x86_hyper_kvm,
 };

 const struct hypervisor_x86 *x86_hyper;
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index e554e5a..865cd13 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 static int kvmapf = 1;

@@ -432,6 +433,19 @@ void __init kvm_guest_init(void)
 #endif
 }

+static bool __init kvm_detect(void)
+{
+   if (!kvm_para_available())
+   return false;
+   return true;
+}
+
+const struct hypervisor_x86 x86_hyper_kvm __refconst = {
+   .name   = "KVM",
+   .detect = kvm_detect,
+};
+EXPORT_SYMBOL_GPL(x86_hyper_kvm);
+
 static __init int activate_jump_labels(void)
 {
if (has_steal_clock) {
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html