diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-22 20:09:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-22 20:09:32 -0400 |
commit | 5ef6ca4f24b59af7f7c2c19502a3923a4bc10e0a (patch) | |
tree | 24f0a7f99ca3f091f9a0c3127d4d37054340fa2c | |
parent | b3ba283d831fed464a1f9c18e7ee82b020ab1a1e (diff) | |
parent | 113b5e3720e79ad938374163c1b8e295521dc9cf (diff) |
Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 debugging documentation updates from Ingo Molnar:
"Documentation updates about x86 kernel stacks"
* 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/Documentation: Adapt Ingo's explanation on printing backtraces
x86/Documentation: Remove STACKFAULT_STACK bulletpoint
x86/Documentation: Move kernel-stacks doc one level up
-rw-r--r-- | Documentation/x86/kernel-stacks (renamed from Documentation/x86/x86_64/kernel-stacks) | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/Documentation/x86/x86_64/kernel-stacks b/Documentation/x86/kernel-stacks index e3c8a49d1a2f..0f3a6c201943 100644 --- a/Documentation/x86/x86_64/kernel-stacks +++ b/Documentation/x86/kernel-stacks | |||
@@ -1,3 +1,6 @@ | |||
1 | Kernel stacks on x86-64 bit | ||
2 | --------------------------- | ||
3 | |||
1 | Most of the text from Keith Owens, hacked by AK | 4 | Most of the text from Keith Owens, hacked by AK |
2 | 5 | ||
3 | x86_64 page size (PAGE_SIZE) is 4K. | 6 | x86_64 page size (PAGE_SIZE) is 4K. |
@@ -56,13 +59,6 @@ If that assumption is ever broken then the stacks will become corrupt. | |||
56 | 59 | ||
57 | The currently assigned IST stacks are :- | 60 | The currently assigned IST stacks are :- |
58 | 61 | ||
59 | * STACKFAULT_STACK. EXCEPTION_STKSZ (PAGE_SIZE). | ||
60 | |||
61 | Used for interrupt 12 - Stack Fault Exception (#SS). | ||
62 | |||
63 | This allows the CPU to recover from invalid stack segments. Rarely | ||
64 | happens. | ||
65 | |||
66 | * DOUBLEFAULT_STACK. EXCEPTION_STKSZ (PAGE_SIZE). | 62 | * DOUBLEFAULT_STACK. EXCEPTION_STKSZ (PAGE_SIZE). |
67 | 63 | ||
68 | Used for interrupt 8 - Double Fault Exception (#DF). | 64 | Used for interrupt 8 - Double Fault Exception (#DF). |
@@ -99,3 +95,47 @@ The currently assigned IST stacks are :- | |||
99 | assumptions about the previous state of the kernel stack. | 95 | assumptions about the previous state of the kernel stack. |
100 | 96 | ||
101 | For more details see the Intel IA32 or AMD AMD64 architecture manuals. | 97 | For more details see the Intel IA32 or AMD AMD64 architecture manuals. |
98 | |||
99 | |||
100 | Printing backtraces on x86 | ||
101 | -------------------------- | ||
102 | |||
103 | The question about the '?' preceding function names in an x86 stacktrace | ||
104 | keeps popping up, here's an indepth explanation. It helps if the reader | ||
105 | stares at print_context_stack() and the whole machinery in and around | ||
106 | arch/x86/kernel/dumpstack.c. | ||
107 | |||
108 | Adapted from Ingo's mail, Message-ID: <20150521101614.GA10889@gmail.com>: | ||
109 | |||
110 | We always scan the full kernel stack for return addresses stored on | ||
111 | the kernel stack(s) [*], from stack top to stack bottom, and print out | ||
112 | anything that 'looks like' a kernel text address. | ||
113 | |||
114 | If it fits into the frame pointer chain, we print it without a question | ||
115 | mark, knowing that it's part of the real backtrace. | ||
116 | |||
117 | If the address does not fit into our expected frame pointer chain we | ||
118 | still print it, but we print a '?'. It can mean two things: | ||
119 | |||
120 | - either the address is not part of the call chain: it's just stale | ||
121 | values on the kernel stack, from earlier function calls. This is | ||
122 | the common case. | ||
123 | |||
124 | - or it is part of the call chain, but the frame pointer was not set | ||
125 | up properly within the function, so we don't recognize it. | ||
126 | |||
127 | This way we will always print out the real call chain (plus a few more | ||
128 | entries), regardless of whether the frame pointer was set up correctly | ||
129 | or not - but in most cases we'll get the call chain right as well. The | ||
130 | entries printed are strictly in stack order, so you can deduce more | ||
131 | information from that as well. | ||
132 | |||
133 | The most important property of this method is that we _never_ lose | ||
134 | information: we always strive to print _all_ addresses on the stack(s) | ||
135 | that look like kernel text addresses, so if debug information is wrong, | ||
136 | we still print out the real call chain as well - just with more question | ||
137 | marks than ideal. | ||
138 | |||
139 | [*] For things like IRQ and IST stacks, we also scan those stacks, in | ||
140 | the right order, and try to cross from one stack into another | ||
141 | reconstructing the call chain. This works most of the time. | ||