From e5c7df720147528ab310fe5ac983cc5115b998da 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. --- src/threads/interrupt.h | 2 ++ src/threads/intr-stubs.pl | 4 ++++ src/userprog/process.c | 2 ++ 3 files changed, 8 insertions(+) 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