From 0132e7fed0ee48dae66607fbccd7c0ab1acea45e Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 4 Apr 2019 15:21:25 +0200 Subject: [PATCH] pc64: get rid of TSTKTOP, USTKTOP is the end of user address space the temporary stack segment used to be at a fixed address above or below the user stack. these days, the temp stack is mapped dynamically by sysexec so TSTKTOP is obsolete. --- sys/src/9/pc64/mem.h | 3 +-- sys/src/9/pc64/mmu.c | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/src/9/pc64/mem.h b/sys/src/9/pc64/mem.h index e2d93cc4a..42a3a119a 100644 --- a/sys/src/9/pc64/mem.h +++ b/sys/src/9/pc64/mem.h @@ -44,9 +44,8 @@ */ #define UTZERO (0x0000000000200000ull) /* first address in user text */ #define UADDRMASK (0x00007fffffffffffull) /* canonical address mask */ -#define TSTKTOP (0x00007ffffffff000ull) +#define USTKTOP (0x00007ffffffff000ull) #define USTKSIZE (16*MiB) /* size of user stack */ -#define USTKTOP (TSTKTOP-USTKSIZE) /* end of new stack in sysexec */ /* * Address spaces. Kernel, sorted by address. diff --git a/sys/src/9/pc64/mmu.c b/sys/src/9/pc64/mmu.c index 02f96d55a..45bc76d40 100644 --- a/sys/src/9/pc64/mmu.c +++ b/sys/src/9/pc64/mmu.c @@ -221,12 +221,12 @@ mmucreate(uintptr *table, uintptr va, int level, int index) flags = PTEWRITE|PTEVALID; if(va < VMAP){ assert(up != nil); - assert((va < TSTKTOP) || (va >= KMAP && va < KMAP+KMAPSIZE)); + assert((va < USTKTOP) || (va >= KMAP && va < KMAP+KMAPSIZE)); p = mmualloc(); p->index = index; p->level = level; - if(va < TSTKTOP){ + if(va < USTKTOP){ flags |= PTEUSER; if(level == PML4E){ if((p->next = up->mmuhead) == nil) @@ -341,9 +341,9 @@ mmuzap(void) /* common case */ pte[PTLX(UTZERO, 3)] = 0; - pte[PTLX(TSTKTOP, 3)] = 0; + pte[PTLX(USTKTOP-1, 3)] = 0; m->mmumap[PTLX(UTZERO, 3)/MAPBITS] &= ~(1ull<<(PTLX(UTZERO, 3)%MAPBITS)); - m->mmumap[PTLX(TSTKTOP, 3)/MAPBITS] &= ~(1ull<<(PTLX(TSTKTOP, 3)%MAPBITS)); + m->mmumap[PTLX(USTKTOP-1, 3)/MAPBITS] &= ~(1ull<<(PTLX(USTKTOP-1, 3)%MAPBITS)); for(i = 0; i < nelem(m->mmumap); pte += MAPBITS, i++){ if((w = m->mmumap[i]) == 0)