From 178d79bccdc97cdaf346a7b87de769a4896df7eb Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Wed, 4 Sep 2024 09:52:19 -0600 Subject: [PATCH] [kernel] Calculate then reduce kernel temp startup stack size --- elks/arch/i86/kernel/Makefile | 2 +- elks/arch/i86/kernel/divzero.c | 2 +- elks/arch/i86/kernel/irq.c | 7 +++++-- elks/arch/i86/kernel/irqtab.S | 4 +++- elks/arch/i86/kernel/strace.c | 15 +++++++++++++++ elks/include/arch/segment.h | 1 + elks/include/linuxmt/limits.h | 1 + elks/include/linuxmt/trace.h | 5 +++-- 8 files changed, 30 insertions(+), 7 deletions(-) diff --git a/elks/arch/i86/kernel/Makefile b/elks/arch/i86/kernel/Makefile index 9872fa287..81cf65ab5 100644 --- a/elks/arch/i86/kernel/Makefile +++ b/elks/arch/i86/kernel/Makefile @@ -40,7 +40,7 @@ OBJS = strace.o system.o irq.o irqtab.o process.o \ ifeq ($(CONFIG_ARCH_IBMPC), y) OBJS += irq-8259.o timer-8254.o -#OBJS += divzero.o +OBJS += divzero.o endif ifeq ($(CONFIG_ARCH_PC98), y) diff --git a/elks/arch/i86/kernel/divzero.c b/elks/arch/i86/kernel/divzero.c index 2fc76d0e1..efee180aa 100644 --- a/elks/arch/i86/kernel/divzero.c +++ b/elks/arch/i86/kernel/divzero.c @@ -8,7 +8,7 @@ * 19 Aug 24 Greg Haerr */ -static char div0msg[] = { "Divide by zero\n" }; +static char div0msg[] = { "Divide fault\n" }; void div0_handler(int i, struct pt_regs *regs) { diff --git a/elks/arch/i86/kernel/irq.c b/elks/arch/i86/kernel/irq.c index c44217ef5..66aef3853 100644 --- a/elks/arch/i86/kernel/irq.c +++ b/elks/arch/i86/kernel/irq.c @@ -125,12 +125,15 @@ void INITPROC irq_init(void) #ifdef CONFIG_ARCH_IBMPC /* catch INT 0 divide by zero/divide overflow hardware fault */ - /*irq_action[IDX_DIVZERO] = div0_handler; - int_handler_add(IDX_DIVZERO, 0x00, _irqit);*/ +#if 1 /* install direct panic-only DIV fault handler until known that * the _irqit version doesn't overwrite the stack */ int_handler_add(IDX_DIVZERO, 0x00, div0_handler_panic); +#else + irq_action[IDX_DIVZERO] = div0_handler; + int_handler_add(IDX_DIVZERO, 0x00, _irqit); +#endif #endif #if defined(CONFIG_TIMER_INT0F) || defined(CONFIG_TIMER_INT1C) diff --git a/elks/arch/i86/kernel/irqtab.S b/elks/arch/i86/kernel/irqtab.S index d6c0cb7a3..88645ba87 100644 --- a/elks/arch/i86/kernel/irqtab.S +++ b/elks/arch/i86/kernel/irqtab.S @@ -424,6 +424,7 @@ div0_handler_panic: .data .global _gint_count .global endistack + .global endtstack .global istack .global tstack .extern current @@ -445,5 +446,6 @@ endistack: .skip ISTACK_BYTES,0 // interrupt stack istack: - .skip 256,0 // startup temp stack +endtstack: + .skip TSTACK_BYTES,0 // startup temp stack tstack: diff --git a/elks/arch/i86/kernel/strace.c b/elks/arch/i86/kernel/strace.c index 865aae091..f85044d06 100644 --- a/elks/arch/i86/kernel/strace.c +++ b/elks/arch/i86/kernel/strace.c @@ -183,4 +183,19 @@ void trace_end(unsigned int retval) check_kstack(n); } +#if UNUSED +void check_tstack(void) +{ + int i; + + /* calc temp stack usage */ + for (i=0; i