ref: a7081490dbeda19788e6374a080ee38606aa3cd3
parent: 635cb9e7425577dae44eb415ad42e8d3892850b5
author: glenda <glenda@9front.local>
date: Tue May 13 21:33:55 EDT 2025
kernel: get rid of Proc.kstack The kernel stack is now above the Proc structure, so the explicit kstack pointer can be eliminated.
--- a/sys/src/9/bcm/arch.c
+++ b/sys/src/9/bcm/arch.c
@@ -68,7 +68,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr)entry;
- p->sched.sp = (uintptr)p->kstack+KSTACK;
+ p->sched.sp = (uintptr)p;
}
/*
--- a/sys/src/9/bcm/trap.c
+++ b/sys/src/9/bcm/trap.c
@@ -138,7 +138,7 @@
assert(!islo());
if(up != nil)
- rem = ((char*)ureg)-up->kstack;
+ rem = ((char*)ureg)-((char*)up - KSTACK);
else
rem = ((char*)ureg)-((char*)m+sizeof(Mach));
if(rem < 256) {
@@ -343,14 +343,14 @@
ureg->pc, ureg->sp, ureg->r14);
delay(2000);
i = 0;
- if(up != nil && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ if(up != nil && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
else{
if(up != nil)
- iprint("&up->kstack %#p &l %#p\n", up->kstack, &l);
+ iprint("&up %#p &l %#p\n", up, &l);
else
iprint("&m %#p &l %#p\n", m, &l);
return;
@@ -420,10 +420,9 @@
iprint("pc %#lux link %#lux\n", ureg->pc, ureg->link);
if(up)
- iprint("user stack: %#p-%#p\n", up->kstack, up->kstack+KSTACK-4);
+ iprint("user stack: %#p-%#p\n", (char*)up - KSTACK, up);
else
- iprint("kernel stack: %8.8lux-%8.8lux\n",
- (ulong)(m+1), (ulong)m+BY2PG-4);
+ iprint("kernel stack: %8.8lux-%8.8lux\n", (ulong)(m+1), (ulong)m+BY2PG);
dumplongs("stack", (ulong *)(ureg + 1), 16);
delay(2000);
dumpstack();
--- a/sys/src/9/bcm64/trap.c
+++ b/sys/src/9/bcm64/trap.c
@@ -566,7 +566,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr) entry;
- p->sched.sp = (uintptr) p->kstack + KSTACK - 16;
+ p->sched.sp = (uintptr) p - 16;
*(void**)p->sched.sp = kprocchild; /* fake */
}
@@ -576,7 +576,7 @@
Ureg *cureg;
p->sched.pc = (uintptr) forkret;
- p->sched.sp = (uintptr) p->kstack + KSTACK - TRAPFRAMESIZE;
+ p->sched.sp = (uintptr) p - TRAPFRAMESIZE;
cureg = (Ureg*) (p->sched.sp + 16);
memmove(cureg, ureg, sizeof(Ureg));
@@ -661,12 +661,12 @@
sp = (uintptr)&ureg;
estack = (uintptr)m+MACHSIZE;
- if(up != nil && sp <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ if(up != nil && sp <= (uintptr)up)
+ estack = (uintptr)up;
if(sp > estack){
if(up != nil)
- iprint("&up->kstack %#p sp %#p\n", up->kstack, sp);
+ iprint("&up %#p sp %#p\n", up, sp);
else
iprint("&m %#p sp %#p\n", m, sp);
return;
--- a/sys/src/9/cycv/trap.c
+++ b/sys/src/9/cycv/trap.c
@@ -26,9 +26,9 @@
x += iprint("ktrace /arm/9cycv %.8lux %.8lux %.8lux <<EOF\n", ureg->pc, ureg->sp, ureg->r14);
i = 0;
if(up
- && (uintptr)&l >= (uintptr)up->kstack
- && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ && (uintptr)&l >= (uintptr)up - KSTACK
+ && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
@@ -522,7 +522,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr) entry;
- p->sched.sp = (uintptr) p->kstack + KSTACK;
+ p->sched.sp = (uintptr) p;
}
void
@@ -531,7 +531,7 @@
Ureg *cureg;
p->sched.pc = (uintptr) forkret;
- p->sched.sp = (uintptr) p->kstack + KSTACK - sizeof(Ureg);
+ p->sched.sp = (uintptr) p - sizeof(Ureg);
cureg = (Ureg*) p->sched.sp;
memmove(cureg, ureg, sizeof(Ureg));
--- a/sys/src/9/imx8/trap.c
+++ b/sys/src/9/imx8/trap.c
@@ -566,7 +566,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr) entry;
- p->sched.sp = (uintptr) p->kstack + KSTACK - 16;
+ p->sched.sp = (uintptr) p - 16;
*(void**)p->sched.sp = kprocchild; /* fake */
}
@@ -576,7 +576,7 @@
Ureg *cureg;
p->sched.pc = (uintptr) forkret;
- p->sched.sp = (uintptr) p->kstack + KSTACK - TRAPFRAMESIZE;
+ p->sched.sp = (uintptr) p - TRAPFRAMESIZE;
cureg = (Ureg*) (p->sched.sp + 16);
memmove(cureg, ureg, sizeof(Ureg));
@@ -661,12 +661,12 @@
sp = (uintptr)&ureg;
estack = (uintptr)m+MACHSIZE;
- if(up != nil && sp <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ if(up != nil && sp <= (uintptr)up)
+ estack = (uintptr)up;
if(sp > estack){
if(up != nil)
- iprint("&up->kstack %#p sp %#p\n", up->kstack, sp);
+ iprint("&up %#p sp %#p\n", up, sp);
else
iprint("&m %#p sp %#p\n", m, sp);
return;
--- a/sys/src/9/kw/arch.c
+++ b/sys/src/9/kw/arch.c
@@ -68,7 +68,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr)entry;
- p->sched.sp = (uintptr)p->kstack+KSTACK;
+ p->sched.sp = (uintptr)p;
}
/*
--- a/sys/src/9/kw/syscall.c
+++ b/sys/src/9/kw/syscall.c
@@ -314,7 +314,7 @@
Ureg *cureg;
//print("%lud setting up for forking child %lud\n", up->pid, p->pid);
- p->sched.sp = (ulong)p->kstack+KSTACK-sizeof(Ureg);
+ p->sched.sp = (ulong)p-sizeof(Ureg);
p->sched.pc = (ulong)forkret;
cureg = (Ureg*)(p->sched.sp);
--- a/sys/src/9/kw/trap.c
+++ b/sys/src/9/kw/trap.c
@@ -367,7 +367,7 @@
char buf[ERRMAX];
if(up != nil)
- rem = (char*)ureg - up->kstack;
+ rem = (char*)ureg - ((char*)up - KSTACK);
else
rem = (char*)ureg - ((char*)m + sizeof(Mach));
if(rem < 256) {
@@ -540,14 +540,14 @@
ureg->pc, ureg->sp, ureg->r14);
delay(2000);
i = 0;
- if(up != nil && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ if(up != nil && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
else{
if(up != nil)
- iprint("&up->kstack %#p &l %#p\n", up->kstack, &l);
+ iprint("&up %#p &l %#p\n", up, &l);
else
iprint("&m %#p &l %#p\n", m, &l);
return;
@@ -617,10 +617,9 @@
iprint("pc %#lux link %#lux\n", ureg->pc, ureg->link);
if(up)
- iprint("user stack: %#p-%#p\n", up->kstack, up->kstack+KSTACK-4);
+ iprint("user stack: %#p-%#p\n", (char*)up - KSTACK, up);
else
- iprint("kernel stack: %8.8lux-%8.8lux\n",
- (ulong)(m+1), (ulong)m+BY2PG-4);
+ iprint("kernel stack: %8.8lux-%8.8lux\n", (ulong)(m+1), (ulong)m+BY2PG);
dumplongs("stack", (ulong *)(ureg + 1), 16);
delay(2000);
dumpstack();
--- a/sys/src/9/mtx/l.s
+++ b/sys/src/9/mtx/l.s
@@ -412,9 +412,7 @@
RLWNM $0, R1, $~KZERO, R1 /* PADDR(m->) */
MOVW 8(R1), R1 /* m->proc */
RLWNM $0, R1, $~KZERO, R1 /* PADDR(m->proc) */
- MOVW 8(R1), R1 /* m->proc->kstack */
- RLWNM $0, R1, $~KZERO, R1 /* PADDR(m->proc->kstack) */
- ADD $(KSTACK-UREGSIZE), R1
+ SUB $UREGSIZE, R1 /* make room on stack */
MOVW R0, R2
BL saveureg(SB)
BL trap(SB)
--- a/sys/src/9/mtx/trap.c
+++ b/sys/src/9/mtx/trap.c
@@ -450,8 +450,8 @@
sl = el-KSTACK;
}
else{
- sl = (ulong)up->kstack;
- el = sl + KSTACK;
+ el = (ulong)up;
+ sl = el-KSTACK;
}
if(l > el || l < sl){
el = (ulong)m+BY2PG;
@@ -488,7 +488,7 @@
if(up) {
print("registers for %s %ld\n", up->text, up->pid);
if((ur->srr1 & MSR_PR) == 0)
- if(ur->usp < (ulong)up->kstack || ur->usp > (ulong)up->kstack+KSTACK)
+ if(ur->usp < (ulong)up - KSTACK || ur->usp > (ulong)up)
print("invalid stack ptr\n");
}
else
@@ -504,7 +504,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (ulong)entry;
- p->sched.sp = (ulong)p->kstack+KSTACK;
+ p->sched.sp = (ulong)p;
}
/*
@@ -540,7 +540,7 @@
{
Ureg *cur;
- p->sched.sp = (ulong)p->kstack+KSTACK-UREGSIZE;
+ p->sched.sp = (ulong)p - UREGSIZE;
p->sched.pc = (ulong)forkret;
cur = (Ureg*)(p->sched.sp+2*BY2WD);
--- a/sys/src/9/omap/arch.c
+++ b/sys/src/9/omap/arch.c
@@ -68,7 +68,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr)entry;
- p->sched.sp = (uintptr)p->kstack+KSTACK;
+ p->sched.sp = (uintptr)p;
}
/*
--- a/sys/src/9/omap/syscall.c
+++ b/sys/src/9/omap/syscall.c
@@ -311,7 +311,7 @@
Ureg *cureg;
//print("%lud setting up for forking child %lud\n", up->pid, p->pid);
- p->sched.sp = (ulong)p->kstack+KSTACK-sizeof(Ureg);
+ p->sched.sp = (ulong)p-sizeof(Ureg);
p->sched.pc = (ulong)forkret;
cureg = (Ureg*)(p->sched.sp);
--- a/sys/src/9/omap/trap.c
+++ b/sys/src/9/omap/trap.c
@@ -453,7 +453,7 @@
splhi(); /* paranoia */
if(up != nil)
- rem = ((char*)ureg)-up->kstack;
+ rem = ((char*)ureg)-((char*)up-KSTACK);
else
rem = ((char*)ureg)-((char*)m+sizeof(Mach));
if(rem < 1024) {
@@ -663,9 +663,9 @@
delay(20);
i = 0;
if(up
- && (uintptr)&l >= (uintptr)up->kstack
- && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ && (uintptr)&l >= (uintptr)up - KSTACK
+ && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -298,9 +298,9 @@
pdb = tmpmap(proc->mmupdb);
pdb[PDX(MACHADDR)] = m->pdb[PDX(MACHADDR)];
tmpunmap(pdb);
- taskswitch(proc->mmupdb->pa, (ulong)(proc->kstack+KSTACK));
+ taskswitch(proc->mmupdb->pa, (ulong)proc);
}else
- taskswitch(PADDR(m->pdb), (ulong)(proc->kstack+KSTACK));
+ taskswitch(PADDR(m->pdb), (ulong)proc);
memmove(&m->gdt[PROCSEG0], proc->gdt, sizeof(proc->gdt));
if((x = (ulong)proc->ldt) && (n = proc->nldt) > 0){
--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -293,9 +293,9 @@
x += iprint("ktrace /kernel/path %.8lux %.8lux <<EOF\n", ureg->pc, ureg->sp);
i = 0;
if(up
- && (uintptr)&l >= (uintptr)up->kstack
- && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ && (uintptr)&l >= (uintptr)up - KSTACK
+ && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
@@ -775,7 +775,7 @@
* to linkproc().
*/
p->sched.pc = (ulong)entry;
- p->sched.sp = (ulong)p->kstack+KSTACK-BY2WD;
+ p->sched.sp = (ulong)p - BY2WD;
}
void
@@ -788,7 +788,7 @@
* - the return PC
* - trap's argument (ur)
*/
- p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Ureg)+2*BY2WD);
+ p->sched.sp = (ulong)p - (sizeof(Ureg)+2*BY2WD);
p->sched.pc = (ulong)forkret;
cureg = (Ureg*)(p->sched.sp+2*BY2WD);
--- a/sys/src/9/pc64/l.s
+++ b/sys/src/9/pc64/l.s
@@ -918,10 +918,9 @@
TEXT syscallentry(SB), 1, $-4
SWAPGS
BYTE $0x65; MOVQ 0, AX /* m-> (MOVQ GS:0x0, AX) */
- MOVQ 16(AX), BX /* m->proc */
+ MOVQ 16(AX), BX
MOVQ SP, R13
- MOVQ 16(BX), SP /* m->proc->kstack */
- ADDQ $KSTACK, SP
+ MOVQ BX, SP
PUSHQ $UDSEL /* old stack segment */
PUSHQ R13 /* old sp */
--- a/sys/src/9/pc64/mmu.c
+++ b/sys/src/9/pc64/mmu.c
@@ -471,7 +471,7 @@
m->mmumap[p->index/MAPBITS] |= 1ull<<(p->index%MAPBITS);
m->pml4[p->index] = PADDR(p->page) | PTEUSER|PTEWRITE|PTEVALID;
}
- taskswitch((uintptr)proc->kstack+KSTACK);
+ taskswitch((uintptr)proc);
}
void
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -255,9 +255,9 @@
x += iprint("ktrace /kernel/path %#p %#p <<EOF\n", ureg->pc, ureg->sp);
i = 0;
if(up
- && (uintptr)&l >= (uintptr)up->kstack
- && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ && (uintptr)&l >= (uintptr)up - KSTACK
+ && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
@@ -762,7 +762,7 @@
* to linkproc().
*/
p->sched.pc = (uintptr)entry;
- p->sched.sp = (uintptr)p->kstack+KSTACK-BY2WD;
+ p->sched.sp = (uintptr)p - BY2WD;
}
void
@@ -775,7 +775,7 @@
* - the return PC
* - trap's argument (ur)
*/
- p->sched.sp = (uintptr)p->kstack+KSTACK-(sizeof(Ureg)+2*BY2WD);
+ p->sched.sp = (uintptr)p - (sizeof(Ureg)+2*BY2WD);
p->sched.pc = (uintptr)forkret;
cureg = (Ureg*)(p->sched.sp+2*BY2WD);
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -653,7 +653,7 @@
struct Proc
{
Label sched; /* known to l.s */
- char *kstack; /* known to l.s */
+
Mach *mach; /* machine running this proc */
char *text;
char *user;
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -648,7 +648,6 @@
}
p = (Proc*)(b + KSTACK);
p->index = procalloc.nextindex++;
- p->kstack = b;
procalloc.tab[p->index] = p;
}
procalloc.free = p->qnext;
--- a/sys/src/9/ppc/l.s
+++ b/sys/src/9/ppc/l.s
@@ -523,9 +523,7 @@
MOVW $MACHPADDR, R1 /* PADDR(m->) */
MOVW 8(R1), R1 /* m->proc */
RLWNM $0, R1, $~KZERO, R1 /* PADDR(m->proc) */
- MOVW 8(R1), R1 /* m->proc->kstack */
- RLWNM $0, R1, $~KZERO, R1 /* PADDR(m->proc->kstack) */
- ADD $(KSTACK-UREGSIZE), R1 /* make room on stack */
+ SUB $UREGSIZE, R1 /* make room on stack */
BL saveureg(SB)
BL trap(SB)
--- a/sys/src/9/ppc/trap.c
+++ b/sys/src/9/ppc/trap.c
@@ -424,8 +424,8 @@
sl = el-KSTACK;
}
else{
- sl = (ulong)up->kstack;
- el = sl + KSTACK;
+ el = (ulong)up;
+ sl = el-KSTACK;
}
if(l > el || l < sl){
el = (ulong)m+BY2PG;
@@ -462,7 +462,7 @@
if(up) {
print("registers for %s %ld\n", up->text, up->pid);
if((ur->srr1 & MSR_PR) == 0)
- if(ur->usp < (ulong)up->kstack || ur->usp > (ulong)up->kstack+KSTACK)
+ if(ur->usp < (ulong)up - KSTACK || ur->usp > (ulong)up)
print("invalid stack ptr\n");
}
else
@@ -480,7 +480,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (ulong)entry;
- p->sched.sp = (ulong)p->kstack+KSTACK;
+ p->sched.sp = (ulong)p;
}
/*
@@ -517,7 +517,7 @@
{
Ureg *cur;
- p->sched.sp = (ulong)p->kstack+KSTACK-UREGSIZE;
+ p->sched.sp = (ulong)p - UREGSIZE;
p->sched.pc = (ulong)forkret;
cur = (Ureg*)(p->sched.sp+2*BY2WD);
--- a/sys/src/9/sgi/l.s
+++ b/sys/src/9/sgi/l.s
@@ -442,8 +442,6 @@
wasuser: /* get kernel stack for this user process */
GETMACH (SP)
MOVW 8(SP), SP /* m->proc */
- MOVW 8(SP), SP /* m->proc->kstack */
- ADDU $(KSTACK-UREGSIZE), SP
dosave:
MOVW R31, 0x28(SP)
--- a/sys/src/9/sgi/main.c
+++ b/sys/src/9/sgi/main.c
@@ -321,7 +321,7 @@
}
void
-procrestore(Proc *p)
+procrestore(Proc *)
{
}
--- a/sys/src/9/sgi/trap.c
+++ b/sys/src/9/sgi/trap.c
@@ -160,7 +160,7 @@
char buf[2*ERRMAX], buf1[ERRMAX], *fpexcep;
static int dumps;
- if (up && (char *)(ur) - up->kstack < 1024 && dumps++ == 0) {
+ if (up && (char *)(ur) - ((char *)up - KSTACK) < 1024 && dumps++ == 0) {
iprint("trap: proc %ld kernel stack getting full\n", up->pid);
dumpregs(ur);
dumpstack();
@@ -421,7 +421,7 @@
if(up == nil)
top = (ulong)MACHADDR + MACHSIZE;
else
- top = (ulong)up->kstack + KSTACK;
+ top = (ulong)up;
i = 0;
for(l=ureg->sp; l < top; l += BY2WD) {
v = *(ulong*)l;
@@ -764,7 +764,7 @@
{
Ureg *cur;
- p->sched.sp = (ulong)p->kstack+KSTACK-UREGSIZE;
+ p->sched.sp = (ulong)p - UREGSIZE;
p->sched.pc = (ulong)forkret;
cur = (Ureg*)(p->sched.sp+2*BY2WD);
@@ -780,7 +780,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (ulong)entry;
- p->sched.sp = (ulong)p->kstack+KSTACK;
+ p->sched.sp = (ulong)p;
}
/* set up user registers before return from exec() */
--- a/sys/src/9/teg2/arch.c
+++ b/sys/src/9/teg2/arch.c
@@ -68,7 +68,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr)entry;
- p->sched.sp = (uintptr)p->kstack+KSTACK;
+ p->sched.sp = (uintptr)p;
}
/*
--- a/sys/src/9/teg2/syscall.c
+++ b/sys/src/9/teg2/syscall.c
@@ -342,7 +342,7 @@
{
Ureg *cureg;
- p->sched.sp = (ulong)p->kstack+KSTACK-sizeof(Ureg);
+ p->sched.sp = (ulong)p - sizeof(Ureg);
p->sched.pc = (ulong)forkret;
cureg = (Ureg*)(p->sched.sp);
--- a/sys/src/9/teg2/trap.c
+++ b/sys/src/9/teg2/trap.c
@@ -819,7 +819,7 @@
splhi(); /* paranoia */
if(up != nil)
- rem = ((char*)ureg)-up->kstack;
+ rem = ((char*)ureg)-((char*)up-KSTACK);
else
rem = ((char*)ureg)-((char*)m+sizeof(Mach));
if(rem < 1024) {
@@ -957,9 +957,9 @@
delay(20);
i = 0;
if(up
- && (uintptr)&l >= (uintptr)up->kstack
- && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ && (uintptr)&l >= (uintptr)up - KSTACK
+ && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
--- a/sys/src/9/xen/mmu.c
+++ b/sys/src/9/xen/mmu.c
@@ -237,10 +237,10 @@
//XXX doesn't work for some reason, but it's not needed for uniprocessor
//pdb = (ulong*)proc->mmupdb->va;
//xenupdate(&pdb[PDX(MACHADDR)], m->pdb[PDX(MACHADDR)]);
- taskswitch(proc->mmupdb, (ulong)(proc->kstack+KSTACK));
+ taskswitch(proc->mmupdb, (ulong)proc);
}
else
- taskswitch(0, (ulong)(proc->kstack+KSTACK));
+ taskswitch(0, (ulong)proc);
}
void
--- a/sys/src/9/xen/trap.c
+++ b/sys/src/9/xen/trap.c
@@ -263,9 +263,9 @@
x += print("ktrace /kernel/path %.8lux %.8lux <<EOF\n", ureg->pc, ureg->sp);
i = 0;
if(up
- && (ulong)&l >= (ulong)up->kstack
- && (ulong)&l <= (ulong)up->kstack+KSTACK)
- estack = (ulong)up->kstack+KSTACK;
+ && (ulong)&l >= (ulong)up - KSTACK
+ && (ulong)&l <= (ulong)up)
+ estack = (ulong)up;
else if((ulong)&l >= (ulong)m->stack
&& (ulong)&l <= (ulong)m+BY2PG)
estack = (ulong)m+MACHSIZE;
@@ -710,7 +710,7 @@
* to linkproc().
*/
p->sched.pc = (ulong)entry;
- p->sched.sp = (ulong)p->kstack+KSTACK-BY2WD;
+ p->sched.sp = (ulong)p - BY2WD;
}
void
@@ -723,7 +723,7 @@
* - the return PC
* - trap's argument (ur)
*/
- p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Ureg)+2*BY2WD);
+ p->sched.sp = (ulong)p - (sizeof(Ureg)+2*BY2WD);
p->sched.pc = (ulong)forkret;
cureg = (Ureg*)(p->sched.sp+2*BY2WD);
--- a/sys/src/9/zynq/trap.c
+++ b/sys/src/9/zynq/trap.c
@@ -26,9 +26,9 @@
x += iprint("ktrace /arm/9zynq %.8lux %.8lux %.8lux <<EOF\n", ureg->pc, ureg->sp, ureg->r14);
i = 0;
if(up
- && (uintptr)&l >= (uintptr)up->kstack
- && (uintptr)&l <= (uintptr)up->kstack+KSTACK)
- estack = (uintptr)up->kstack+KSTACK;
+ && (uintptr)&l >= (uintptr)up - KSTACK
+ && (uintptr)&l <= (uintptr)up)
+ estack = (uintptr)up;
else if((uintptr)&l >= (uintptr)m->stack
&& (uintptr)&l <= (uintptr)m+MACHSIZE)
estack = (uintptr)m+MACHSIZE;
@@ -521,7 +521,7 @@
kprocchild(Proc *p, void (*entry)(void))
{
p->sched.pc = (uintptr) entry;
- p->sched.sp = (uintptr) p->kstack + KSTACK;
+ p->sched.sp = (uintptr) p;
}
void
@@ -530,7 +530,7 @@
Ureg *cureg;
p->sched.pc = (uintptr) forkret;
- p->sched.sp = (uintptr) p->kstack + KSTACK - sizeof(Ureg);
+ p->sched.sp = (uintptr) p - sizeof(Ureg);
cureg = (Ureg*) p->sched.sp;
memmove(cureg, ureg, sizeof(Ureg));