On Mon, Jun 28, 2010 at 6:34 AM, sam shepperd <samshepp...@gmail.com> wrote:
> On Mon, Jun 28, 2010 at 12:47 AM, Venkatram Tummala > <venkatram...@gmail.com> wrote: > > On Sun, Jun 27, 2010 at 10:05 PM, Mulyadi Santosa > > <mulyadi.sant...@gmail.com> wrote: > >> > >> On Mon, Jun 28, 2010 at 09:54, sam shepperd <samshepp...@gmail.com> > wrote: > >> > Kindly thanks - that helps. However the virtual address of the kernel > >> > symbol I am looking up in memory is not within current->mm. > > > > I see. I think i know what you mean . Your symbol is in kernel address > > space. I think the mm_struct object you are looking for is init_mm . If > so, > > in the above code I wrote, use pgd_offset_k(addr) instead of > pgd_offset(mm, > > addr). I think that is what you are looking for. Correct me if I > > misunderstood you. > > > > Venkatram Tummala > > This is what I need (pgd_offset_k), thank you!! > > On new kernels init_mm is not exported however. Is there a > replacement I can use from a module? mm_struct->mmlist is no longer a > list of all mm's (only swapped mm's). I would like a way to walk from > current->mm to init_mm. Google seems to indicate rmap can do this but > I cannot find any code. > Glad that pgd_offset_k(..) worked. I dont think you can walk through the mm_struct objects. Ideally, there should be no reason for anybody to be accessing all mm_structs. All the kernel should care about is current->mm & init_mm. You should not be poking into somebody's else address space. I understand that you want to do this because init_mm is no longer exported by the kernel. As far as i know, the only way to access init_mm from a kernel module is to do a EXPORT_SYMBOL(..) in the kernel & compile it. As a workaround, you can walkthrough the task_struct objects, and you can get the mm_struct object from the task_struct object. Having said that, its a pretty bad workaround & certainly it will not be accepted by kernel community if at all you care anything about it. Venkatram Tummala