Save and restore user processes' FS and GS registers.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 9 Jan 2005 08:03:38 +0000 (08:03 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 9 Jan 2005 08:03:38 +0000 (08:03 +0000)
TODO
src/threads/interrupt.h
src/threads/intr-stubs.pl
src/userprog/process.c

diff --git a/TODO b/TODO
index b4e216e1288f0ced59b414d8979ce303c0771099..15902a2cd3db19fd7e77209b9d82127190a96759 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,15 +1,5 @@
 -*- text -*-
 
-* FS and GS:
-
-  - struct intr_frame: Add members.
-  
-  - intr_entry(): Save, reset.
-
-  - intr_exit(): Restore.
-
-  - execute_thread(): Initialize.
-
 * Userprog project:
 
   - Move `join' implementation here, from `threads' project, to help
index d54b7ef0893ff4caff7af5883d47b7c123fcd0d8..99abf8e3a92ddecff94064dd7bbaf5f0086e774d 100644 (file)
@@ -29,6 +29,8 @@ struct intr_frame
     uint32_t edx;               /* Saved EDX. */
     uint32_t ecx;               /* Saved ECX. */
     uint32_t eax;               /* Saved EAX. */
+    uint16_t gs, :16;           /* Saved GS segment register. */
+    uint16_t fs, :16;           /* Saved FS segment register. */
     uint16_t es, :16;           /* Saved ES segment register. */
     uint16_t ds, :16;           /* Saved DS segment register. */
 
index a5ad9b0514bd251f5aec0ab9222d659c503a9c64..75cde7b6bb8cdf2629357beef89886a00d6eb1ea 100755 (executable)
@@ -35,6 +35,8 @@ intr_entry:
        # Save caller's registers.
        push ds
        push es
+       push fs
+       push gs
        pusha
 
        # Set up kernel environment.
@@ -53,6 +55,8 @@ intr_entry:
 intr_exit:
        # Restore caller's registers.
        popa
+       pop gs
+       pop fs
        pop es
        pop ds
        add esp, 8
index b9a199e64063f395924b535bfc545b4207cb4e4a..c0a6547acb0e09a7717d43ab8fb7199e8ae7248b 100644 (file)
@@ -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;