[PATCH] uml: remove spinlock wrapper functions
[safe/jmp/linux-2.6] / arch / um / kernel / trap_kern.c
index 95c8f87..02f6d4d 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
  * Licensed under the GPL
  */
 #include "mconsole_kern.h"
 #include "mem.h"
 #include "mem_kern.h"
+#include "sysdep/sigcontext.h"
+#include "sysdep/ptrace.h"
+#include "os.h"
 #ifdef CONFIG_MODE_SKAS
 #include "skas.h"
 #endif
+#include "os.h"
 
 /* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
 int handle_page_fault(unsigned long address, unsigned long ip, 
@@ -95,7 +99,16 @@ survive:
                pte = pte_offset_kernel(pmd, address);
        } while(!pte_present(*pte));
        err = 0;
+       /* The below warning was added in place of
+        *      pte_mkyoung(); if (is_write) pte_mkdirty();
+        * If it's triggered, we'd see normally a hang here (a clean pte is
+        * marked read-only to emulate the dirty bit).
+        * However, the generic code can mark a PTE writable but clean on a
+        * concurrent read fault, triggering this harmlessly. So comment it out.
+        */
+#if 0
        WARN_ON(!pte_young(*pte) || (is_write && !pte_dirty(*pte)));
+#endif
        flush_tlb_page(vma, address);
 out:
        up_read(&mm->mmap_sem);
@@ -116,6 +129,25 @@ out_of_memory:
        goto out;
 }
 
+void segv_handler(int sig, union uml_pt_regs *regs)
+{
+       struct faultinfo * fi = UPT_FAULTINFO(regs);
+
+       if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
+               bad_segv(*fi, UPT_IP(regs));
+               return;
+       }
+       segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
+}
+
+struct kern_handlers handlinfo_kern = {
+       .relay_signal = relay_signal,
+       .winch = winch,
+       .bus_handler = relay_signal,
+       .page_fault = segv_handler,
+       .sigio_handler = sigio_handler,
+       .timer_handler = timer_handler
+};
 /*
  * We give a *copy* of the faultinfo in the regs to segv.
  * This must be done, since nesting SEGVs could overwrite
@@ -166,7 +198,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
                si.si_signo = SIGBUS;
                si.si_errno = 0;
                si.si_code = BUS_ADRERR;
-               si.si_addr = (void *)address;
+               si.si_addr = (void __user *)address;
                 current->thread.arch.faultinfo = fi;
                force_sig_info(SIGBUS, &si, current);
        } else if (err == -ENOMEM) {
@@ -175,7 +207,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
        } else {
                BUG_ON(err != -EFAULT);
                si.si_signo = SIGSEGV;
-               si.si_addr = (void *) address;
+               si.si_addr = (void __user *) address;
                 current->thread.arch.faultinfo = fi;
                force_sig_info(SIGSEGV, &si, current);
        }
@@ -188,8 +220,8 @@ void bad_segv(struct faultinfo fi, unsigned long ip)
 
        si.si_signo = SIGSEGV;
        si.si_code = SEGV_ACCERR;
-        si.si_addr = (void *) FAULT_ADDRESS(fi);
-        current->thread.arch.faultinfo = fi;
+       si.si_addr = (void __user *) FAULT_ADDRESS(fi);
+       current->thread.arch.faultinfo = fi;
        force_sig_info(SIGSEGV, &si, current);
 }