Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1625315

[PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump()

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump()
Date 2017-04-18 15:20 +0200
Message-ID <txBcZ-6Cr-9@gated-at.bofh.it> (permalink)
References <txBcZ-6Cr-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] x86/unwind: unwind_dump() cleanups Josh Poimboeuf <jpoimboe@redhat.com> - 2017-04-18 15:20 +0200
  [PATCH 1/3] x86/unwind: properly zero-pad 32-bit values in unwind_dump() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-04-18 15:20 +0200
    [tip:x86/asm] x86/unwind: Properly zero-pad 32-bit values in  unwind_dump() tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2017-04-19 10:20 +0200
  [PATCH 3/3] x86/unwind: remove unused 'sp' argument in unwind_dump() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-04-18 15:20 +0200
    [tip:x86/asm] x86/unwind: Remove unused 'sp' parameter in  unwind_dump() tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2017-04-19 10:20 +0200
  [PATCH 2/3] x86/unwind: prepend hex mask value with '0x' in unwind_dump() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-04-18 15:20 +0200
    [tip:x86/asm] x86/unwind: Prepend hex mask value with '0x' in  unwind_dump() tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2017-04-19 10:20 +0200

csiph-web