|
ginnOS
The reference: libc, the libraries and the kernel
|
Go to the source code of this file.
Macros | |
| #define | KSTACK_GUARD_SIZE PAGE_SIZE |
| kernel stacks with guard pages. | |
Functions | |
| void | kstack_init (void) |
| reserve the kernel stack region. | |
| uintptr_t | kstack_alloc (void) |
| allocate and map a zeroed kernel stack. | |
| void | kstack_free (uintptr_t base) |
| unmap a kernel stack and return its frames and slot. | |
| bool | kstack_is_guard (uintptr_t addr) |
| check whether an address falls in the guard page of any stack slot. | |
| #define KSTACK_GUARD_SIZE PAGE_SIZE |
kernel stacks with guard pages.
every process's kernel stack lives in a fixed virtual region (KSTACK_REGION_BASE) split into one slot per process. a slot is an unmapped guard page followed by KERNEL_STACK_SIZE bytes of mapped stack, so running off the bottom of a stack faults on the guard page instead of silently overwriting whatever physical frame lies below it. the region's page table is reserved at boot and shared by every address space, so a stack mapped later is reachable from any process.
| void kstack_init | ( | void | ) |
reserve the kernel stack region.
must run after paging_init() and before the first address space is created (process_create()).
| uintptr_t kstack_alloc | ( | void | ) |
allocate and map a zeroed kernel stack.
| void kstack_free | ( | uintptr_t | base | ) |
unmap a kernel stack and return its frames and slot.
never free the stack the CPU is currently running on.
| base | the value kstack_alloc() returned. |