From ef0bb54192a7eab2103f17a50eb209fa8e372f69 Mon Sep 17 00:00:00 2001 From: fvdl Date: Mon, 13 Oct 2003 18:40:16 +0000 Subject: [PATCH] Define a few macros to validate userspace selectors. --- sys/arch/amd64/include/segments.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/arch/amd64/include/segments.h b/sys/arch/amd64/include/segments.h index 6a41ac95534e..797026d91676 100644 --- a/sys/arch/amd64/include/segments.h +++ b/sys/arch/amd64/include/segments.h @@ -1,4 +1,4 @@ -/* $NetBSD: segments.h,v 1.2 2003/08/07 16:26:36 agc Exp $ */ +/* $NetBSD: segments.h,v 1.3 2003/10/13 18:40:16 fvdl Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -333,4 +333,19 @@ void cpu_init_idt __P((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_ */