kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86, add hypervisor name to dump_stack() [v4]
@ 2012-10-30 20:26 Prarit Bhargava
  2012-10-30 21:04 ` Borislav Petkov
  2012-11-01  9:30 ` Gleb Natapov
  0 siblings, 2 replies; 3+ messages in thread
From: Prarit Bhargava @ 2012-10-30 20:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Avi Kivity, Gleb Natapov, Alex Williamson,
	Marcelo Tostatti, Ingo Molnar, kvm, x86

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 <prarit@redhat.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Marcelo Tostatti <mtosatti@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: kvm@vger.kernel.org
Cc: x86@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 <asm/fpu-internal.h>
 #include <asm/debugreg.h>
 #include <asm/nmi.h>
+#include <asm/hypervisor.h>
 
 /*
  * 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86, add hypervisor name to dump_stack() [v4]
  2012-10-30 20:26 [PATCH] x86, add hypervisor name to dump_stack() [v4] Prarit Bhargava
@ 2012-10-30 21:04 ` Borislav Petkov
  2012-11-01  9:30 ` Gleb Natapov
  1 sibling, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2012-10-30 21:04 UTC (permalink / raw)
  To: Prarit Bhargava
  Cc: linux-kernel, Avi Kivity, Gleb Natapov, Alex Williamson,
	Marcelo Tostatti, Ingo Molnar, kvm, x86

On Tue, Oct 30, 2012 at 04:26:33PM -0400, 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 <prarit@redhat.com>
> Cc: Avi Kivity <avi@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Marcelo Tostatti <mtosatti@redhat.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: x86@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

Looks useful.

Acked-by: Borislav Petkov <bp@alien8.de>

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86, add hypervisor name to dump_stack() [v4]
  2012-10-30 20:26 [PATCH] x86, add hypervisor name to dump_stack() [v4] Prarit Bhargava
  2012-10-30 21:04 ` Borislav Petkov
@ 2012-11-01  9:30 ` Gleb Natapov
  1 sibling, 0 replies; 3+ messages in thread
From: Gleb Natapov @ 2012-11-01  9:30 UTC (permalink / raw)
  To: Prarit Bhargava
  Cc: linux-kernel, Avi Kivity, Alex Williamson, Marcelo Tostatti,
	Ingo Molnar, kvm, x86

On Tue, Oct 30, 2012 at 04:26:33PM -0400, 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 <prarit@redhat.com>
> Cc: Avi Kivity <avi@redhat.com>
> Cc: Gleb Natapov <gleb@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Marcelo Tostatti <mtosatti@redhat.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: x86@kernel.org
> 
Acked-by: Gleb Natapov <gleb@redhat.com>

> [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 <asm/fpu-internal.h>
>  #include <asm/debugreg.h>
>  #include <asm/nmi.h>
> +#include <asm/hypervisor.h>
>  
>  /*
>   * 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

--
			Gleb.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-01  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-30 20:26 [PATCH] x86, add hypervisor name to dump_stack() [v4] Prarit Bhargava
2012-10-30 21:04 ` Borislav Petkov
2012-11-01  9:30 ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).