[PATCH] uml: remove pte_mkexec
[linux-2.6-block.git] / arch / um / kernel / skas / mmu.c
index 9e5e39cea821f8fe772c54b9363e7731cb22fc9a..4cd2ff546ef6f9d322b2f882ca182bf5315cf7c9 100644 (file)
@@ -15,6 +15,7 @@
 #include "asm/mmu.h"
 #include "asm/pgalloc.h"
 #include "asm/pgtable.h"
+#include "asm/ldt.h"
 #include "os.h"
 #include "skas.h"
 
@@ -54,14 +55,16 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
         * destroy_context_skas.
         */
 
-        mm->context.skas.last_page_table = pmd_page_kernel(*pmd);
+        mm->context.skas.last_page_table = pmd_page_vaddr(*pmd);
 #ifdef CONFIG_3_LEVEL_PGTABLES
         mm->context.skas.last_pmd = (unsigned long) __va(pud_val(*pud));
 #endif
 
        *pte = mk_pte(virt_to_page(kernel), __pgprot(_PAGE_PRESENT));
-       *pte = pte_mkexec(*pte);
-       *pte = pte_wrprotect(*pte);
+       /* This is wrong for the code page, but it doesn't matter since the
+        * stub is mapped by hand with the correct permissions.
+        */
+       *pte = pte_mkwrite(*pte);
        return(0);
 
  out_pmd:
@@ -74,13 +77,12 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
 
 int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
 {
-       struct mm_struct *cur_mm = current->mm;
-       struct mm_id *cur_mm_id = &cur_mm->context.skas.id;
-       struct mm_id *mm_id = &mm->context.skas.id;
+       struct mmu_context_skas *from_mm = NULL;
+       struct mmu_context_skas *to_mm = &mm->context.skas;
        unsigned long stack = 0;
-       int from, ret = -ENOMEM;
+       int ret = -ENOMEM;
 
-       if(!proc_mm || !ptrace_faultinfo){
+       if(skas_needs_stub){
                stack = get_zeroed_page(GFP_KERNEL);
                if(stack == 0)
                        goto out;
@@ -102,33 +104,39 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
 
                mm->nr_ptes--;
        }
-       mm_id->stack = stack;
 
-       if(proc_mm){
-               if((cur_mm != NULL) && (cur_mm != &init_mm))
-                       from = cur_mm_id->u.mm_fd;
-               else from = -1;
+       to_mm->id.stack = stack;
+       if(current->mm != NULL && current->mm != &init_mm)
+               from_mm = &current->mm->context.skas;
 
-               ret = new_mm(from, stack);
+       if(proc_mm){
+               ret = new_mm(stack);
                if(ret < 0){
                        printk("init_new_context_skas - new_mm failed, "
                               "errno = %d\n", ret);
                        goto out_free;
                }
-               mm_id->u.mm_fd = ret;
+               to_mm->id.u.mm_fd = ret;
        }
        else {
-               if((cur_mm != NULL) && (cur_mm != &init_mm))
-                       mm_id->u.pid = copy_context_skas0(stack,
-                                                         cur_mm_id->u.pid);
-               else mm_id->u.pid = start_userspace(stack);
+               if(from_mm)
+                       to_mm->id.u.pid = copy_context_skas0(stack,
+                                                            from_mm->id.u.pid);
+               else to_mm->id.u.pid = start_userspace(stack);
+       }
+
+       ret = init_new_ldt(to_mm, from_mm);
+       if(ret < 0){
+               printk("init_new_context_skas - init_ldt"
+                      " failed, errno = %d\n", ret);
+               goto out_free;
        }
 
        return 0;
 
  out_free:
-       if(mm_id->stack != 0)
-               free_page(mm_id->stack);
+       if(to_mm->id.stack != 0)
+               free_page(to_mm->id.stack);
  out:
        return ret;
 }
@@ -146,7 +154,7 @@ void destroy_context_skas(struct mm_struct *mm)
                free_page(mmu->id.stack);
                pte_lock_deinit(virt_to_page(mmu->last_page_table));
                pte_free_kernel((pte_t *) mmu->last_page_table);
-                dec_page_state(nr_page_table_pages);
+               dec_zone_page_state(virt_to_page(mmu->last_page_table), NR_PAGETABLE);
 #ifdef CONFIG_3_LEVEL_PGTABLES
                pmd_free((pmd_t *) mmu->last_pmd);
 #endif