summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <rsc>2009-05-31 01:12:08 +0000
committerrsc <rsc>2009-05-31 01:12:08 +0000
commit7b644318dd3b17fe5ec0229db956119986082738 (patch)
tree1e60a8628081eb2833a58d73903ff1fd7f6a1bbe
parente97519a6d2efd56eb5b5ff2e4c4b20048a33c7af (diff)
downloadxv6-labs-7b644318dd3b17fe5ec0229db956119986082738.tar.gz
xv6-labs-7b644318dd3b17fe5ec0229db956119986082738.tar.bz2
xv6-labs-7b644318dd3b17fe5ec0229db956119986082738.zip
clean up %fs %gs use
-rw-r--r--bootasm.S3
-rw-r--r--proc.c2
-rw-r--r--trapasm.S3
-rw-r--r--x86.h5
4 files changed, 5 insertions, 8 deletions
diff --git a/bootasm.S b/bootasm.S
index 9c4a9b2..4b2e012 100644
--- a/bootasm.S
+++ b/bootasm.S
@@ -7,7 +7,6 @@
#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
-#define SEG_KCPU 3 // kernel per-cpu data
#define CR0_PE 1 // protected mode enable bit
@@ -63,7 +62,7 @@ start32:
movw %ax, %ds # -> DS: Data Segment
movw %ax, %es # -> ES: Extra Segment
movw %ax, %ss # -> SS: Stack Segment
- movw $(SEG_KCPU<<3), %ax # Our per-cpu segment selector
+ movw $0, %ax # Zero segments not ready for use
movw %ax, %fs # -> FS
movw %ax, %gs # -> GS
diff --git a/proc.c b/proc.c
index a2aeab2..dd7d881 100644
--- a/proc.c
+++ b/proc.c
@@ -93,9 +93,9 @@ ksegment(void)
c1->gdt[SEG_UDATA] = SEG_NULL;
c1->gdt[SEG_TSS] = SEG_NULL;
lgdt(c1->gdt, sizeof(c1->gdt));
+ loadfsgs(SEG_KCPU << 3);
// Initialize cpu-local variables.
- setgs(SEG_KCPU << 3);
c = c1;
cp = 0;
}
diff --git a/trapasm.S b/trapasm.S
index 59fca57..983163d 100644
--- a/trapasm.S
+++ b/trapasm.S
@@ -13,10 +13,7 @@ alltraps:
pushal
# Set up data and per-cpu segments.
- # Can find out KDATA from %ss.
- # Assume that KCPU is KDATA+1.
movw $(SEG_KDATA<<3), %ax
- movw %ss, %ax
movw %ax, %ds
movw %ax, %es
movw $(SEG_KCPU<<3), %ax
diff --git a/x86.h b/x86.h
index ecb5d2a..934b9ec 100644
--- a/x86.h
+++ b/x86.h
@@ -104,9 +104,10 @@ xchg(volatile uint *addr, uint newval)
}
static inline void
-setgs(ushort gs)
+loadfsgs(ushort v)
{
- asm volatile("movw %0, %%gs" : : "r" (gs));
+ asm volatile("movw %0, %%fs" : : "r" (v));
+ asm volatile("movw %0, %%gs" : : "r" (v));
}
static inline void