--- zzzz-none-000/linux-3.10.107/arch/mips/kernel/module.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/kernel/module.c 2021-11-10 11:53:54.000000000 +0000 @@ -32,6 +32,11 @@ #include #include /* MODULE_START */ +#if defined(CONFIG_AVM_ENHANCED) +#include +#include +#include +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ struct mips_hi16 { struct mips_hi16 *next; @@ -42,14 +47,51 @@ static LIST_HEAD(dbe_list); static DEFINE_SPINLOCK(dbe_lock); +#if !defined(CONFIG_AVM_ENHANCED) #ifdef MODULE_START void *module_alloc(unsigned long size) { return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END, - GFP_KERNEL, PAGE_KERNEL, -1, + GFP_KERNEL, PAGE_KERNEL, -1, __builtin_return_address(0)); } #endif +#else /*--- if !defined(CONFIG_AVM_ENHANCED) ---*/ +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +void *module_alloc(unsigned long size, char *name, enum _module_alloc_type_ type __attribute__ ((unused))) { + void *ptr; + switch(type) { + case module_alloc_type_init: + ptr = vmalloc(size); + break; + case module_alloc_type_core: + ptr = (void *)module_alloc_size_list_alloc(size, name, type); + if(ptr == NULL) + ptr = vmalloc_exec(size); + break; + default: + case module_alloc_type_page: + ptr = vmalloc_exec(size); + break; + } + /*--- do_memory_check(); ---*/ + return ptr; +} + +/* Free memory returned from module_alloc */ +void module_free(struct module *mod, void *module_region) { + if(module_alloc_size_list_free((unsigned long)module_region) == 0) { + return; + } + if((((unsigned long)module_region) & 0xE0000000) == 0xC0000000) { + vfree(module_region); + return; + } + return; +} +#endif/*--- #else ---*//*--- if !defined(CONFIG_AVM_ENHANCED) ---*/ + int apply_r_mips_none(struct module *me, u32 *location, Elf_Addr v) { @@ -58,8 +100,14 @@ static int apply_r_mips_32_rel(struct module *me, u32 *location, Elf_Addr v) { - *location += v; - +#if defined(CONFIG_AVM_ENHANCED) + if((u32)location & 0x3) { + /*--- supress unaligned trap-handling ---*/ + u32 tmp = extract_unaligned_dword(location); + set_unaligned_dword(location, tmp + v); + } else +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + *location += v; return 0; } @@ -73,8 +121,8 @@ if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { printk(KERN_ERR - "module %s: relocation overflow\n", - me->name); + "module %s: addr 0x%08lx relocation overflow at location 0x%08lx\n", + me->name, (unsigned long)v, (unsigned long)location); return -ENOEXEC; } @@ -225,8 +273,11 @@ v = sym->st_value; res = reloc_handlers_rel[ELF_MIPS_R_TYPE(rel[i])](me, location, v); - if (res) + if (res) { + printk(KERN_ERR "failed on symbol %s\n", + strtab + sym->st_name); return res; + } } /*