From: Ben Pfaff Date: Mon, 23 Apr 2007 00:05:33 +0000 (+0000) Subject: Correctly initialize the esp0 pointer in the TSS for the initial X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58ff179ed68e25b33037ca479b0f51f8fdbec7fe;p=pintos-anon Correctly initialize the esp0 pointer in the TSS for the initial kernel thread. Shouldn't actually matter in practice, because that pointer is only used on a user->kernel transition, and the initial kernel thread never runs a user process. Reported by Godmar Back. --- diff --git a/src/userprog/process.c b/src/userprog/process.c index 781cc5d..c0e5215 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -129,7 +129,7 @@ process_activate (void) /* Set thread's kernel stack for use in processing interrupts. */ - tss_set_esp0 ((uint8_t *) t + PGSIZE); + tss_update (); } /* We load ELF binaries. The following definitions are taken diff --git a/src/userprog/tss.c b/src/userprog/tss.c index f103823..569e8d1 100644 --- a/src/userprog/tss.c +++ b/src/userprog/tss.c @@ -82,9 +82,9 @@ tss_init (void) few fields of it are ever referenced, and those are the only ones we initialize. */ tss = palloc_get_page (PAL_ASSERT | PAL_ZERO); - tss->esp0 = ptov(0x20000); tss->ss0 = SEL_KDSEG; tss->bitmap = 0xdfff; + tss_update (); } /* Returns the kernel TSS. */ @@ -95,10 +95,11 @@ tss_get (void) return tss; } -/* Sets the ring 0 stack pointer in the TSS to ESP0. */ +/* Sets the ring 0 stack pointer in the TSS to point to the end + of the thread stack. */ void -tss_set_esp0 (uint8_t *esp0) +tss_update (void) { ASSERT (tss != NULL); - tss->esp0 = esp0; + tss->esp0 = (uint8_t *) thread_current () + PGSIZE; } diff --git a/src/userprog/tss.h b/src/userprog/tss.h index fa8d47b..467bd19 100644 --- a/src/userprog/tss.h +++ b/src/userprog/tss.h @@ -6,6 +6,6 @@ struct tss; void tss_init (void); struct tss *tss_get (void); -void tss_set_esp0 (uint8_t *); +void tss_update (void); #endif /* userprog/tss.h */