From 4104e83567e9b478ee7465444509ab6ecb6304b9 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sat, 14 Jan 2012 00:36:07 +0000 Subject: [PATCH] Fix kernel modules loading for MIPS64 kernel: On amd64, link_elf_obj.c must specify KERNBASE rather than VM_MIN_KERNEL_ADDRESS to vm_map_find() because kernel loadable modules must be mapped for execution in the same upper region of the kernel map as the kernel code and data segments. For MIPS32 KERNBASE lies below KVA area (it's less than VM_MIN_KERNEL_ADDRESS) so basically vm_map_find got whole KVA to look through. On MIPS64 it's not the case because KERNBASE is set to the very end of XKSEG, well out of KVA bounds, so vm_map_find always fails. We should use VM_MIN_KERNEL_ADDRESS as a base for vm_map_find. Details obtained from: alc@ --- sys/kern/link_elf_obj.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index a5a815d2fd24..135614ccad8a 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -684,7 +684,11 @@ link_elf_load_file(linker_class_t cls, const char *filename, * location of code and data in the kernel's address space, request a * mapping that is above the kernel. */ +#ifdef __amd64__ mapbase = KERNBASE; +#else + mapbase = VM_MIN_KERNEL_ADDRESS; +#endif error = vm_map_find(kernel_map, ef->object, 0, &mapbase, round_page(mapsize), TRUE, VM_PROT_ALL, VM_PROT_ALL, FALSE); if (error) {