Allocating kernel memory within a specific range.

Igor Grobman igor at
Sat Mar 6 06:30:09 EST 2004

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.

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

Thanks for any and all ideas.

** Sent via the linuxppc64-dev mail list. See

More information about the Linuxppc64-dev mailing list