diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-03-24 14:43:11 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-24 15:57:30 -0400 |
commit | 1ddc6f3c60d75a7577dd33bc441e309febe2fc76 (patch) | |
tree | 28cae85dafae5f8454dac0328bea38cc89a72ba7 | |
parent | d56fe4bf5f3cc30d455c80520f7b71da36ae00e6 (diff) |
x86/asm/entry/64: Improve the THREAD_INFO() macro explanation
Explain the background, and add a real example.
Acked-by: Denys Vlasenko <dvlasenk@redhat.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Acked-by: Borislav Petkov <bp@suse.de>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/20150324184311.GA14760@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/thread_info.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index ad0ee3423da5..813dfbb867a7 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
@@ -206,10 +206,29 @@ static inline unsigned long current_stack_pointer(void) | |||
206 | _ASM_SUB $(THREAD_SIZE),reg ; | 206 | _ASM_SUB $(THREAD_SIZE),reg ; |
207 | 207 | ||
208 | /* | 208 | /* |
209 | * ASM operand which evaluates to thread_info address | 209 | * ASM operand which evaluates to a 'thread_info' address of |
210 | * if it is known that "reg" is exactly "off" bytes below stack top. | 210 | * the current task, if it is known that "reg" is exactly "off" |
211 | * Example (fetch thread_info->fieldname): | 211 | * bytes below the top of the stack currently. |
212 | * mov TI_fieldname+THREAD_INFO(reg, off),%eax | 212 | * |
213 | * ( The kernel stack's size is known at build time, it is usually | ||
214 | * 2 or 4 pages, and the bottom of the kernel stack contains | ||
215 | * the thread_info structure. So to access the thread_info very | ||
216 | * quickly from assembly code we can calculate down from the | ||
217 | * top of the kernel stack to the bottom, using constant, | ||
218 | * build-time calculations only. ) | ||
219 | * | ||
220 | * For example, to fetch the current thread_info->flags value into %eax | ||
221 | * on x86-64 defconfig kernels, in syscall entry code where RSP is | ||
222 | * currently at exactly SIZEOF_PTREGS bytes away from the top of the | ||
223 | * stack: | ||
224 | * | ||
225 | * mov TI_flags+THREAD_INFO(%rsp, SIZEOF_PTREGS), %eax | ||
226 | * | ||
227 | * will translate to: | ||
228 | * | ||
229 | * 8b 84 24 b8 c0 ff ff mov -0x3f48(%rsp), %eax | ||
230 | * | ||
231 | * which is below the current RSP by almost 16K. | ||
213 | */ | 232 | */ |
214 | #define THREAD_INFO(reg, off) ((off)-THREAD_SIZE)(reg) | 233 | #define THREAD_INFO(reg, off) ((off)-THREAD_SIZE)(reg) |
215 | 234 | ||