Skip to content

Commit ce26ebc

Browse files
reduce our stack and guard it
1 parent 5c5f0cf commit ce26ebc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#error "Bit-field layout assumed: x86_64 little-endian."
1313
#endif
1414

15-
#define KSTACK_SIZE (32ULL * 1024ULL * 1024ULL) /* 32 MiB */
15+
#define KSTACK_SIZE (1 * 1024 * 1024) /* 1 MB */
1616
#define KSTACK_MASK (~(KSTACK_SIZE - 1ULL))
1717

1818
#define kprintf(fmt, ...) \

src/gdt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extern volatile struct limine_kernel_file_request rr_kfile_req;
3838

3939
struct reqset request_addresses(void) {
4040
static struct {
41-
uintptr_t arr[11];
41+
uintptr_t arr[12];
4242
} buf; /* backing storage, static so it survives return */
4343

4444
buf.arr[0] = (uintptr_t)limine_gdtr;
@@ -53,6 +53,10 @@ struct reqset request_addresses(void) {
5353
buf.arr[9] = (uintptr_t)hhdm_request.response - hhdm_request.response->offset;
5454
buf.arr[10] = (uintptr_t)stack_size_request.response - hhdm_request.response->offset;
5555

56+
uintptr_t rsp_va;
57+
__asm__ volatile ("mov %%rsp, %0" : "=r"(rsp_va));
58+
buf.arr[11] = rsp_va - 16 - (uintptr_t)hhdm_request.response->offset;
59+
5660
return (struct reqset){
5761
buf.arr,
5862
sizeof(buf.arr) / sizeof(buf.arr[0])

0 commit comments

Comments
 (0)