so, i thought about this a bit, and i think the extra flexablity
and generality of finding a hole in the process' address space
for ESEG doesn't pay—too fancy.  moving TSTK above
the normal stack so TSTK is not in normally adressable space,
seems more natural.

for nix this results in a trivial diff

/n/dump/2013/0316/sys/src/nix/k10/mem.h:60,68 - /sys/src/nix/k10/mem.h:60,68
   */
  #define UTZERO                (0+2*MiB)               /* first address in 
user text */
  #define UTROUND(t)    ROUNDUP((t), BIGPGSZ)
- #define USTKTOP               (0x00007ffffffff000ull & ~(BIGPGSZ-1))
+ #define TSTKTOP               (0x00007ffffffff000ull & ~(BIGPGSZ-1))
  #define USTKSIZE              (16*1024*1024)          /* size of user stack */
- #define TSTKTOP               (USTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
+ #define USTKTOP               (TSTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
  
  
  /*

it's a little more intricate for the 9 kernels, as they aren't quite as
tidy.  but still, there are just a few extra bits.

it is probablly a good idea to rid ourselves of TSTKSIZE as it's not
needed anymore.

- erik


diff -c /n/dump/2013/0316/sys/src/9/bcm/mmu.c bcm/mmu.c
/n/dump/2013/0316/sys/src/9/bcm/mmu.c:12,18 - bcm/mmu.c:12,18
  
  enum {
        L1lo            = UZERO/MiB,            /* L1X(UZERO)? */
-       L1hi            = (USTKTOP+MiB-1)/MiB,  /* L1X(USTKTOP+MiB-1)? */
+       L1hi            = (TSTKTOP+MiB-1)/MiB,  /* L1X(TSTKTOP+MiB-1)? */
  };
  
  void
diff -c /n/dump/2013/0316/sys/src/9/kw/mmu.c kw/mmu.c
/n/dump/2013/0316/sys/src/9/kw/mmu.c:12,18 - kw/mmu.c:12,18
  
  enum {
        L1lo            = UZERO/MiB,            /* L1X(UZERO)? */
-       L1hi            = (USTKTOP+MiB-1)/MiB,  /* L1X(USTKTOP+MiB-1)? */
+       L1hi            = (TSTKTOP+MiB-1)/MiB,  /* L1X(TSTKTOP+MiB-1)? */
  };
  
  #define ISHOLE(pte)   ((pte) == 0)
diff -c /n/dump/2013/0316/sys/src/9/omap/mmu.c omap/mmu.c
/n/dump/2013/0316/sys/src/9/omap/mmu.c:11,17 - omap/mmu.c:11,17
  
  enum {
        L1lo            = UZERO/MiB,            /* L1X(UZERO)? */
-       L1hi            = (USTKTOP+MiB-1)/MiB,  /* L1X(USTKTOP+MiB-1)? */
+       L1hi            = (TSTKTOP+MiB-1)/MiB,  /* L1X(TSTKTOP+MiB-1)? */
  };
  
  #define ISHOLE(pte)   ((pte) == 0)
diff -c /n/dump/2013/0316/sys/src/9/teg2/mmu.c teg2/mmu.c
/n/dump/2013/0316/sys/src/9/teg2/mmu.c:23,29 - teg2/mmu.c:23,29
  
        L1lo            = UZERO/MiB,            /* L1X(UZERO)? */
  #ifdef SMALL_ARM                              /* well under 1GB of RAM? */
-       L1hi            = (USTKTOP+MiB-1)/MiB,  /* L1X(USTKTOP+MiB-1)? */
+       L1hi            = (TSTKTOP+MiB-1)/MiB,  /* L1X(TSTKTOP+MiB-1)? */
  #else
        /*
         * on trimslice, top of 1GB ram can't be addressible, as high
diff -c /n/dump/2013/0316/sys/src/9/bcm/mem.h bcm/mem.h
/n/dump/2013/0316/sys/src/9/bcm/mem.h:51,59 - bcm/mem.h:51,59
  
  #define       UZERO           0                       /* user segment */
  #define       UTZERO          (UZERO+BY2PG)           /* user text start */
- #define       USTKTOP         0x20000000                      /* user segment 
end +1 */
+ #define       TSTKTOP         0x20000000                      /* user segment 
end +1 */
  #define       USTKSIZE        (8*1024*1024)           /* user stack size */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
  #define       TSTKSIZ         256
  
  /* address at which to copy and execute rebootcode */
diff -c /n/dump/2013/0316/sys/src/9/bitsy/mem.h bitsy/mem.h
/n/dump/2013/0316/sys/src/9/bitsy/mem.h:60,68 - bitsy/mem.h:60,68
  #define       UCDRAMTOP       0xD0000000              /* ... */
  #define       NULLZERO        0xE0000000              /* 128 meg for cache 
