]> Devi Nivas Git - cs3210-lab1.git/commitdiff
yank out stack overflow checking ugliness
authorrsc <rsc>
Thu, 27 Sep 2007 20:38:53 +0000 (20:38 +0000)
committerrsc <rsc>
Thu, 27 Sep 2007 20:38:53 +0000 (20:38 +0000)
main.c
proc.c
proc.h
swtch.S

diff --git a/main.c b/main.c
index 464112bb29ad74582e6e4a7b30ef09cff6ae11b8..b48923172b08e14108016c73101f189212ee6641 100644 (file)
--- a/main.c
+++ b/main.c
@@ -60,7 +60,6 @@ mpmain(void)
   if(cpu() != mp_bcpu())
     lapic_init(cpu());
   setupsegs(0);
-  asm volatile("movl %0, %%ss" :: "r" (SEG_CPUSTACK << 3));
   cpuid(0, 0, 0, 0, 0);  // memory barrier
   cpus[cpu()].booted = 1;
   popcli();
diff --git a/proc.c b/proc.c
index e139c3907cab1494b2f524c05650277155004bbc..b009892846e3587d151dbd6c4b742537b5c16241 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -73,7 +73,7 @@ setupsegs(struct proc *p)
   
   pushcli();
   c = &cpus[cpu()];
-  c->ts.ss0 = SEG_PROCSTACK << 3;
+  c->ts.ss0 = SEG_KDATA << 3;
   if(p)
     c->ts.esp0 = (uint)(p->kstack + KSTACKSIZE);
   else
@@ -84,15 +84,12 @@ setupsegs(struct proc *p)
   c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
   c->gdt[SEG_TSS] = SEG16(STS_T32A, (uint)&c->ts, sizeof(c->ts)-1, 0);
   c->gdt[SEG_TSS].s = 0;
-  c->gdt[SEG_CPUSTACK] = SEG(STA_W|STA_E, 0, (uint)c->stack, 0);
   if(p){
     c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, (uint)p->mem, p->sz-1, DPL_USER);
     c->gdt[SEG_UDATA] = SEG(STA_W, (uint)p->mem, p->sz-1, DPL_USER);
-    c->gdt[SEG_PROCSTACK] = SEG(STA_W|STA_E, 0, (uint)p->kstack, 0);
   } else {
     c->gdt[SEG_UCODE] = SEG_NULL;
     c->gdt[SEG_UDATA] = SEG_NULL;
-    c->gdt[SEG_PROCSTACK] = SEG_NULL;
   }
 
   lgdt(c->gdt, sizeof(c->gdt));
@@ -143,7 +140,6 @@ copyproc(struct proc *p)
   memset(&np->context, 0, sizeof(np->context));
   np->context.eip = (uint)forkret;
   np->context.esp = (uint)np->tf;
-  np->context.ss = SEG_PROCSTACK<<3;
 
   // Clear %eax so that fork system call returns 0 in child.
   np->tf->eax = 0;
diff --git a/proc.h b/proc.h
index 2063baa23e45dd4b71cb74bf02f0b226c49d204e..36913c461e9ed4801e7cf94a16275e791f7913c3 100644 (file)
--- a/proc.h
+++ b/proc.h
@@ -4,9 +4,7 @@
 #define SEG_UCODE 3
 #define SEG_UDATA 4
 #define SEG_TSS   5  // this process's task state
-#define SEG_CPUSTACK 6
-#define SEG_PROCSTACK 7
-#define NSEGS     8
+#define NSEGS     6
 
 // Saved registers for kernel context switches.
 // Don't need to save all the %fs etc. segment registers,
@@ -24,7 +22,6 @@ struct context {
   int esi;
   int edi;
   int ebp;
-  int ss;
 };
 
 enum proc_state { UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE };
diff --git a/swtch.S b/swtch.S
index 8aa4c2edcc7ac684b9ae42170acfa34d136f6ebc..786e9ac3c1e3de377c349f08b86fc61fc416ee6b 100644 (file)
--- a/swtch.S
+++ b/swtch.S
@@ -16,14 +16,10 @@ swtch:
   movl %esi, 20(%eax)
   movl %edi, 24(%eax)
   movl %ebp, 28(%eax)
-  movl %ss, %ebx
-  movl %ebx, 32(%eax)
 
   # Load new registers
   movl 4(%esp), %eax  # not 8(%esp) - popped return address above
 
-  movl 32(%eax), %ebx
-  movl %ebx, %ss
   movl 28(%eax), %ebp
   movl 24(%eax), %edi
   movl 20(%eax), %esi