All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] x86/unwind: unwind_dump() cleanups
@ 2017-04-18 13:12 Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump() Josh Poimboeuf
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Josh Poimboeuf @ 2017-04-18 13:12 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel

Some minor cleanups related to the unwind_dump() function.

Josh Poimboeuf (3):
  x86/unwind: properly zero-pad 32-bit values in unwind_dump()
  x86/unwind: prepend hex mask value with '0x' in unwind_dump()
  x86/unwind: remove unused 'sp' argument in unwind_dump()

 arch/x86/kernel/unwind_frame.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

-- 
2.7.4

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

* [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump()
  2017-04-18 13:12 [PATCH 0/3] x86/unwind: unwind_dump() cleanups Josh Poimboeuf
@ 2017-04-18 13:12 ` Josh Poimboeuf
  2017-04-19  8:07   ` [tip:x86/asm] x86/unwind: Properly " tip-bot for Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 2/3] x86/unwind: prepend hex mask value with '0x' " Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 3/3] x86/unwind: remove unused 'sp' argument " Josh Poimboeuf
  2 siblings, 1 reply; 7+ messages in thread
From: Josh Poimboeuf @ 2017-04-18 13:12 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, H. Peter Anvin

On x86-32, 32-bit stack values printed by unwind_dump() are confusingly
zero-padded to 16 characters (64 bits):

  unwind stack type:0 next_sp:  (null) mask:a graph_idx:0
  f50cdebc: 00000000f50cdec4 (0xf50cdec4)
  f50cdec0: 00000000c40489b7 (irq_exit+0x87/0xa0)
  ...

Instead, base the field width on the size of a long integer so that it
looks right on both x86-32 and x86-64.

x86-32:

  unwind stack type:1 next_sp:  (null) mask:0x2 graph_idx:0
  c0ee9d98: c0ee9de0 (init_thread_union+0x1de0/0x2000)
  c0ee9d9c: c043fd90 (__save_stack_trace+0x50/0xe0)
  ...

x86-64:

  unwind stack type:1 next_sp:          (null) mask:0x2 graph_idx:0
  ffffffff81e03b88: ffffffff81e03c10 (init_thread_union+0x3c10/0x4000)
  ffffffff81e03b90: ffffffff81048f8e (__save_stack_trace+0x5e/0x100)
  ...

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kernel/unwind_frame.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index c461135..3ebe687 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -48,11 +48,13 @@ static void unwind_dump(struct unwind_state *state, unsigned long *sp)
 
 		if (zero) {
 			if (!prev_zero)
-				printk_deferred("%p: %016x ...\n", sp, 0);
+				printk_deferred("%p: %0*x ...\n",
+						sp, BITS_PER_LONG/4, 0);
 			continue;
 		}
 
-		printk_deferred("%p: %016lx (%pB)\n", sp, word, (void *)word);
+		printk_deferred("%p: %0*lx (%pB)\n",
+				sp, BITS_PER_LONG/4, word, (void *)word);
 	}
 }
 
-- 
2.7.4

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

* [PATCH 2/3] x86/unwind: prepend hex mask value with '0x' in unwind_dump()
  2017-04-18 13:12 [PATCH 0/3] x86/unwind: unwind_dump() cleanups Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump() Josh Poimboeuf
@ 2017-04-18 13:12 ` Josh Poimboeuf
  2017-04-19  8:08   ` [tip:x86/asm] x86/unwind: Prepend " tip-bot for Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 3/3] x86/unwind: remove unused 'sp' argument " Josh Poimboeuf
  2 siblings, 1 reply; 7+ messages in thread
From: Josh Poimboeuf @ 2017-04-18 13:12 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel

In unwind_dump(), the stack mask value is printed in hex, but is
confusingly not prepended with '0x'.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kernel/unwind_frame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 3ebe687..5d26374 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -36,7 +36,7 @@ static void unwind_dump(struct unwind_state *state, unsigned long *sp)
 
 	dumped_before = true;
 
