From 90284ecf98313edfd34d8e3f30a2b00a0065bf38 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 9 Jan 2005 08:03:38 +0000 Subject: [PATCH] Save and restore user processes' FS and GS registers. --- TODO | 10 ---------- src/threads/interrupt.h | 2 ++ src/threads/intr-stubs.pl | 4 ++++ src/userprog/process.c | 2 ++ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index b4e216e..15902a2 100644 --- 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 diff --git a/src/threads/interrupt.h b/src/threads/interrupt.h index d54b7ef..99abf8e 100644 --- a/src/threads/interrupt.h +++ b/src/threads/interrupt.h @@ -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. */ diff --git a/src/threads/intr-stubs.pl b/src/threads/intr-stubs.pl index a5ad9b0..75cde7b 100755 --- a/src/threads/intr-stubs.pl +++ b/src/threads/intr-stubs.pl @@ -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 diff --git a/src/userprog/process.c b/src/userprog/process.c index b9a199e..c0a6547 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; -- 2.30.2