flush zeroes */
  #define       NULLTOP         0xE8000000              /* ... */
- #define       USTKTOP         0x2000000               /* byte just beyond 
user stack */
+ #define       TSTKTOP         0x2000000               /* byte just beyond 
user stack */
  #define       USTKSIZE                (8*1024*1024)           /* size of user 
stack */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
  #define       TSTKSIZ         100
  #define       MACHADDR        (KZERO+0x00001000)
  #define       EVECTORS        0xFFFF0000              /* virt base of 
exception vectors */
diff -c /n/dump/2013/0316/sys/src/9/kw/mem.h kw/mem.h
/n/dump/2013/0316/sys/src/9/kw/mem.h:69,77 - kw/mem.h:69,77
  
  #define       UZERO           0                       /* user segment */
  #define       UTZERO          (UZERO+BY2PG)           /* user text start */
- #define       USTKTOP         KZERO                   /* user segment end +1 
*/
+ #define       TSTKTOP         KZERO                   /* user segment end +1 
*/
  #define       USTKSIZE        (8*1024*1024)           /* user stack size */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
  #define       TSTKSIZ         256
  
  /* address at which to copy and execute rebootcode */
diff -c /n/dump/2013/0316/sys/src/9/omap/mem.h omap/mem.h
/n/dump/2013/0316/sys/src/9/omap/mem.h:73,81 - omap/mem.h:73,81
  #define       UTZERO          (UZERO+BY2PG)           /* user text start */
  #define UTROUND(t)    ROUNDUP((t), BY2PG)
  /* moved USTKTOP down to 512MB to keep MMIO space out of user space. */
- #define       USTKTOP         0x20000000              /* user segment end +1 
*/
+ #define       TSTKTOP         0x20000000              /* user segment end +1 
*/
  #define       USTKSIZE        (8*1024*1024)           /* user stack size */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
  #define       TSTKSIZ         256
  
  /* address at which to copy and execute rebootcode */
diff -c /n/dump/2013/0316/sys/src/9/pc/mem.h pc/mem.h
/n/dump/2013/0316/sys/src/9/pc/mem.h:61,69 - pc/mem.h:61,69
  #define       VMAPSIZE        (0x10000000-VPTSIZE-KMAPSIZE)
  #define       UZERO           0                       /* base of user address 
space */
  #define       UTZERO          (UZERO+BY2PG)           /* first address in 
user text */
- #define       USTKTOP         (VMAP-BY2PG)            /* byte just beyond 
user stack */
+ #define       TSTKTOP         (VMAP-BY2PG)            /* byte just beyond 
user stack */
  #define       USTKSIZE        (16*1024*1024)          /* size of user stack */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
  #define       TSTKSIZ         256     /* pages in new stack; limits exec args 
*/
  
  /*
diff -c /n/dump/2013/0316/sys/src/9/pcpae/mem.h pcpae/mem.h
/n/dump/2013/0316/sys/src/9/pcpae/mem.h:61,69 - pcpae/mem.h:61,69
  #define       VMAPSIZE        (0x10000000-VPTSIZE-KMAPSIZE-KXMAPSIZE)
  #define       UZERO           0                       /* base of user address 
space */
  #define       UTZERO          (UZERO+BY2PG)           /* first address in 
user text */
- #define       USTKTOP         (VMAP-BY2PG)            /* byte just beyond 
user stack */
+ #define       TSTKTOP         (VMAP-BY2PG)            /* byte just beyond 
user stack */
  #define       USTKSIZE        (16*1024*1024)          /* size of user stack */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* end of new stack in 
sysexec */
  #define       TSTKSIZ         256                     /* pages in new stack; 
limits exec args */
  
  /*
diff -c /n/dump/2013/0316/sys/src/9/teg2/mem.h teg2/mem.h
/n/dump/2013/0316/sys/src/9/teg2/mem.h:91,99 - teg2/mem.h:91,99
   * moved it down another MB to utterly avoid KADDR(stack_base) mapping
   * to high exception vectors.  see confinit().
   */
- #define       USTKTOP         (0x40000000 - 64*KiB - MiB) /* user segment end 
+1 */
+ #define       TSTKTOP         (0x40000000 - 64*KiB - MiB) /* user segment end 
+1 */
  #define       USTKSIZE        (8*1024*1024)           /* user stack size */
- #define       TSTKTOP         (USTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
+ #define       USTKTOP         (TSTKTOP-USTKSIZE)      /* sysexec temporary 
stack */
  #define       TSTKSIZ         256
  
  /* address at which to copy and execute rebootcode */

Reply via email to