summaryrefslogtreecommitdiff
path: root/i386/i386/user_ldt.c
diff options
context:
space:
mode:
Diffstat (limited to 'i386/i386/user_ldt.c')
-rw-r--r--i386/i386/user_ldt.c72
1 files changed, 11 insertions, 61 deletions
diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c
index 74c10a4c..d8bdb90f 100644
--- a/i386/i386/user_ldt.c
+++ b/i386/i386/user_ldt.c
@@ -43,67 +43,17 @@
#include "ldt.h"
#include "vm_param.h"
-char acc_type[8][3] = {
- /* code stack data */
- { 0, 0, 1 }, /* data */
- { 0, 1, 1 }, /* data, writable */
- { 0, 0, 1 }, /* data, expand-down */
- { 0, 1, 1 }, /* data, writable, expand-down */
- { 1, 0, 0 }, /* code */
- { 1, 0, 1 }, /* code, readable */
- { 1, 0, 0 }, /* code, conforming */
- { 1, 0, 1 }, /* code, readable, conforming */
-};
-
-boolean_t selector_check(thread, sel, type)
- thread_t thread;
- int sel;
- int type; /* code, stack, data */
-{
- struct user_ldt *ldt;
- int access;
-
- ldt = thread->pcb->ims.ldt;
- if (ldt == 0) {
- switch (type) {
- case S_CODE:
- return sel == USER_CS;
- case S_STACK:
- return sel == USER_DS;
- case S_DATA:
- return sel == 0 ||
- sel == USER_CS ||
- sel == USER_DS;
- }
- }
-
- if (type != S_DATA && sel == 0)
- return FALSE;
- if ((sel & (SEL_LDT|SEL_PL)) != (SEL_LDT|SEL_PL_U)
- || sel > ldt->desc.limit_low)
- return FALSE;
-
- access = ldt->ldt[sel_idx(sel)].access;
-
- if ((access & (ACC_P|ACC_PL|ACC_TYPE_USER|SZ_64))
- != (ACC_P|ACC_PL_U|ACC_TYPE_USER))
- return FALSE;
- /* present, pl == pl.user, not system, not 64bits */
-
- return acc_type[(access & 0xe)>>1][type];
-}
-
/*
* Add the descriptors to the LDT, starting with
* the descriptor for 'first_selector'.
*/
kern_return_t
-i386_set_ldt(thread, first_selector, desc_list, count, desc_list_inline)
- thread_t thread;
- int first_selector;
- struct real_descriptor *desc_list;
- unsigned int count;
- boolean_t desc_list_inline;
+i386_set_ldt(
+ thread_t thread,
+ int first_selector,
+ struct real_descriptor *desc_list,
+ unsigned int count,
+ boolean_t desc_list_inline)
{
user_ldt_t new_ldt, old_ldt, temp;
struct real_descriptor *dp;
@@ -305,14 +255,14 @@ i386_set_ldt(thread, first_selector, desc_list, count, desc_list_inline)
kern_return_t
i386_get_ldt(thread, first_selector, selector_count, desc_list, count)
- thread_t thread;
+ const thread_t thread;
int first_selector;
int selector_count; /* number wanted */
struct real_descriptor **desc_list; /* in/out */
unsigned int *count; /* in/out */
{
struct user_ldt *user_ldt;
- pcb_t pcb = thread->pcb;
+ pcb_t pcb;
int first_desc = sel_idx(first_selector);
unsigned int ldt_count;
vm_size_t ldt_size;
@@ -326,6 +276,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count)
if (first_desc + selector_count >= 8192)
return KERN_INVALID_ARGUMENT;
+ pcb = thread->pcb;
addr = 0;
size = 0;
@@ -416,8 +367,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count)
}
void
-user_ldt_free(user_ldt)
- user_ldt_t user_ldt;
+user_ldt_free(user_ldt_t user_ldt)
{
#ifdef MACH_PV_DESCRIPTORS
int i;
@@ -481,7 +431,7 @@ i386_set_gdt (thread_t thread, int *selector, struct real_descriptor desc)
}
kern_return_t
-i386_get_gdt (thread_t thread, int selector, struct real_descriptor *desc)
+i386_get_gdt (const thread_t thread, int selector, struct real_descriptor *desc)
{
if (thread == THREAD_NULL)
return KERN_INVALID_ARGUMENT;