summaryrefslogtreecommitdiff
path: root/sys/arch/i386/include
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-03-12 03:52:27 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-03-12 03:52:27 +0000
commitc62a833c3eed0faa13ce022b6d4eee3119bffd85 (patch)
treecf68d2b3fbd1afd58c33da5d40eee730557be64e /sys/arch/i386/include
parentcd06312d1f6bdbfe322dd8bf9ada43332f0d48e3 (diff)
Provide distinct segments for the %fs and %gs selectors to use by
default, with per-rthread base offsets and with sysarch() functions, I386_{GET,SET}_{FS,GS}BASE, for fetching and setting those base offsets. This is necessary for both rthread and Linux compat support. suggestions from kettenis@, prodding from pirofti@ and deraadt@
Diffstat (limited to 'sys/arch/i386/include')
-rw-r--r--sys/arch/i386/include/pcb.h12
-rw-r--r--sys/arch/i386/include/segments.h9
-rw-r--r--sys/arch/i386/include/sysarch.h10
3 files changed, 22 insertions, 9 deletions
diff --git a/sys/arch/i386/include/pcb.h b/sys/arch/i386/include/pcb.h
index fa3623eafad..66c1b816a63 100644
--- a/sys/arch/i386/include/pcb.h
+++ b/sys/arch/i386/include/pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcb.h,v 1.14 2007/10/03 07:51:26 kettenis Exp $ */
+/* $OpenBSD: pcb.h,v 1.15 2011/03/12 03:52:26 guenther Exp $ */
/* $NetBSD: pcb.h,v 1.21 1996/01/08 13:51:42 mycroft Exp $ */
/*-
@@ -59,13 +59,13 @@ struct pcb {
#define pcb_ebp pcb_tss.tss_ebp
#define pcb_cs pcb_tss.tss_cs
#define pcb_ldt_sel pcb_tss.tss_ldt
- int pcb_tss_sel;
union descriptor *pcb_ldt; /* per process (user) LDT */
int pcb_ldt_len; /* number of LDT entries */
- int pcb_cr0; /* saved image of CR0 */
- int pcb_pad[2]; /* savefpu on 16-byte boundary */
union savefpu pcb_savefpu; /* floating point state for FPU */
+ int pcb_cr0; /* saved image of CR0 */
struct emcsts pcb_saveemc; /* Cyrix EMC state */
+ struct segment_descriptor pcb_threadsegs[2];
+ /* per-thread descriptors */
/*
* Software pcb (extension)
*/
@@ -81,6 +81,10 @@ struct pcb {
#define PCB_SAVECTX 0x00000001
};
+/* the indexes of the %fs/%gs segments in pcb_threadsegs */
+#define TSEG_FS 0
+#define TSEG_GS 1
+
/*
* The pcb is augmented with machine-dependent additional data for
* core dumps. For the i386, there is nothing to add.
diff --git a/sys/arch/i386/include/segments.h b/sys/arch/i386/include/segments.h
index a6932a4e0fd..1a56a1887e2 100644
--- a/sys/arch/i386/include/segments.h
+++ b/sys/arch/i386/include/segments.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: segments.h,v 1.18 2010/12/24 20:26:30 tedu Exp $ */
+/* $OpenBSD: segments.h,v 1.19 2011/03/12 03:52:26 guenther Exp $ */
/* $NetBSD: segments.h,v 1.23 1996/02/01 22:31:03 mycroft Exp $ */
/*-
@@ -215,15 +215,16 @@ void idt_vec_free(int);
#define GCODE_SEL 1 /* Kernel code descriptor */
#define GDATA_SEL 2 /* Kernel data descriptor */
#define GLDT_SEL 3 /* Default LDT descriptor */
-#define GUCODE1_SEL 4 /* User code descriptor */
+#define GCPU_SEL 4 /* per-CPU segment */
#define GUCODE_SEL 5 /* User code descriptor (a stack short) */
#define GUDATA_SEL 6 /* User data descriptor */
#define GAPM32CODE_SEL 7 /* 32 bit APM code descriptor */
#define GAPM16CODE_SEL 8 /* 16 bit APM code descriptor */
#define GAPMDATA_SEL 9 /* APM data descriptor */
#define GICODE_SEL 10 /* Interrupt code descriptor (same as Kernel code) */
-#define GCPU_SEL 11 /* per-CPU segment */
-#define NGDT 12
+#define GUFS_SEL 11 /* User per-thread (%fs) descriptor */
+#define GUGS_SEL 12 /* User per-thread (%gs) descriptor */
+#define NGDT 13
/*
* Entries in the Local Descriptor Table (LDT)
diff --git a/sys/arch/i386/include/sysarch.h b/sys/arch/i386/include/sysarch.h
index cae749a2b53..1115026c63d 100644
--- a/sys/arch/i386/include/sysarch.h
+++ b/sys/arch/i386/include/sysarch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysarch.h,v 1.5 2004/09/15 18:46:50 deraadt Exp $ */
+/* $OpenBSD: sysarch.h,v 1.6 2011/03/12 03:52:26 guenther Exp $ */
/* $NetBSD: sysarch.h,v 1.8 1996/01/08 13:51:44 mycroft Exp $ */
#ifndef _I386_SYSARCH_H_
@@ -13,6 +13,10 @@
#define I386_GET_IOPERM 3
#define I386_SET_IOPERM 4
#define I386_VM86 5
+#define I386_GET_FSBASE 6
+#define I386_SET_FSBASE 7
+#define I386_GET_GSBASE 8
+#define I386_SET_GSBASE 9
struct i386_get_ldt_args {
int start;
@@ -44,6 +48,10 @@ int i386_set_ldt(int, union descriptor *, int);
int i386_iopl(int);
int i386_get_ioperm(u_long *);
int i386_set_ioperm(u_long *);
+int i386_get_fsbase(void **);
+int i386_set_fsbase(void *);
+int i386_get_gsbase(void **);
+int i386_set_gsbase(void *);
int sysarch(int, void *);
#endif