9 #include <linux/errno.h>
11 #include <linux/sched.h>
12 #include <linux/string.h>
20 #include <asm/mmu_context.h>
21 #include <asm/syscalls.h>
24 static void flush_ldt(
void *current_mm)
26 if (
current->active_mm == current_mm)
27 load_LDT(&
current->active_mm->context);
33 void *oldldt, *newldt;
36 if (mincount <= pc->
size)
53 (mincount - oldsize) * LDT_ENTRY_SIZE);
55 paravirt_alloc_ldt(newldt, mincount);
70 if (!cpumask_equal(mm_cpumask(
current->mm),
79 paravirt_free_ldt(oldldt, oldsize);
90 int err = alloc_ldt(
new, old->
size, 0);
96 for (i = 0; i < old->
size; i++)
143 static int read_ldt(
void __user *
ptr,
unsigned long bytecount)
156 if (size > bytecount)
165 if (size != bytecount) {
167 if (
clear_user(ptr + size, bytecount - size) != 0) {
177 static int read_default_ldt(
void __user *ptr,
unsigned long bytecount)
181 unsigned long size = 5 *
sizeof(
struct desc_struct);
183 unsigned long size = 128;
185 if (bytecount > size)
192 static int write_ldt(
void __user *ptr,
unsigned long bytecount,
int oldmode)
200 if (bytecount !=
sizeof(ldt_info))
207 if (ldt_info.entry_number >= LDT_ENTRIES)
209 if (ldt_info.contents == 3) {
212 if (ldt_info.seg_not_present == 0)
218 error = alloc_ldt(&
current->mm->context,
219 ldt_info.entry_number + 1, 1);
225 if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
232 fill_ldt(&
ldt, &ldt_info);
248 unsigned long bytecount)
254 ret = read_ldt(ptr, bytecount);
257 ret = write_ldt(ptr, bytecount, 1);
260 ret = read_default_ldt(ptr, bytecount);
263 ret = write_ldt(ptr, bytecount, 0);