vserver 1.9.3
[linux-2.6.git] / arch / ia64 / ia32 / ia32_ldt.c
index 4cc8242..a152738 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 Hewlett-Packard Co
+ * Copyright (C) 2001, 2004 Hewlett-Packard Co
  *     David Mosberger-Tang <davidm@hpl.hp.com>
  *
  * Adapted from arch/i386/kernel/ldt.c
 
 #include "ia32priv.h"
 
-#define P(p)   ((void *) (unsigned long) (p))
-
 /*
  * read_ldt() is not really atomic - this is not a problem since synchronization of reads
  * and writes done to the LDT has to be assured by user-space anyway. Writes are atomic,
  * to protect the security checks done on new descriptors.
  */
 static int
-read_ldt (void *ptr, unsigned long bytecount)
+read_ldt (void __user *ptr, unsigned long bytecount)
 {
-       char *src, *dst, buf[256];      /* temporary buffer (don't overflow kernel stack!) */
        unsigned long bytes_left, n;
+       char __user *src, *dst;
+       char buf[256];  /* temporary buffer (don't overflow kernel stack!) */
 
        if (bytecount > IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE)
                bytecount = IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE;
 
        bytes_left = bytecount;
 
-       src = (void *) IA32_LDT_OFFSET;
+       src = (void __user *) IA32_LDT_OFFSET;
        dst = ptr;
 
        while (bytes_left) {
@@ -61,7 +60,7 @@ read_ldt (void *ptr, unsigned long bytecount)
 }
 
 static int
-read_default_ldt (void * ptr, unsigned long bytecount)
+read_default_ldt (void __user * ptr, unsigned long bytecount)
 {
        unsigned long size;
        int err;
@@ -80,7 +79,7 @@ read_default_ldt (void * ptr, unsigned long bytecount)
 }
 
 static int
-write_ldt (void * ptr, unsigned long bytecount, int oldmode)
+write_ldt (void __user * ptr, unsigned long bytecount, int oldmode)
 {
        struct ia32_user_desc ldt_info;
        __u64 entry;
@@ -120,7 +119,7 @@ write_ldt (void * ptr, unsigned long bytecount, int oldmode)
         * memory, but we still need to guard against out-of-memory, hence we must use
         * put_user().
         */
-       ret = __put_user(entry, (__u64 *) IA32_LDT_OFFSET + ldt_info.entry_number);
+       ret = __put_user(entry, (__u64 __user *) IA32_LDT_OFFSET + ldt_info.entry_number);
        ia32_load_segment_descriptors(current);
        return ret;
 }
@@ -132,16 +131,16 @@ sys32_modify_ldt (int func, unsigned int ptr, unsigned int bytecount)
 
        switch (func) {
              case 0:
-               ret = read_ldt(P(ptr), bytecount);
+               ret = read_ldt(compat_ptr(ptr), bytecount);
                break;
              case 1:
-               ret = write_ldt(P(ptr), bytecount, 1);
+               ret = write_ldt(compat_ptr(ptr), bytecount, 1);
                break;
              case 2:
-               ret = read_default_ldt(P(ptr), bytecount);
+               ret = read_default_ldt(compat_ptr(ptr), bytecount);
                break;
              case 0x11:
-               ret = write_ldt(P(ptr), bytecount, 0);
+               ret = write_ldt(compat_ptr(ptr), bytecount, 0);
                break;
        }
        return ret;