Merge branch 'core/softlockup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / arch / mips / kernel / vpe.c
index 39804c5..972b2d2 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/vmalloc.h>
 #include <linux/elf.h>
 #include <linux/seq_file.h>
+#include <linux/smp_lock.h>
 #include <linux/syscalls.h>
 #include <linux/moduleloader.h>
 #include <linux/interrupt.h>
@@ -269,7 +270,7 @@ static void *alloc_progmem(unsigned long len)
         * This means you must tell Linux to use less memory than you
         * physically have, for example by passing a mem= boot argument.
         */
-       addr = pfn_to_kaddr(max_pfn);
+       addr = pfn_to_kaddr(max_low_pfn);
        memset(addr, 0, len);
 #else
        /* simple grab some mem for now */
@@ -781,10 +782,15 @@ static int vpe_run(struct vpe * v)
        /* take system out of configuration state */
        clear_c0_mvpcontrol(MVPCONTROL_VPC);
 
+       /*
+        * SMTC/SMVP kernels manage VPE enable independently,
+        * but uniprocessor kernels need to turn it on, even
+        * if that wasn't the pre-dvpe() state.
+        */
 #ifdef CONFIG_SMP
-       evpe(EVPE_ENABLE);
-#else
        evpe(vpeflags);
+#else
+       evpe(EVPE_ENABLE);
 #endif
        emt(dmt_flag);
        local_irq_restore(flags);
@@ -840,7 +846,7 @@ static int vpe_elfload(struct vpe * v)
 
        /* Sanity checks against insmoding binaries or wrong arch,
           weird elf version */
-       if (memcmp(hdr->e_ident, ELFMAG, 4) != 0
+       if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0
            || (hdr->e_type != ET_REL && hdr->e_type != ET_EXEC)
            || !elf_check_arch(hdr)
            || hdr->e_shentsize != sizeof(*sechdrs)) {
@@ -947,12 +953,14 @@ static int vpe_elfload(struct vpe * v)
                struct elf_phdr *phdr = (struct elf_phdr *) ((char *)hdr + hdr->e_phoff);
 
                for (i = 0; i < hdr->e_phnum; i++) {
-                       if (phdr->p_type != PT_LOAD)
-                               continue;
-
-                       memcpy((void *)phdr->p_paddr, (char *)hdr + phdr->p_offset, phdr->p_filesz);
-                       memset((void *)phdr->p_paddr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz);
-                       phdr++;
+                       if (phdr->p_type == PT_LOAD) {
+                               memcpy((void *)phdr->p_paddr,
+                                      (char *)hdr + phdr->p_offset,
+                                      phdr->p_filesz);
+                               memset((void *)phdr->p_paddr + phdr->p_filesz,
+                                      0, phdr->p_memsz - phdr->p_filesz);
+                   }
+                   phdr++;
                }
 
                for (i = 0; i < hdr->e_shnum; i++) {
@@ -1043,17 +1051,20 @@ static int vpe_open(struct inode *inode, struct file *filp)
        enum vpe_state state;
        struct vpe_notifications *not;
        struct vpe *v;
-       int ret;
+       int ret, err = 0;
 
+       lock_kernel();
        if (minor != iminor(inode)) {
                /* assume only 1 device at the moment. */
                printk(KERN_WARNING "VPE loader: only vpe1 is supported\n");
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
 
        if ((v = get_vpe(tclimit)) == NULL) {
                printk(KERN_WARNING "VPE loader: unable to get vpe\n");
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
 
        state = xchg(&v->state, VPE_STATE_INUSE);
@@ -1093,6 +1104,8 @@ static int vpe_open(struct inode *inode, struct file *filp)
        v->shared_ptr = NULL;
        v->__start = 0;
 
+out:
+       unlock_kernel();
        return 0;
 }
 
@@ -1107,7 +1120,7 @@ static int vpe_release(struct inode *inode, struct file *filp)
                return -ENODEV;
 
        hdr = (Elf_Ehdr *) v->pbuffer;
-       if (memcmp(hdr->e_ident, ELFMAG, 4) == 0) {
+       if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) == 0) {
                if (vpe_elfload(v) >= 0) {
                        vpe_run(v);
                } else {