X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fuserprog%2Fprocess.c;h=88c9d8dcae20995bb5e7dc3b4b2d5a42ca5b8e6e;hb=d80dc83cd65332de026aa01035967fc031d0f305;hp=b8d4a14462c63faecf6ac69944db4180b83d2914;hpb=d97c24e174bb94bc9ff96b0094bf25b78a576295;p=pintos-anon diff --git a/src/userprog/process.c b/src/userprog/process.c index b8d4a14..88c9d8d 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -54,6 +54,8 @@ execute_thread (void *filename_) /* Initialize interrupt frame and load executable. */ memset (&if_, 0, sizeof if_); + if_.gs = SEL_UDSEG; + if_.fs = SEL_UDSEG; if_.es = SEL_UDSEG; if_.ds = SEL_UDSEG; if_.cs = SEL_UCSEG; @@ -71,14 +73,11 @@ execute_thread (void *filename_) /* Start the user process by simulating a return from an interrupt, implemented by intr_exit (in - threads/intr-stubs.pl). Because intr_exit takes all of its + threads/intr-stubs.S). Because intr_exit takes all of its arguments on the stack in the form of a `struct intr_frame', we just point the stack pointer (%esp) to our stack frame and jump to it. */ - asm ("mov %0, %%esp\n" - "jmp intr_exit\n" - : /* no outputs */ - : "g" (&if_)); + asm ("mov %%esp, %0; jmp intr_exit" :: "g" (&if_)); NOT_REACHED (); } @@ -320,7 +319,7 @@ load_segment (struct file *file, const struct Elf32_Phdr *phdr) } /* p_offset must point within file. */ - if (phdr->p_offset < 0 || phdr->p_offset > file_length (file)) + if (phdr->p_offset > (Elf32_Off) file_length (file)) { printf ("bad p_offset %"PE32Ox, phdr->p_offset); return false;