summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/sysarch.h
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2003-05-12 02:37:29 +0000
committerpeter <peter@FreeBSD.org>2003-05-12 02:37:29 +0000
commitc688fcc3ca312086f910aab7cdf045d92c0c364f (patch)
tree64ee040db2f5653c25d9bdeca46546a3cf5d954b /sys/amd64/include/sysarch.h
parent6d94cd1e18844aefcc39c20d259853511b278015 (diff)
downloadFreeBSD-src-c688fcc3ca312086f910aab7cdf045d92c0c364f.zip
FreeBSD-src-c688fcc3ca312086f910aab7cdf045d92c0c364f.tar.gz
Give a %fs and %gs to userland. Use swapgs to obtain the kernel %GS.base
value on entry and exit. This isn't as easy as it sounds because when we recursively trap or interrupt, we have to avoid duplicating the swapgs instruction or we end up back with the userland %gs. I implemented this by testing TF_CS to see if we're coming from supervisor mode already, and check for returning to supervisor. To avoid a race with interrupts in the brief period after beginning executing the handler and before the swapgs, convert all trap gates to interrupt gates, and reenable interrupts immediately after the swapgs. I am not happy with this. There are other possible ways to do this that should be investigated. (eg: storing the GS.base MSR value in the trapframe) Add some sysarch functions to let the userland code get to this. Approved by: re (blanket amd64/*)
Diffstat (limited to 'sys/amd64/include/sysarch.h')
-rw-r--r--sys/amd64/include/sysarch.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/amd64/include/sysarch.h b/sys/amd64/include/sysarch.h
index c33f7b8..f14ee31 100644
--- a/sys/amd64/include/sysarch.h
+++ b/sys/amd64/include/sysarch.h
@@ -34,9 +34,27 @@
*/
/*
- * Architecture specific syscalls (i386)
+ * Architecture specific syscalls (AMD64)
*/
#ifndef _MACHINE_SYSARCH_H_
#define _MACHINE_SYSARCH_H_
+#define AMD64_GET_FSBASE 0
+#define AMD64_SET_FSBASE 1
+#define AMD64_GET_GSBASE 2
+#define AMD64_SET_GSBASE 3
+
+#if 0 /* these wrappers need to be implemented in libc first */
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+unsigned long amd64_get_fsbase(void);
+unsigned long amd64_set_fsbase(unsigned long);
+unsigned long amd64_get_gsbase(void);
+unsigned long amd64_set_gsbase(unsigned long);
+__END_DECLS
+#endif
+#endif
+
#endif /* !_MACHINE_SYSARCH_H_ */
OpenPOWER on IntegriCloud