Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kernel] Calculate then reduce kernel temp startup stack size #1995

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elks/arch/i86/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion elks/arch/i86/kernel/divzero.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 5 additions & 2 deletions elks/arch/i86/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion elks/arch/i86/kernel/irqtab.S
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ div0_handler_panic:
.data
.global _gint_count
.global endistack
.global endtstack
.global istack
.global tstack
.extern current
Expand All @@ -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:
15 changes: 15 additions & 0 deletions elks/arch/i86/kernel/strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<TSTACK_BYTES/2; i++) {
if (endtstack[i] != 0)
break;
}
i = (TSTACK_BYTES/2 - i) << 1;
printk("tstack usage %d\n", i);
}
#endif

#endif /* CONFIG_TRACE */
1 change: 1 addition & 0 deletions elks/include/arch/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
extern seg_t kernel_cs, kernel_ds;
extern short *_endtext, *_endftext, *_enddata, *_endbss;
extern short endistack[];
extern short endtstack[];
extern unsigned int heapsize;

#endif
1 change: 1 addition & 0 deletions elks/include/linuxmt/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#endif

#define ISTACK_BYTES 512 /* Size of interrupt stack */
#define TSTACK_BYTES 128 /* Size of temp startup stack */

#define KSTACK_GUARD 100 /* bytes before CHECK_KSTACK overflow warning */

Expand Down
5 changes: 3 additions & 2 deletions elks/include/linuxmt/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
#ifndef __ASSEMBLER__
extern int tracing;

extern void trace_begin(void);
extern void trace_end(unsigned int retval);
void trace_begin(void);
void trace_end(unsigned int retval);
void check_tstack(void);
#endif

#endif
Loading