]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/um/sys-i386/ldt.c
Pull sgi-drivers-makefile-cleanup into release branch
[linux-2.6-omap-h63xx.git] / arch / um / sys-i386 / ldt.c
index 17746b4c08ff00afee1407018b05611e78e69bbe..1fa09a79a10b682fc74f81e9a4fcc072a5579b93 100644 (file)
@@ -16,6 +16,7 @@
 #include "choose-mode.h"
 #include "kern.h"
 #include "mode_kern.h"
+#include "os.h"
 
 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 
@@ -88,6 +89,7 @@ out:
 #include "skas.h"
 #include "skas_ptrace.h"
 #include "asm/mmu_context.h"
+#include "proc_mm.h"
 
 long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
                     void **addr, int done)
@@ -456,13 +458,14 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
        int i;
        long page, err=0;
        void *addr = NULL;
+       struct proc_mm_op copy;
 
-       memset(&desc, 0, sizeof(desc));
 
        if(!ptrace_ldt)
                init_MUTEX(&new_mm->ldt.semaphore);
 
        if(!from_mm){
+               memset(&desc, 0, sizeof(desc));
                /*
                 * We have to initialize a clean ldt.
                 */
@@ -494,8 +497,26 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
                        }
                }
                new_mm->ldt.entry_count = 0;
+
+               goto out;
        }
-       else if (!ptrace_ldt) {
+
+       if(proc_mm){
+               /* We have a valid from_mm, so we now have to copy the LDT of
+                * from_mm to new_mm, because using proc_mm an new mm with
+                * an empty/default LDT was created in new_mm()
+                */
+               copy = ((struct proc_mm_op) { .op       = MM_COPY_SEGMENTS,
+                                             .u        =
+                                             { .copy_segments =
+                                                       from_mm->id.u.mm_fd } } );
+               i = os_write_file(new_mm->id.u.mm_fd, &copy, sizeof(copy));
+               if(i != sizeof(copy))
+                       printk("new_mm : /proc/mm copy_segments failed, "
+                              "err = %d\n", -i);
+       }
+
+       if(!ptrace_ldt) {
                /* Our local LDT is used to supply the data for
                 * modify_ldt(READLDT), if PTRACE_LDT isn't available,
                 * i.e., we have to use the stub for modify_ldt, which
@@ -524,6 +545,7 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
                up(&from_mm->ldt.semaphore);
        }
 
+    out:
        return err;
 }