Hi,
I'm not sure this is the right place to post my message, but I do need
some advice for my problem.
I have a special user application who needs to access any part of the
kernel memory. My question is therefore how to make the whole memory
accessible for that particular application ?
Thanks.
On Thu, Apr 28, 2005 at 04:52:21PM -0700, Gilles Pokam wrote:
> I have a special user application who needs to access any part of
> the kernel memory.
why & for what?
> My question is therefore how to make the whole memory accessible for
> that particular application ?
maybe /dev/kmem or /proc/kcore
it would help if you explain in more detail what you are trying to do
On 4/28/05, Chris Wedgwood <[email protected]> wrote:
> On Thu, Apr 28, 2005 at 04:52:21PM -0700, Gilles Pokam wrote:
>
> > I have a special user application who needs to access any part of
> > the kernel memory.
>
> why & for what?
>
> > My question is therefore how to make the whole memory accessible for
> > that particular application ?
>
> maybe /dev/kmem or /proc/kcore
>
> it would help if you explain in more detail what you are trying to do
>
Here is the big picture of the what (detailed are omitted):
I'm experimenting with system to help developers debug their programs.
The debugger is based on a replayer whose purpose is to
deterministically replay the last millions of instructions that lead
to a crash. On the user site, when the program runs, a trace of load
values along with some architectural state is continuously recorded.
Upon a crash, this trace is sent to the developer for debugging. At
the developer site, the application is replayed as follows. The
architectural state is initialized by reading the values from the
trace. The execution then proceeds as follows. If a load instruction
is encountered, the value is taken from the trace. Otherwise all other
instructions execute normally.
Issues:
Now, there are cases where a load value read from the trace (a virtual
address) raises a pagefault exception at the execution because the
address is invalid (the OS has not mapped this address) or the
accessed page doesn't have the right protection. In such cases,
instead of having the program to segfault, I want to handle this as a
valid pagefault, returning a page at the place. One other constraint
is that the application that is being debugged must not be modified.
I was thinking of making the whole memory accessible to handle this.
But I can not rely on mapping /dev/mem or /proc/kcore into the user
space since this would require modifying the binary. Are there other
ways of doing this ? May be disabling paging ? if so, how to do this ?
Thanks for any suggestions.
Gilles
On Thu, Apr 28, 2005 at 10:33:16PM -0700, Gilles Pokam wrote:
> I was thinking of making the whole memory accessible to handle this.
> But I can not rely on mapping /dev/mem or /proc/kcore into the user
> space since this would require modifying the binary. Are there other
> ways of doing this ? May be disabling paging ? if so, how to do this
> ?
why can't you use a wrapper?
On 4/28/05, Chris Wedgwood <[email protected]> wrote:
> On Thu, Apr 28, 2005 at 10:33:16PM -0700, Gilles Pokam wrote:
>
> > I was thinking of making the whole memory accessible to handle this.
> > But I can not rely on mapping /dev/mem or /proc/kcore into the user
> > space since this would require modifying the binary. Are there other
> > ways of doing this ? May be disabling paging ? if so, how to do this
> > ?
>
> why can't you use a wrapper?
Can you be more explicit ?
Thanks.
Gilles
On Thu, Apr 28, 2005 at 10:48:31PM -0700, Gilles Pokam wrote:
> Can you be more explicit ?
why can't you have the parent process of whatever your tracing mess
with /dev/kmem or whatever so you don't have to frob the original
binary?
i guess it's not really clear to me what you're doing entirely
On 4/28/05, Chris Wedgwood <[email protected]> wrote:
> On Thu, Apr 28, 2005 at 10:48:31PM -0700, Gilles Pokam wrote:
>
> > Can you be more explicit ?
>
> why can't you have the parent process of whatever your tracing mess
> with /dev/kmem or whatever so you don't have to frob the original
> binary?
I see the point. Just to test this solution, I tried before to modify
a test application by mmaping /dev/mem into the application address
range. Since I don't know apriori which address is going to raise a
pagefault, I had to mmap the entire memory to the user space. However
this doesn't work. It looks like there is a limitation on the amount
of memory you can mmap ?
> i guess it's not really clear to me what you're doing entirely
the simplest way to say is: I want the pagefault handler to return a
memory page when it encounters a pagefault exceptions due to an
invalid address or incorrect page protection.
Thanks.
Gilles
On Thu, Apr 28, 2005 at 11:45:40PM -0700, Gilles Pokam wrote:
> the simplest way to say is: I want the pagefault handler to return a
> memory page when it encounters a pagefault exceptions due to an
> invalid address or incorrect page protection.
where should this page come from?
On 4/28/05, Chris Wedgwood <[email protected]> wrote:
> On Thu, Apr 28, 2005 at 11:45:40PM -0700, Gilles Pokam wrote:
>
> > the simplest way to say is: I want the pagefault handler to return a
> > memory page when it encounters a pagefault exceptions due to an
> > invalid address or incorrect page protection.
>
> where should this page come from?
One way is to make the pagefault handler return a new vma that
contains the faulty address when such a scenario is encountered. The
normal pagefault mechanism will then apply by the time that address
gets accessed again since the address will now be valid. So a page
will be allocated. But I don't know how what should be changed in the
kernel to enable this behavior.