Skip to content

Commit 3876215

Browse files
rpptmcgrof
authored andcommitted
nios2: define virtual address space for modules
nios2 uses kmalloc() to implement module_alloc() because CALL26/PCREL26 cannot reach all of vmalloc address space. Define module space as 32MiB below the kernel base and switch nios2 to use vmalloc for module allocations. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Dinh Nguyen <dinguyen@kernel.org> Acked-by: Song Liu <song@kernel.org> Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 0cdf587 commit 3876215

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

arch/nios2/include/asm/pgtable.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
#include <asm-generic/pgtable-nopmd.h>
2626

2727
#define VMALLOC_START CONFIG_NIOS2_KERNEL_MMU_REGION_BASE
28-
#define VMALLOC_END (CONFIG_NIOS2_KERNEL_REGION_BASE - 1)
28+
#define VMALLOC_END (CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M - 1)
29+
30+
#define MODULES_VADDR (CONFIG_NIOS2_KERNEL_REGION_BASE - SZ_32M)
31+
#define MODULES_END (CONFIG_NIOS2_KERNEL_REGION_BASE - 1)
2932

3033
struct mm_struct;
3134

arch/nios2/kernel/module.c

+4-15
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,12 @@
2121

2222
#include <asm/cacheflush.h>
2323

24-
/*
25-
* Modules should NOT be allocated with kmalloc for (obvious) reasons.
26-
* But we do it for now to avoid relocation issues. CALL26/PCREL26 cannot reach
27-
* from 0x80000000 (vmalloc area) to 0xc00000000 (kernel) (kmalloc returns
28-
* addresses in 0xc0000000)
29-
*/
3024
void *module_alloc(unsigned long size)
3125
{
32-
if (size == 0)
33-
return NULL;
34-
return kmalloc(size, GFP_KERNEL);
35-
}
36-
37-
/* Free memory returned from module_alloc */
38-
void module_memfree(void *module_region)
39-
{
40-
kfree(module_region);
26+
return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
27+
GFP_KERNEL, PAGE_KERNEL_EXEC,
28+
VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
29+
__builtin_return_address(0));
4130
}
4231

4332
int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,

0 commit comments

Comments
 (0)