--- zzzz-none-000/linux-4.4.60/arch/arm/kernel/module.c 2017-04-08 07:53:53.000000000 +0000 +++ wasp-540e-714/linux-4.4.60/arch/arm/kernel/module.c 2019-07-03 09:21:34.000000000 +0000 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -38,17 +39,72 @@ #endif #ifdef CONFIG_MMU +#if defined(CONFIG_AVM_ENHANCED) +void *_module_alloc(unsigned long size) +#else void *module_alloc(unsigned long size) +#endif { - void *p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, - GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, + unsigned long gfp_flags = GFP_KERNEL; + void *p; + + if (IS_ENABLED(CONFIG_ARM_MODULE_PLTS)) + gfp_flags = gfp_flags | __GFP_NOWARN; + + p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, + gfp_flags, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, __builtin_return_address(0)); + if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p) return p; + return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, __builtin_return_address(0)); } +#if defined(CONFIG_AVM_ENHANCED) +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +void *module_alloc(unsigned long size, char *name, enum _module_alloc_type_ type __attribute__ ((unused))) { + void *ptr = 0; +#if defined(CONFIG_AVM_BOOTMEM) + ptr = (void *)module_alloc_size_list_alloc(size, name, type); + if(ptr) { + return ptr; + } +#endif + switch(type) { + case module_alloc_type_init: + ptr = _module_alloc(size); + break; + case module_alloc_type_core: + /*--- ptr = (void *)module_alloc_size_list_alloc(size, name, type); ---*/ + /*--- if(ptr == NULL) { ---*/ + ptr = _module_alloc(size); + /*--- } ---*/ + break; + default: + case module_alloc_type_page: + ptr = _module_alloc(size); + break; + } + /*--- do_memory_check(); ---*/ + return ptr; +} + +/*--------------------------------------------------------------------------------*\ + Free memory returned from module_alloc +\*--------------------------------------------------------------------------------*/ +void module_memfree(void *module_region) { +#ifdef CONFIG_AVM_BOOTMEM + if(module_alloc_size_list_free((unsigned long)module_region) == 0) { + return; + } +#endif /* CONFIG_AVM_BOOTMEM */ + vfree(module_region); + return; +} +#endif/*--- if !defined(CONFIG_AVM_ENHANCED) ---*/ #endif int @@ -88,6 +144,10 @@ return -ENOEXEC; } + if ((IS_ERR_VALUE(sym->st_value) || !sym->st_value) && + ELF_ST_BIND(sym->st_info) == STB_WEAK) + continue; + loc = dstsec->sh_addr + rel->r_offset; switch (ELF32_R_TYPE(rel->r_info)) {