VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 8
-EXTRAVERSION = -1.521.3.planetlab
+EXTRAVERSION = -1.521.3.planetlab.2004.12.14
NAME=Zonked Quokka
# *DOCUMENTATION*
CFLAGS += -fomit-frame-pointer
endif
+ifdef CONFIG_X86_STACK_CHECK
+CFLAGS += -p
+endif
+
ifdef CONFIG_DEBUG_INFO
CFLAGS += -g
endif
The kernel will print a stack trace when the current stack exceeds
the specified size.
+config X86_STACK_CHECK
+ bool "Check for stack overflows"
+ default n
+ help
+ Say Y here to have the kernel attempt to detect when the per-task
+ kernel stack overflows.
+
+ Some older versions of gcc don't handle the -p option correctly.
+ Kernprof is affected by the same problem, which is described here:
+ http://oss.sgi.com/projects/kernprof/faq.html#Q9
+
+ Basically, if you get oopses in __free_pages_ok during boot when
+ you have this turned on, you need to fix gcc. The Redhat 2.96
+ version and gcc-3.x seem to work.
+
+ If not debugging a stack overflow problem, say N
+
+config STACK_PANIC
+ int "Panic when stack approaches with specified bytes of the stack limit"
+ depends on X86_STACK_CHECK
+ default 512 if IRQSTACKS
+ default 512
+ help
+ Panic if the stack grows to within specified byte range.
+
endmenu
if (high_loaded) close_output_buffer_if_we_run_high(mv);
return high_loaded;
}
+
+/* We don't actually check for stack overflows this early. */
+__asm__(".globl mcount ; mcount: ret\n");
pushl $do_spurious_interrupt_bug
jmp error_code
+#ifdef CONFIG_X86_STACK_CHECK
+ENTRY(mcount)
+ push %eax
+ movl $(THREAD_SIZE - 1),%eax
+ andl %esp,%eax
+ cmpl $STACK_WARN,%eax /* esp reaches into STACK_WARN space */
+ jle 1f
+2:
+ popl %eax
+ ret
+1:
+ lock; btsl $0,stack_overflowed
+ jc 2b
+
+ # switch to overflow stack
+ movl %esp,%eax
+ movl $(stack_overflow_stack + THREAD_SIZE - 4),%esp
+
+ pushf
+ cli
+ pushl %eax
+
+ # push eip then esp of error for stack_overflow_panic
+ pushl 4(%eax)
+ pushl %eax
+
+ # update the task pointer and cpu in the overflow stack's thread_info.
+ GET_THREAD_INFO_WITH_ESP(%eax)
+ movl TI_task(%eax),%ebx
+ movl %ebx,stack_overflow_stack+TI_task
+ movl TI_cpu(%eax),%ebx
+ movl %ebx,stack_overflow_stack+TI_cpu
+
+ call stack_overflow
+
+ # pop off call arguments
+ addl $8,%esp
+
+ popl %eax
+ popf
+ movl %eax,%esp
+ popl %eax
+ movl $0,stack_overflowed
+ ret
+#warning stack check enabled
+#endif
+
.previous
.data
+#ifdef CONFIG_X86_STACK_CHECK
+ .globl stack_overflowed
+stack_overflowed:
+ .long 0
+#endif
+
ENTRY(sys_call_table)
.long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
.long sys_exit
EXPORT_SYMBOL(__PAGE_KERNEL);
+#ifdef CONFIG_X86_STACK_CHECK
+extern void mcount(void);
+EXPORT_SYMBOL(mcount);
+#endif
+
+
#ifdef CONFIG_HIGHMEM
EXPORT_SYMBOL(kmap);
EXPORT_SYMBOL(kunmap);
__attribute__((__section__(".data.init_task"))) =
{ INIT_THREAD_INFO(init_task, init_thread_union) };
+#ifdef CONFIG_X86_STACK_CHECK
+union thread_union stack_overflow_stack
+ __attribute__((__section__(".data.init_task"))) =
+ { INIT_THREAD_INFO(init_task, stack_overflow_stack) };
+#endif
+
+
/*
* Initial task structure.
*
__setup("idle=", idle_setup);
+void stack_overflow(unsigned long esp, unsigned long eip)
+{
+ int panicing = ((esp&(THREAD_SIZE-1)) <= STACK_PANIC);
+
+ printk( "esp: 0x%lx masked: 0x%lx STACK_PANIC:0x%lx %d %d\n",
+ esp, (esp&(THREAD_SIZE-1)), STACK_PANIC, (((esp&(THREAD_SIZE-1)) <= STACK_PANIC)), panicing );
+
+ if (panicing)
+ print_symbol("stack overflow from %s\n", eip);
+ else
+ print_symbol("excessive stack use from %s\n", eip);
+ printk("esp: %p\n", (void*)esp);
+ show_trace(current,(void*)esp);
+
+ if (panicing)
+ panic("stack overflow\n");
+}
+
void show_regs(struct pt_regs * regs)
{
unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
CONFIG_IRQSTACKS=y
CONFIG_STACK_SIZE_SHIFT=13
CONFIG_STACK_WARN=4000
+# CONFIG_X86_STACK_CHECK is not set
+CONFIG_STACK_PANIC=512
#
# Power management options (ACPI, APM)
#define PREEMPT_ACTIVE 0x4000000
#define THREAD_SIZE (1<<CONFIG_STACK_SIZE_SHIFT)
#define STACK_WARN (CONFIG_STACK_WARN)
+#define STACK_PANIC (0x200ul)
/*
* macros/functions for gaining access to the thread information structure