One way of supporting a guard page below kstack: allocate kstacks in
procinit() and map them high up (below TRAMPOLNE) with an empty mapping below each stack. Never free a kernel stack. Another way would be to allocate and map them dynamically, but then we need to reload page table when switching processes in scheduler() and/or have a kernel pagetable per proc (if we want k->stack to be the same virtual address in each process). One gotcha: kernel addresses are not equal to physical addresses for stack addresses. A stack address must be translated if we need its physical address (e.g., virtio passes a stack address to the disk).
This commit is contained in:
parent
b924e44f06
commit
9156632701
5 changed files with 42 additions and 14 deletions
|
|
@ -193,6 +193,8 @@ uint64 walkaddr(pagetable_t, uint64);
|
|||
int copyout(pagetable_t, uint64, char *, uint64);
|
||||
int copyin(pagetable_t, char *, uint64, uint64);
|
||||
int copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max);
|
||||
char* map_kstack();
|
||||
uint64 kernelpa(uint64);
|
||||
|
||||
// plic.c
|
||||
void plicinit(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue