x86/asm/entry: Simplify task_pt_regs() macro definition

Before this change, task_pt_regs() was using KSTK_TOP(),
and it was the only use of that macro. In turn, KSTK_TOP used
THREAD_SIZE_LONGS, and it was the only use of that macro too.

Fold these macros into task_pt_regs(). Tweak comment
about "- 8" - we now use a symbolic constant, not literal 8.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
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: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1426255743-5394-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Denys Vlasenko 2015-03-13 15:09:03 +01:00 committed by Ingo Molnar
parent 76e4c4908a
commit 5c39403e00
1 changed files with 6 additions and 14 deletions

View File

@ -847,15 +847,8 @@ static inline void spin_lock_prefetch(const void *x)
extern unsigned long thread_saved_pc(struct task_struct *tsk); extern unsigned long thread_saved_pc(struct task_struct *tsk);
#define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
#define KSTK_TOP(info) \
({ \
unsigned long *__ptr = (unsigned long *)(info); \
(unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
})
/* /*
* The below -8 is to reserve 8 bytes on top of the ring0 stack. * TOP_OF_KERNEL_STACK_PADDING reserves 8 bytes on top of the ring0 stack.
* This is necessary to guarantee that the entire "struct pt_regs" * This is necessary to guarantee that the entire "struct pt_regs"
* is accessible even if the CPU haven't stored the SS/ESP registers * is accessible even if the CPU haven't stored the SS/ESP registers
* on the stack (interrupt gate does not save these registers * on the stack (interrupt gate does not save these registers
@ -866,10 +859,9 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
*/ */
#define task_pt_regs(task) \ #define task_pt_regs(task) \
({ \ ({ \
struct pt_regs *__regs__; \ unsigned long __ptr = (unsigned long)task_stack_page(task); \
__regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task)) - \ __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \
TOP_OF_KERNEL_STACK_PADDING); \ ((struct pt_regs *)__ptr) - 1; \
__regs__ - 1; \
}) })
#define KSTK_ESP(task) (task_pt_regs(task)->sp) #define KSTK_ESP(task) (task_pt_regs(task)->sp)