aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target/linux/cobalt/config-default205
-rw-r--r--target/linux/cobalt/patches-2.6.35/001-no_module_reloc.patch368
2 files changed, 474 insertions, 99 deletions
diff --git a/target/linux/cobalt/config-default b/target/linux/cobalt/config-default
index 5c06303069..5c08a666b4 100644
--- a/target/linux/cobalt/config-default
+++ b/target/linux/cobalt/config-default
@@ -1,24 +1,47 @@
# CONFIG_32BIT is not set
+CONFIG_64BIT=y
# CONFIG_ALCHEMY_GPIO_INDIRECT is not set
# CONFIG_AR7 is not set
# CONFIG_ARCH_HAS_ILOG2_U32 is not set
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+CONFIG_ARCH_POPULATES_NODE_MAP=y
# CONFIG_ARCH_SUPPORTS_MSI is not set
+CONFIG_ARCH_SUPPORTS_OPROFILE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
# CONFIG_ARPD is not set
+CONFIG_ATA=y
# CONFIG_BCM47XX is not set
# CONFIG_BCM63XX is not set
+CONFIG_BINFMT_ELF32=y
+CONFIG_BITREVERSE=y
# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_BLOCK_COMPAT=y
# CONFIG_BRIDGE is not set
# CONFIG_BSD_PROCESS_ACCT is not set
# CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD is not set
# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
+CONFIG_CEVT_GT641XX=y
+CONFIG_CEVT_R4K=y
+CONFIG_CEVT_R4K_LIB=y
+CONFIG_COMPAT=y
+CONFIG_COMPAT_BRK=y
+CONFIG_COMPAT_NETLINK_MESSAGES=y
+CONFIG_CONSOLE_TRANSLATIONS=y
# CONFIG_CPU_BIG_ENDIAN is not set
# CONFIG_CPU_CAVIUM_OCTEON is not set
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_CPU_LITTLE_ENDIAN=y
# CONFIG_CPU_LOONGSON2E is not set
+# CONFIG_CPU_LOONGSON2F is not set
# CONFIG_CPU_MIPS32_R1 is not set
# CONFIG_CPU_MIPS32_R2 is not set
# CONFIG_CPU_MIPS64_R1 is not set
# CONFIG_CPU_MIPS64_R2 is not set
+CONFIG_CPU_NEVADA=y
# CONFIG_CPU_R10000 is not set
# CONFIG_CPU_R3000 is not set
# CONFIG_CPU_R4300 is not set
@@ -31,113 +54,21 @@
# CONFIG_CPU_RM7000 is not set
# CONFIG_CPU_RM9000 is not set
# CONFIG_CPU_SB1 is not set
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
# CONFIG_CPU_TX39XX is not set
# CONFIG_CPU_TX49XX is not set
# CONFIG_CPU_VR41XX is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_DM9000 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_FIRMWARE_EDID is not set
-# CONFIG_FRAMEBUFFER_CONSOLE is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_HIGH_RES_TIMERS is not set
-# CONFIG_HW_RANDOM is not set
-# CONFIG_HZ_100 is not set
-# CONFIG_INPUT_YEALINK is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_JFFS2_FS is not set
-# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
-# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
-# CONFIG_LEDS_TRIGGER_TIMER is not set
-# CONFIG_LOGO is not set
-# CONFIG_MACH_ALCHEMY is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_MACH_LOONGSON is not set
-# CONFIG_MACH_TX39XX is not set
-# CONFIG_MACH_TX49XX is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_MII is not set
-# CONFIG_MIKROTIK_RB532 is not set
-# CONFIG_MIPS_MACHINE is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_MT_SMP is not set
-# CONFIG_MIPS_MT_SMTC is not set
-# CONFIG_MIPS_SIM is not set
-# CONFIG_MISC_DEVICES is not set
-# CONFIG_MTD_BLOCK is not set
-# CONFIG_MTD_BLOCK_RO is not set
-# CONFIG_MTD_CFI is not set
-# CONFIG_MTD_CFI_INTELEXT is not set
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_NETDEV_1000 is not set
-# CONFIG_NET_PCI is not set
-# CONFIG_NO_IOPORT is not set
-# CONFIG_NXP_STB220 is not set
-# CONFIG_NXP_STB225 is not set
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_PCI=y
-# CONFIG_PMC_MSP is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_PNX8550_JBS is not set
-# CONFIG_PNX8550_STB810 is not set
-# CONFIG_SCSI_LOWLEVEL is not set
-# CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP27 is not set
-# CONFIG_SGI_IP28 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SIBYTE_BIGSUR is not set
-# CONFIG_SIBYTE_CARMEL is not set
-# CONFIG_SIBYTE_CRHINE is not set
-# CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SIBYTE_LITTLESUR is not set
-# CONFIG_SIBYTE_RHONE is not set
-# CONFIG_SIBYTE_SENTOSA is not set
-# CONFIG_SIBYTE_SWARM is not set
-# CONFIG_SLAB is not set
-# CONFIG_TREE_PREEMPT_RCU is not set
-# CONFIG_ULI526X is not set
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_WATCHDOG is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_WLAN_80211 is not set
-CONFIG_64BIT=y
-CONFIG_ARCH_HIBERNATION_POSSIBLE=y
-CONFIG_ARCH_POPULATES_NODE_MAP=y
-CONFIG_ARCH_SUPPORTS_OPROFILE=y
-CONFIG_ARCH_SUSPEND_POSSIBLE=y
-CONFIG_ATA=y
-CONFIG_BINFMT_ELF32=y
-CONFIG_BITREVERSE=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_BLK_DEV_SD=y
-CONFIG_BLOCK_COMPAT=y
-CONFIG_CEVT_GT641XX=y
-CONFIG_CEVT_R4K=y
-CONFIG_CEVT_R4K_LIB=y
-CONFIG_CFG80211_DEFAULT_PS_VALUE=0
-CONFIG_COMPAT=y
-CONFIG_COMPAT_BRK=y
-CONFIG_COMPAT_NETLINK_MESSAGES=y
-CONFIG_CONSOLE_TRANSLATIONS=y
-CONFIG_CPU_HAS_SYNC=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_CPU_NEVADA=y
-CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
-CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
CONFIG_CSRC_R4K=y
CONFIG_CSRC_R4K_LIB=y
CONFIG_DE2104X=y
CONFIG_DE2104X_DSL=0
+# CONFIG_DE4X5 is not set
CONFIG_DECOMPRESS_LZMA=y
CONFIG_DEVKMEM=y
CONFIG_DEVPORT=y
-CONFIG_DMA_NEED_PCI_MAP_STATE=y
+# CONFIG_DM9000 is not set
+# CONFIG_DM9102 is not set
CONFIG_DMA_NONCOHERENT=y
CONFIG_DNOTIFY=y
CONFIG_DUMMY_CONSOLE=y
@@ -146,6 +77,9 @@ CONFIG_ELF_CORE=y
CONFIG_ENABLE_MUST_CHECK=y
CONFIG_FB=y
CONFIG_FB_COBALT=y
+# CONFIG_FB_SM7XX is not set
+# CONFIG_FB_XGI is not set
+# CONFIG_FIRMWARE_EDID is not set
CONFIG_FIRMWARE_IN_KERNEL=y
CONFIG_FS_POSIX_ACL=y
CONFIG_GENERIC_ACL=y
@@ -155,19 +89,28 @@ CONFIG_GENERIC_CMOS_UPDATE=y
CONFIG_GENERIC_FIND_LAST_BIT=y
CONFIG_GENERIC_FIND_NEXT_BIT=y
CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+# CONFIG_HAMRADIO is not set
CONFIG_HAS_DMA=y
CONFIG_HAS_IOMEM=y
CONFIG_HAS_IOPORT=y
CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
CONFIG_HAVE_GENERIC_DMA_COHERENT=y
CONFIG_HAVE_IDE=y
CONFIG_HAVE_OPROFILE=y
CONFIG_HAVE_SYSCALL_WRAPPERS=y
CONFIG_HID=m
CONFIG_HID_SUPPORT=y
+# CONFIG_HIGH_RES_TIMERS is not set
CONFIG_HW_CONSOLE=y
CONFIG_HW_HAS_PCI=y
+# CONFIG_HW_RANDOM is not set
CONFIG_HZ=250
+# CONFIG_HZ_100 is not set
CONFIG_HZ_250=y
CONFIG_I8253=y
CONFIG_I8259=y
@@ -177,31 +120,72 @@ CONFIG_INPUT=y
CONFIG_INPUT_COBALT_BTNS=y
CONFIG_INPUT_EVDEV=y
CONFIG_INPUT_POLLDEV=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_MULTICAST is not set
CONFIG_IRQ_CPU=y
CONFIG_IRQ_GT641XX=y
+# CONFIG_JFFS2_FS is not set
CONFIG_KEXEC=y
CONFIG_LEDS_COBALT_QUBE=y
CONFIG_LEDS_COBALT_RAQ=y
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
+# CONFIG_LEDS_TRIGGER_TIMER is not set
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_LOONGSON_MC146818 is not set
+CONFIG_LOONGSON_UART_BASE=y
+# CONFIG_MACH_ALCHEMY is not set
+# CONFIG_MACH_DECSTATION is not set
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_MACH_LOONGSON is not set
+# CONFIG_MACH_TX39XX is not set
+# CONFIG_MACH_TX49XX is not set
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_MII is not set
+# CONFIG_MIKROTIK_RB532 is not set
+CONFIG_MIPS=y
CONFIG_MIPS32_COMPAT=y
CONFIG_MIPS32_N32=y
CONFIG_MIPS32_O32=y
-CONFIG_MIPS=y
CONFIG_MIPS_COBALT=y
+CONFIG_MIPS_EXTERNAL_TIMER=y
CONFIG_MIPS_L1_CACHE_SHIFT=5
+# CONFIG_MIPS_MACHINE is not set
+# CONFIG_MIPS_MALTA is not set
CONFIG_MIPS_MT_DISABLED=y
+# CONFIG_MIPS_MT_SMP is not set
+# CONFIG_MIPS_MT_SMTC is not set
+# CONFIG_MIPS_SIM is not set
+# CONFIG_MISC_DEVICES is not set
+# CONFIG_MTD_BLOCK is not set
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
CONFIG_MTD_JEDECPROBE=y
CONFIG_MTD_PHYSMAP=y
+CONFIG_NEED_DMA_MAP_STATE=y
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NET_PCI is not set
CONFIG_NET_TULIP=y
+# CONFIG_NO_IOPORT is not set
+# CONFIG_NXP_STB220 is not set
+# CONFIG_NXP_STB225 is not set
CONFIG_PAGEFLAGS_EXTENDED=y
+# CONFIG_PARTITION_ADVANCED is not set
CONFIG_PATA_VIA=y
+CONFIG_PCI=y
CONFIG_PCI_DISABLE_COMMON_QUIRKS=y
CONFIG_PCI_DOMAINS=y
CONFIG_PCI_GT64XXX_PCI0=y
-CONFIG_PCI_LEGACY=y
CONFIG_PCSPKR_PLATFORM=y
CONFIG_PHYS_ADDR_T_64BIT=y
+# CONFIG_PMC_MSP is not set
+# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_PNX8550_JBS is not set
+# CONFIG_PNX8550_STB810 is not set
+# CONFIG_POWERTV is not set
CONFIG_PROC_PAGE_MONITOR=y
CONFIG_RAID_ATTRS=y
CONFIG_RELAY=y
@@ -210,9 +194,26 @@ CONFIG_RTC_INTF_DEV_UIE_EMUL=y
CONFIG_SATA_PMP=y
CONFIG_SCHED_OMIT_FRAME_POINTER=y
CONFIG_SCSI=y
+# CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_SCSI_MOD=y
+# CONFIG_SCSI_MULTI_LUN is not set
CONFIG_SECCOMP=y
+# CONFIG_SERIAL_8250_EXTENDED is not set
CONFIG_SERIAL_8250_NR_UARTS=4
CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SGI_IP27 is not set
+# CONFIG_SGI_IP28 is not set
+# CONFIG_SGI_IP32 is not set
+# CONFIG_SIBYTE_BIGSUR is not set
+# CONFIG_SIBYTE_CARMEL is not set
+# CONFIG_SIBYTE_CRHINE is not set
+# CONFIG_SIBYTE_CRHONE is not set
+# CONFIG_SIBYTE_LITTLESUR is not set
+# CONFIG_SIBYTE_RHONE is not set
+# CONFIG_SIBYTE_SENTOSA is not set
+# CONFIG_SIBYTE_SWARM is not set
+# CONFIG_SLAB is not set
CONFIG_SLUB=y
CONFIG_SYSVIPC_COMPAT=y
CONFIG_SYS_HAS_CPU_NEVADA=y
@@ -221,6 +222,7 @@ CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+# CONFIG_TINY_RCU is not set
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_TREE_RCU=y
CONFIG_TULIP=y
@@ -228,9 +230,14 @@ CONFIG_TULIP_MMIO=y
CONFIG_TULIP_MWI=y
CONFIG_TULIP_NAPI=y
CONFIG_TULIP_NAPI_HW_MITIGATION=y
+# CONFIG_ULI526X is not set
CONFIG_USB_SUPPORT=y
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_VLAN_8021Q is not set
CONFIG_VM_EVENT_COUNTERS=y
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_VT_HW_CONSOLE_BINDING=y
+# CONFIG_WATCHDOG is not set
+# CONFIG_WINBOND_840 is not set
CONFIG_ZONE_DMA_FLAG=0
diff --git a/target/linux/cobalt/patches-2.6.35/001-no_module_reloc.patch b/target/linux/cobalt/patches-2.6.35/001-no_module_reloc.patch
new file mode 100644
index 0000000000..3b1f12427a
--- /dev/null
+++ b/target/linux/cobalt/patches-2.6.35/001-no_module_reloc.patch
@@ -0,0 +1,368 @@
+--- a/arch/mips/Makefile
++++ b/arch/mips/Makefile
+@@ -85,7 +85,7 @@ all-$(CONFIG_BOOT_ELF64) := $(vmlinux-64
+ cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
+ cflags-y += -msoft-float
+ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
+-MODFLAGS += -mno-long-calls
++MODFLAGS += -mlong-calls
+
+ cflags-y += -ffreestanding
+
+--- a/arch/mips/include/asm/module.h
++++ b/arch/mips/include/asm/module.h
+@@ -9,11 +9,6 @@ struct mod_arch_specific {
+ struct list_head dbe_list;
+ const struct exception_table_entry *dbe_start;
+ const struct exception_table_entry *dbe_end;
+-
+- void *phys_plt_tbl;
+- void *virt_plt_tbl;
+- unsigned int phys_plt_offset;
+- unsigned int virt_plt_offset;
+ };
+
+ typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
+--- a/arch/mips/kernel/module.c
++++ b/arch/mips/kernel/module.c
+@@ -43,117 +43,6 @@ static struct mips_hi16 *mips_hi16_list;
+ static LIST_HEAD(dbe_list);
+ static DEFINE_SPINLOCK(dbe_lock);
+
+-/*
+- * Get the potential max trampolines size required of the init and
+- * non-init sections. Only used if we cannot find enough contiguous
+- * physically mapped memory to put the module into.
+- */
+-static unsigned int
+-get_plt_size(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
+- const char *secstrings, unsigned int symindex, bool is_init)
+-{
+- unsigned long ret = 0;
+- unsigned int i, j;
+- Elf_Sym *syms;
+-
+- /* Everything marked ALLOC (this includes the exported symbols) */
+- for (i = 1; i < hdr->e_shnum; ++i) {
+- unsigned int info = sechdrs[i].sh_info;
+-
+- if (sechdrs[i].sh_type != SHT_REL
+- && sechdrs[i].sh_type != SHT_RELA)
+- continue;
+-
+- /* Not a valid relocation section? */
+- if (info >= hdr->e_shnum)
+- continue;
+-
+- /* Don't bother with non-allocated sections */
+- if (!(sechdrs[info].sh_flags & SHF_ALLOC))
+- continue;
+-
+- /* If it's called *.init*, and we're not init, we're
+- not interested */
+- if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != 0)
+- != is_init)
+- continue;
+-
+- syms = (Elf_Sym *) sechdrs[symindex].sh_addr;
+- if (sechdrs[i].sh_type == SHT_REL) {
+- Elf_Mips_Rel *rel = (void *) sechdrs[i].sh_addr;
+- unsigned int size = sechdrs[i].sh_size / sizeof(*rel);
+-
+- for (j = 0; j < size; ++j) {
+- Elf_Sym *sym;
+-
+- if (ELF_MIPS_R_TYPE(rel[j]) != R_MIPS_26)
+- continue;
+-
+- sym = syms + ELF_MIPS_R_SYM(rel[j]);
+- if (!is_init && sym->st_shndx != SHN_UNDEF)
+- continue;
+-
+- ret += 4 * sizeof(int);
+- }
+- } else {
+- Elf_Mips_Rela *rela = (void *) sechdrs[i].sh_addr;
+- unsigned int size = sechdrs[i].sh_size / sizeof(*rela);
+-
+- for (j = 0; j < size; ++j) {
+- Elf_Sym *sym;
+-
+- if (ELF_MIPS_R_TYPE(rela[j]) != R_MIPS_26)
+- continue;
+-
+- sym = syms + ELF_MIPS_R_SYM(rela[j]);
+- if (!is_init && sym->st_shndx != SHN_UNDEF)
+- continue;
+-
+- ret += 4 * sizeof(int);
+- }
+- }
+- }
+-
+- return ret;
+-}
+-
+-#ifndef MODULE_START
+-static void *alloc_phys(unsigned long size)
+-{
+- unsigned order;
+- struct page *page;
+- struct page *p;
+-
+- size = PAGE_ALIGN(size);
+- order = get_order(size);
+-
+- page = alloc_pages(GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN |
+- __GFP_THISNODE, order);
+- if (!page)
+- return NULL;
+-
+- split_page(page, order);
+-
+- for (p = page + (size >> PAGE_SHIFT); p < page + (1 << order); ++p)
+- __free_page(p);
+-
+- return page_address(page);
+-}
+-#endif
+-
+-static void free_phys(void *ptr, unsigned long size)
+-{
+- struct page *page;
+- struct page *end;
+-
+- page = virt_to_page(ptr);
+- end = page + (PAGE_ALIGN(size) >> PAGE_SHIFT);
+-
+- for (; page < end; ++page)
+- __free_page(page);
+-}
+-
+-
+ void *module_alloc(unsigned long size)
+ {
+ #ifdef MODULE_START
+@@ -169,99 +58,21 @@ void *module_alloc(unsigned long size)
+
+ return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
+ #else
+- void *ptr;
+-
+ if (size == 0)
+ return NULL;
+-
+- ptr = alloc_phys(size);
+-
+- /* If we failed to allocate physically contiguous memory,
+- * fall back to regular vmalloc. The module loader code will
+- * create jump tables to handle long jumps */
+- if (!ptr)
+- return vmalloc(size);
+-
+- return ptr;
+-#endif
+-}
+-
+-static inline bool is_phys_addr(void *ptr)
+-{
+-#ifdef CONFIG_64BIT
+- return (KSEGX((unsigned long)ptr) == CKSEG0);
+-#else
+- return (KSEGX(ptr) == KSEG0);
++ return vmalloc(size);
+ #endif
+ }
+
+ /* Free memory returned from module_alloc */
+ void module_free(struct module *mod, void *module_region)
+ {
+- if (is_phys_addr(module_region)) {
+- if (mod->module_init == module_region)
+- free_phys(module_region, mod->init_size);
+- else if (mod->module_core == module_region)
+- free_phys(module_region, mod->core_size);
+- else
+- BUG();
+- } else {
+- vfree(module_region);
+- }
+-}
+-
+-static void *__module_alloc(int size, bool phys)
+-{
+- void *ptr;
+-
+- if (phys)
+- ptr = kmalloc(size, GFP_KERNEL);
+- else
+- ptr = vmalloc(size);
+- return ptr;
+-}
+-
+-static void __module_free(void *ptr)
+-{
+- if (is_phys_addr(ptr))
+- kfree(ptr);
+- else
+- vfree(ptr);
++ vfree(module_region);
+ }
+
+ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+ char *secstrings, struct module *mod)
+ {
+- unsigned int symindex = 0;
+- unsigned int core_size, init_size;
+- int i;
+-
+- for (i = 1; i < hdr->e_shnum; i++)
+- if (sechdrs[i].sh_type == SHT_SYMTAB)
+- symindex = i;
+-
+- core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false);
+- init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true);
+-
+- mod->arch.phys_plt_offset = 0;
+- mod->arch.virt_plt_offset = 0;
+- mod->arch.phys_plt_tbl = NULL;
+- mod->arch.virt_plt_tbl = NULL;
+-
+- if ((core_size + init_size) == 0)
+- return 0;
+-
+- mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1);
+- if (!mod->arch.phys_plt_tbl)
+- return -ENOMEM;
+-
+- mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0);
+- if (!mod->arch.virt_plt_tbl) {
+- __module_free(mod->arch.phys_plt_tbl);
+- mod->arch.phys_plt_tbl = NULL;
+- return -ENOMEM;
+- }
+-
+ return 0;
+ }
+
+@@ -284,36 +95,28 @@ static int apply_r_mips_32_rela(struct m
+ return 0;
+ }
+
+-static Elf_Addr add_plt_entry_to(unsigned *plt_offset,
+- void *start, Elf_Addr v)
++static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
+ {
+- unsigned *tramp = start + *plt_offset;
+- *plt_offset += 4 * sizeof(int);
+-
+- /* adjust carry for addiu */
+- if (v & 0x00008000)
+- v += 0x10000;
+-
+- tramp[0] = 0x3c190000 | (v >> 16); /* lui t9, hi16 */
+- tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */
+- tramp[2] = 0x03200008; /* jr t9 */
+- tramp[3] = 0x00000000; /* nop */
++ if (v % 4) {
++ pr_err("module %s: dangerous R_MIPS_26 REL relocation\n",
++ me->name);
++ return -ENOEXEC;
++ }
+
+- return (Elf_Addr) tramp;
+-}
++ if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) {
++ printk(KERN_ERR
++ "module %s: relocation overflow\n",
++ me->name);
++ return -ENOEXEC;
++ }
+
+-static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v)
+-{
+- if (is_phys_addr(location))
+- return add_plt_entry_to(&me->arch.phys_plt_offset,
+- me->arch.phys_plt_tbl, v);
+- else
+- return add_plt_entry_to(&me->arch.virt_plt_offset,
+- me->arch.virt_plt_tbl, v);
++ *location = (*location & ~0x03ffffff) |
++ ((*location + (v >> 2)) & 0x03ffffff);
+
++ return 0;
+ }
+
+-static int set_r_mips_26(struct module *me, u32 *location, u32 ofs, Elf_Addr v)
++static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v)
+ {
+ if (v % 4) {
+ pr_err("module %s: dangerous R_MIPS_26 RELArelocation\n",
+@@ -322,31 +125,17 @@ static int set_r_mips_26(struct module *
+ }
+
+ if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) {
+- v = add_plt_entry(me, location, v + (ofs << 2));
+- if (!v) {
+- printk(KERN_ERR
++ printk(KERN_ERR
+ "module %s: relocation overflow\n",
+ me->name);
+- return -ENOEXEC;
+- }
+- ofs = 0;
++ return -ENOEXEC;
+ }
+
+- *location = (*location & ~0x03ffffff) | ((ofs + (v >> 2)) & 0x03ffffff);
++ *location = (*location & ~0x03ffffff) | ((v >> 2) & 0x03ffffff);
+
+ return 0;
+ }
+
+-static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
+-{
+- return set_r_mips_26(me, location, *location & 0x03ffffff, v);
+-}
+-
+-static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v)
+-{
+- return set_r_mips_26(me, location, 0, v);
+-}
+-
+ static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v)
+ {
+ struct mips_hi16 *n;
+@@ -611,32 +400,11 @@ int module_finalize(const Elf_Ehdr *hdr,
+ list_add(&me->arch.dbe_list, &dbe_list);
+ spin_unlock_irq(&dbe_lock);
+ }
+-
+- /* Get rid of the fixup trampoline if we're running the module
+- * from physically mapped address space */
+- if (me->arch.phys_plt_offset == 0) {
+- __module_free(me->arch.phys_plt_tbl);
+- me->arch.phys_plt_tbl = NULL;
+- }
+- if (me->arch.virt_plt_offset == 0) {
+- __module_free(me->arch.virt_plt_tbl);
+- me->arch.virt_plt_tbl = NULL;
+- }
+-
+ return 0;
+ }
+
+ void module_arch_cleanup(struct module *mod)
+ {
+- if (mod->arch.phys_plt_tbl) {
+- __module_free(mod->arch.phys_plt_tbl);
+- mod->arch.phys_plt_tbl = NULL;
+- }
+- if (mod->arch.virt_plt_tbl) {
+- __module_free(mod->arch.virt_plt_tbl);
+- mod->arch.virt_plt_tbl = NULL;
+- }
+-
+ spin_lock_irq(&dbe_lock);
+ list_del(&mod->arch.dbe_list);
+ spin_unlock_irq(&dbe_lock);