-	printk_deferred("unwind stack type:%d next_sp:%p mask:%lx graph_idx:%d\n",
+	printk_deferred("unwind stack type:%d next_sp:%p mask:0x%lx graph_idx:%d\n",
 			state->stack_info.type, state->stack_info.next_sp,
 			state->stack_mask, state->graph_idx);
 
-- 
2.7.4

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

* [PATCH 3/3] x86/unwind: remove unused 'sp' argument in unwind_dump()
  2017-04-18 13:12 [PATCH 0/3] x86/unwind: unwind_dump() cleanups Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump() Josh Poimboeuf
  2017-04-18 13:12 ` [PATCH 2/3] x86/unwind: prepend hex mask value with '0x' " Josh Poimboeuf
@ 2017-04-18 13:12 ` Josh Poimboeuf
  2017-04-19  8:08   ` [tip:x86/asm] x86/unwind: Remove unused 'sp' parameter " tip-bot for Josh Poimboeuf
  2 siblings, 1 reply; 7+ messages in thread
From: Josh Poimboeuf @ 2017-04-18 13:12 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel

The 'sp' argument to unwind_dump() is unused.  Remove it.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kernel/unwind_frame.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 5d26374..bda82df 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -25,11 +25,11 @@
 	val;						\
 })
 
-static void unwind_dump(struct unwind_state *state, unsigned long *sp)
+static void unwind_dump(struct unwind_state *state)
 {
 	static bool dumped_before = false;
 	bool prev_zero, zero = false;
-	unsigned long word;
+	unsigned long word, *sp;
 
 	if (dumped_before)
 		return;
@@ -287,13 +287,13 @@ bool unwind_next_frame(struct unwind_state *state)
 			"WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n",
 			state->regs, state->task->comm,
 			state->task->pid, next_bp);
-		unwind_dump(state, (unsigned long *)state->regs);
+		unwind_dump(state);
 	} else {
 		printk_deferred_once(KERN_WARNING
 			"WARNING: kernel stack frame pointer at %p in %s:%d has bad value %p\n",
 			state->bp, state->task->comm,
 			state->task->pid, next_bp);
-		unwind_dump(state, state->bp);
+		unwind_dump(state);
 	}
 the_end:
 	state->stack_info.type = STACK_TYPE_UNKNOWN;
-- 
2.7.4

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

* [tip:x86/asm] x86/unwind: Properly zero-pad 32-bit values in unwind_dump()
  2017-04-18 13:12 ` [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump() Josh Poimboeuf
@ 2017-04-19  8:07   ` tip-bot for Josh Poimboeuf
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2017-04-19  8:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, torvalds, dvlasenk, brgerst, jpoimboe, bp, peterz, mingo,
	linux-kernel, luto, hpa

Commit-ID:  9b135b234644c9881eee4f5d5683da0f4524722f
Gitweb:     http://git.kernel.org/tip/9b135b234644c9881eee4f5d5683da0f4524722f
Author:     Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Tue, 18 Apr 2017 08:12:56 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 19 Apr 2017 09:59:47 +0200

x86/unwind: Properly zero-pad 32-bit values in unwind_dump()

On x86-32, 32-bit stack values printed by unwind_dump() are confusingly
zero-padded to 16 characters (64 bits):

  unwind stack type:0 next_sp:  (null) mask:a graph_idx:0
  f50cdebc: 00000000f50cdec4 (0xf50cdec4)
  f50cdec0: 00000000c40489b7 (irq_exit+0x87/0xa0)
  ...

Instead, base the field width on the size of a long integer so that it
looks right on both x86-32 and x86-64.

x86-32:

  unwind stack type:1 next_sp:  (null) mask:0x2 graph_idx:0
  c0ee9d98: c0ee9de0 (init_thread_union+0x1de0/0x2000)
  c0ee9d9c: c043fd90 (__save_stack_trace+0x50/0xe0)
  ...

x86-64:

  unwind stack type:1 next_sp:          (null) mask:0x2 graph_idx:0
  ffffffff81e03b88: ffffffff81e03c10 (init_thread_union+0x3c10/0x4000)
  ffffffff81e03b90: ffffffff81048f8e (__save_stack_trace+0x5e/0x100)
  ...

Reported-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/36b743812e7eb291d74af4e5067736736622daad.1492520933.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/unwind_frame.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index c461135..3ebe687 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -48,11 +48,13 @@ static void unwind_dump(struct unwind_state *state, unsigned long *sp)
 
 		if (zero) {
 			if (!prev_zero)
-				printk_deferred("%p: %016x ...\n", sp, 0);
+				printk_deferred("%p: %0*x ...\n",
+						sp, BITS_PER_LONG/4, 0);
 			continue;
 		}
 
-		printk_deferred("%p: %016lx (%pB)\n", sp, word, (void *)word);
+		printk_deferred("%p: %0*lx (%pB)\n",
+				sp, BITS_PER_LONG/4, word, (void *)word);
 	}
 }
 

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

* [tip:x86/asm] x86/unwind: Prepend hex mask value with '0x' in unwind_dump()
  2017-04-18 13:12 ` [PATCH 2/3] x86/unwind: prepend hex mask value with '0x' " Josh Poimboeuf
@ 2017-04-19  8:08   ` tip-bot for Josh Poimboeuf
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2017-04-19  8:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, torvalds, brgerst, linux-kernel, mingo, luto, hpa,
	dvlasenk, bp, jpoimboe, tglx

Commit-ID:  4ea3d7410c3597910071182a6bc258c015942887
Gitweb:     http://git.kernel.org/tip/4ea3d7410c3597910071182a6bc258c015942887
Author:     Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Tue, 18 Apr 2017 08:12:57 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 19 Apr 2017 09:59:47 +0200

x86/unwind: Prepend hex mask value with '0x' in unwind_dump()

In unwind_dump(), the stack mask value is printed in hex, but is
confusingly not prepended with '0x'.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/e7fe41be19d73c9f99f53082486473febfe08ffa.1492520933.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/unwind_frame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 3ebe687..5d26374 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -36,7 +36,7 @@ static void unwind_dump(struct unwind_state *state, unsigned long *sp)
 
 	dumped_before = true;
 
-	printk_deferred("unwind stack type:%d next_sp:%p mask:%lx graph_idx:%d\n",
+	printk_deferred("unwind stack type:%d next_sp:%p mask:0x%lx graph_idx:%d\n",
 			state->stack_info.type, state->stack_info.next_sp,
 			state->stack_mask, state->graph_idx);
 

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

* [tip:x86/asm] x86/unwind: Remove unused 'sp' parameter in unwind_dump()
  2017-04-18 13:12 ` [PATCH 3/3] x86/unwind: remove unused 'sp' argument " Josh Poimboeuf
@ 2017-04-19  8:08   ` tip-bot for Josh Poimboeuf
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Josh Poimboeuf @ 2017-04-19  8:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jpoimboe, brgerst, luto, bp, peterz, mingo, dvlasenk, torvalds,
	linux-kernel, tglx, hpa

Commit-ID:  aa4f853461aab5f526a312bf418091a95626632b
Gitweb:     http://git.kernel.org/tip/aa4f853461aab5f526a312bf418091a95626632b
Author:     Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Tue, 18 Apr 2017 08:12:58 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 19 Apr 2017 09:59:47 +0200

x86/unwind: Remove unused 'sp' parameter in unwind_dump()

The 'sp' parameter to unwind_dump() is unused.  Remove it.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/08cb36b004629f6bbcf44c267ae4a609242ebd0b.1492520933.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/unwind_frame.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 5d26374..bda82df 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -25,11 +25,11 @@
 	val;						\
 })
 
-static void unwind_dump(struct unwind_state *state, unsigned long *sp)
+static void unwind_dump(struct unwind_state *state)
 {
 	static bool dumped_before = false;
 	bool prev_zero, zero = false;
-	unsigned long word;
+	unsigned long word, *sp;
 
 	if (dumped_before)
 		return;
@@ -287,13 +287,13 @@ bad_address:
 			"WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n",
 			state->regs, state->task->comm,
 			state->task->pid, next_bp);
-		unwind_dump(state, (unsigned long *)state->regs);
+		unwind_dump(state);
 	} else {
 		printk_deferred_once(KERN_WARNING
 			"WARNING: kernel stack frame pointer at %p in %s:%d has bad value %p\n",
 			state->bp, state->task->comm,
 			state->task->pid, next_bp);
-		unwind_dump(state, state->bp);
+		unwind_dump(state);
 	}
 the_end:
 	state->stack_info.type = STACK_TYPE_UNKNOWN;

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

end of thread, other threads:[~2017-04-19  8:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-18 13:12 [PATCH 0/3] x86/unwind: unwind_dump() cleanups Josh Poimboeuf
2017-04-18 13:12 ` [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump() Josh Poimboeuf
2017-04-19  8:07   ` [tip:x86/asm] x86/unwind: Properly " tip-bot for Josh Poimboeuf
2017-04-18 13:12 ` [PATCH 2/3] x86/unwind: prepend hex mask value with '0x' " Josh Poimboeuf
2017-04-19  8:08   ` [tip:x86/asm] x86/unwind: Prepend " tip-bot for Josh Poimboeuf
2017-04-18 13:12 ` [PATCH 3/3] x86/unwind: remove unused 'sp' argument " Josh Poimboeuf
2017-04-19  8:08   ` [tip:x86/asm] x86/unwind: Remove unused 'sp' parameter " tip-bot for Josh Poimboeuf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.