--------------23B5855350071B8457B26204
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
sumanth wrote:
>
> Is there a way to determine the page offset (usually 0xC0000000)
> from a loaded kernel module dynamically? This becomes a problem when
> trying to insert modules into kernels that might have a different page
> offset than the one the module was compiled with. For example, if the
> PAGE_OFFSET macro in page.h has been changed to say 0x80000000 to
> accomodate a 2g + 2g kernel/user space as opposed to the more usual 1g
> + 3g kernel/user division
> this will cause the module that uses the wrong PAGE_OFFSET value to do
> extremely weird things. Is there a
> consistent, relatively kernel-independent way of dealing with this?
PAGE_OFFSET itself isn't exported. hmm, if you know what you're
doing i guess you could play games like in the attached example module ;)
(i only tried this on 2.3.12)
--------------23B5855350071B8457B26204
Content-Type: text/plain; charset=us-ascii; name="kpo.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="kpo.c"
//gcc -O2 -fomit-frame-pointer -Wall -D__KERNEL__=1 -DMODULE=1 -I/usr/src/linux/include/ -c kpo.c
//insmod ./kpo.o
#include <asm/segment.h>
#include <asm/current.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
EXPORT_NO_SYMBOLS;
#undef PAGE_OFFSET
unsigned long PAGE_OFFSET;
int init_module(void)
{
//PAGE_OFFSET = find_task_by_pid(1)->addr_limit.seg;
PAGE_OFFSET = current->addr_limit.seg;
printk( KERN_DEBUG "PAGE_OFFSET=0x%08lx\n", PAGE_OFFSET );
return -1;
}
void cleanup_module(void)
{
}
--------------23B5855350071B8457B26204--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/