Commit f96489a2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] cleanup patch that prepares for 4Kb stacks

From: Arjan van de Ven <arjanv@redhat.com>

I have 4Kb stacks + IRQ stacks working in my tree.  The biggest part of the
4K-stacks work is changing hardcoded 8Kb assumptions to the proper,
pre-existing define for this.  That part of the patch is appropriate in
general, even when 4Kb stacks might not be.
parent 0c39a2fa
......@@ -515,8 +515,8 @@ ENTRY(nmi)
/* Do not access memory above the end of our stack page,
* it might not exist.
*/
andl $0x1fff,%eax
cmpl $0x1fec,%eax
andl $(THREAD_SIZE-1),%eax
cmpl $(THREAD_SIZE-20),%eax
popl %eax
jae nmi_stack_correct
cmpl $sysenter_entry,12(%esp)
......
......@@ -16,6 +16,8 @@
#include <asm/pgtable.h>
#include <asm/desc.h>
#include <asm/cache.h>
#include <asm/thread_info.h>
#define OLD_CL_MAGIC_ADDR 0x90020
#define OLD_CL_MAGIC 0xA33F
......@@ -325,7 +327,7 @@ rp_sidt:
ret
ENTRY(stack_start)
.long init_thread_union+8192
.long init_thread_union+THREAD_SIZE
.long __BOOT_DS
/* This is the default interrupt "handler" :-) */
......
......@@ -435,7 +435,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
long esp;
__asm__ __volatile__("andl %%esp,%0" :
"=r" (esp) : "0" (8191));
"=r" (esp) : "0" (THREAD_SIZE - 1));
if (unlikely(esp < (sizeof(struct thread_info) + 1024))) {
printk("do_IRQ: stack overflow: %ld\n",
esp - sizeof(struct thread_info));
......
......@@ -637,6 +637,8 @@ extern void scheduling_functions_start_here(void);
extern void scheduling_functions_end_here(void);
#define first_sched ((unsigned long) scheduling_functions_start_here)
#define last_sched ((unsigned long) scheduling_functions_end_here)
#define top_esp (THREAD_SIZE - sizeof(unsigned long))
#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long))
unsigned long get_wchan(struct task_struct *p)
{
......@@ -647,12 +649,12 @@ unsigned long get_wchan(struct task_struct *p)
return 0;
stack_page = (unsigned long)p->thread_info;
esp = p->thread.esp;
if (!stack_page || esp < stack_page || esp > 8188+stack_page)
if (!stack_page || esp < stack_page || esp > top_esp+stack_page)
return 0;
/* include/asm-i386/system.h:switch_to() pushes ebp last. */
ebp = *(unsigned long *) esp;
do {
if (ebp < stack_page || ebp > 8184+stack_page)
if (ebp < stack_page || ebp > top_ebp+stack_page)
return 0;
eip = *(unsigned long *) (ebp+4);
if (eip < first_sched || eip >= last_sched)
......
......@@ -119,7 +119,7 @@ void show_trace_task(struct task_struct *tsk)
unsigned long esp = tsk->thread.esp;
/* User space on another CPU? */
if ((esp ^ (unsigned long)tsk->thread_info) & (PAGE_MASK<<1))
if ((esp ^ (unsigned long)tsk->thread_info) & ~(THREAD_SIZE - 1))
return;
show_trace(tsk, (unsigned long *)esp);
}
......
......@@ -77,16 +77,17 @@ struct thread_info {
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)
#define THREAD_SIZE (2*PAGE_SIZE)
/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~8191UL));
__asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1)));
return ti;
}
/* thread information allocation */
#define THREAD_SIZE (2*PAGE_SIZE)
#define alloc_thread_info(task) ((struct thread_info *)kmalloc(THREAD_SIZE, GFP_KERNEL))
#define free_thread_info(info) kfree(info)
#define get_thread_info(ti) get_task_struct((ti)->task)
......@@ -94,9 +95,11 @@ static inline struct thread_info *current_thread_info(void)
#else /* !__ASSEMBLY__ */
#define THREAD_SIZE 8192
/* how to get the thread information struct from ASM */
#define GET_THREAD_INFO(reg) \
movl $-8192, reg; \
movl $-THREAD_SIZE, reg; \
andl %esp, reg
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment