Allocating kernel memory within a specific range.
Benjamin Herrenschmidt
benh at kernel.crashing.org
Sat Mar 6 10:59:05 EST 2004
On Sat, 2004-03-06 at 06:30, Igor Grobman wrote:
> Hello ppc64 hackers.
>
> I have a question, which might seem a bit weird at first, but bear with
> me. I would like to get at kernel memory that lies within 32MB of kernel
> code (i.e. within the range of the unconditional branch instruction). In
> other words, I would like to get at memory between the end of kernel code
> and address 0xc000000001FFFFFF. As far as I can tell, this memory is
> available to the memory allocator, but whenever I call kmalloc() I tend to
> get addresses that are 180MB away or more. Is there a way to massage
> kmalloc() or some other function into giving me what I want? I am not
> asking for an officially published interface, just something that I could
> get working in my kernel module.
Nothing that works after kernel mm is initialized. You can reserve
memory early during boot though, using the lmb_ mecanism, which provides
some alignement & limits for allocations. (in prom.c). But that's a bit
scary, don't think about using that for more than in-house experiments.
> An alternative would be to get memory in the
> 0xBFFFFFFFFE000000-0xBFFFFFFFFFFFFFFF range. From what I understand, this
> is close to impossible, since the upper 21 bits are not considered in
> addressing (except the high nibble).
>
> In case you are curious why I need this. I am working on a port of
> KernInst, a tool that allows dynamically splicing code into a running
> kernel, thus allowing dynamic kernel modification. I need to be able to
> overwrite a single instruction atomically with a jump to the modified
> code. The 32MB requirement requirement is due to range of the branch
> instruction.
Another possibility is to play MMU mapping tricks and map the last page
of the virtual address space & use absolute branches.
> Thanks for any and all ideas.
> -Igor
>
--
Benjamin Herrenschmidt <benh at kernel.crashing.org>
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list