Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lkm_map

Wolfgang Solfrank wrote:

when playing with the new module framework, I tried to load/unload
the example module.  Loading works like a charm, but when unloading
the module, the system panics with an assertion failure in
uvm_km_pgremove_intrsafe at line 473, i.e. the


I tracked it down to the fact that VM_MAX_KERNEL_ADDRESS is
defined (in sys/arch/amd64/include/vmparam.h) as 0xffffff8000000000.
At the same time the lkm_map (which is used to map modules) is
allocated in sys/arch/amd64/amd64/machdep.c just beyond the kernel
itself (probably in order to be able to use short(er?) calls from
the module into the kernel).  The kernel virtual space starts at
KERNBASE, defined (in sys/arch/amd64/include/param.h) as
0xffffffff80000000.  This results in the lkm_map not being part
of the kernel_map, which then leads to the assertion failure

So the question is, why is VM_MAX_KERNEL_ADDRESS defined this low,
so that the "kernel virtual space", i.e. KERNBASE, is not within
The kernel virtual space is determined by the -cmodel=kernel compile flags, that put it in the 4T-2G region. lkm_map is indeed located where it is to be able to link modules compiled with the same flags (the issue is %rip-relative addressing). Therefore, KERNBASE is 0xffffffff80000000 (4T-2G).

The total address space that is available to pick kernel data space from is 0xffffff8000000000 - KERNBASE. However, that's a very large range, and some kernel data structures blew up when I configured the kernel for the whole range. Also, I ran into some assumptions that only the lower end of the kernel space can be pre-allocated by e.g. kernel text, not the upper part, which would need to be the case for amd64.

So I just used a more limited range at the lower end of the available space.

I don't know if the data structure limitations and code assumptions are still there, perhaps they aren't anymore.

- Frank

Home | Main Index | Thread Index | Old Index