Merge branch 'connlimit' of git://dev.medozas.de/linux
[pandora-kernel.git] / arch / mips / kernel / module.c
index 3e9100d..dd940b7 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/jump_label.h>
+
 #include <asm/pgtable.h>       /* MODULE_START */
 
 struct mips_hi16 {
@@ -46,17 +48,9 @@ static DEFINE_SPINLOCK(dbe_lock);
 void *module_alloc(unsigned long size)
 {
 #ifdef MODULE_START
-       struct vm_struct *area;
-
-       size = PAGE_ALIGN(size);
-       if (!size)
-               return NULL;
-
-       area = __get_vm_area(size, VM_ALLOC, MODULE_START, MODULE_END);
-       if (!area)
-               return NULL;
-
-       return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
+       return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
+                               GFP_KERNEL, PAGE_KERNEL, -1,
+                               __builtin_return_address(0));
 #else
        if (size == 0)
                return NULL;
@@ -98,7 +92,8 @@ static int apply_r_mips_32_rela(struct module *me, u32 *location, Elf_Addr v)
 static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
 {
        if (v % 4) {
-               printk(KERN_ERR "module %s: dangerous relocation\n", me->name);
+               pr_err("module %s: dangerous R_MIPS_26 REL relocation\n",
+                      me->name);
                return -ENOEXEC;
        }
 
@@ -118,7 +113,8 @@ static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
 static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v)
 {
        if (v % 4) {
-               printk(KERN_ERR "module %s: dangerous relocation\n", me->name);
+               pr_err("module %s: dangerous R_MIPS_26 RELArelocation\n",
+                      me->name);
                return -ENOEXEC;
        }
 
@@ -222,7 +218,7 @@ static int apply_r_mips_lo16_rel(struct module *me, u32 *location, Elf_Addr v)
        return 0;
 
 out_danger:
-       printk(KERN_ERR "module %s: dangerous " "relocation\n", me->name);
+       pr_err("module %s: dangerous R_MIPS_LO16 REL relocation\n", me->name);
 
        return -ENOEXEC;
 }
@@ -301,7 +297,7 @@ int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
                /* This is the symbol it is referring to */
                sym = (Elf_Sym *)sechdrs[symindex].sh_addr
                        + ELF_MIPS_R_SYM(rel[i]);
-               if (!sym->st_value) {
+               if (IS_ERR_VALUE(sym->st_value)) {
                        /* Ignore unresolved weak symbol */
                        if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
                                continue;
@@ -341,7 +337,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
                /* This is the symbol it is referring to */
                sym = (Elf_Sym *)sechdrs[symindex].sh_addr
                        + ELF_MIPS_R_SYM(rel[i]);
-               if (!sym->st_value) {
+               if (IS_ERR_VALUE(sym->st_value)) {
                        /* Ignore unresolved weak symbol */
                        if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
                                continue;
@@ -388,6 +384,9 @@ int module_finalize(const Elf_Ehdr *hdr,
        const Elf_Shdr *s;
        char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
 
+       /* Make jump label nops. */
+       jump_label_apply_nops(me);
+
        INIT_LIST_HEAD(&me->arch.dbe_list);
        for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
                if (strcmp("__dbe_table", secstrings + s->sh_name) != 0)