summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2004-01-29 13:21:11 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2004-01-29 13:21:11 +0000
commit0f86c01644cc8c1781aac366d224a7646f89ba7b (patch)
tree62136ab8c3583d8fb50006dd1e348389e1addbe0 /sys/arch/amd64/include
parent714673f9240f6c880f6895bf5e164d21de275464 (diff)
check struct reg for evil; from netbsd
Diffstat (limited to 'sys/arch/amd64/include')
-rw-r--r--sys/arch/amd64/include/reg.h6
-rw-r--r--sys/arch/amd64/include/segments.h17
2 files changed, 21 insertions, 2 deletions
diff --git a/sys/arch/amd64/include/reg.h b/sys/arch/amd64/include/reg.h
index d2ab5521203..293d1fbf403 100644
--- a/sys/arch/amd64/include/reg.h
+++ b/sys/arch/amd64/include/reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: reg.h,v 1.2 2004/01/29 12:43:35 mickey Exp $ */
+/* $OpenBSD: reg.h,v 1.3 2004/01/29 13:21:10 mickey Exp $ */
/* $NetBSD: reg.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
/*-
@@ -125,4 +125,8 @@ struct fpreg {
#define fp_st fxstate.fx_st
#define fp_xmm fxstate.fx_xmm
+#ifdef _KERNEL
+int check_context(const struct reg *, struct trapframe *);
+#endif
+
#endif /* !_AMD64_REG_H_ */
diff --git a/sys/arch/amd64/include/segments.h b/sys/arch/amd64/include/segments.h
index 636f3a38fee..58890114e6a 100644
--- a/sys/arch/amd64/include/segments.h
+++ b/sys/arch/amd64/include/segments.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: segments.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: segments.h,v 1.2 2004/01/29 13:21:10 mickey Exp $ */
/* $NetBSD: segments.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
/*-
@@ -302,4 +302,19 @@ void cpu_init_idt(void);
#define LSYSRETBASE_SEL LUCODE32_SEL
+/*
+ * Checks for valid user selectors. If USER_LDT ever gets implemented
+ * for amd64, these must check the ldt length and SEL_UPL if a user
+ * ldt is active.
+ */
+#define VALID_USER_DSEL32(s) \
+ ((s) == GSEL(GUDATA32_SEL, SEL_UPL) || (s) == LSEL(LUDATA32_SEL, SEL_UPL))
+#define VALID_USER_CSEL32(s) \
+ ((s) == GSEL(GUCODE32_SEL, SEL_UPL) || (s) == LSEL(LUCODE32_SEL, SEL_UPL))
+
+#define VALID_USER_CSEL(s) \
+ ((s) == GSEL(GUCODE_SEL, SEL_UPL) || (s) == LSEL(LUCODE_SEL, SEL_UPL))
+#define VALID_USER_DSEL(s) \
+ ((s) == GSEL(GUDATA_SEL, SEL_UPL) || (s) == LSEL(LUDATA_SEL, SEL_UPL))
+
#endif /* _AMD64_SEGMENTS_H_ */