1

As you might know it is possible to list all the mapped physical addresses and their respected virtual addresses for user space applications using /proc/$pid/maps

Is there any way to do the same and find virtual addresses of all mapped physical addresses, mapped by ioremap() in kernel space? (Assuming that we can run code in kernel space.)

Gil Hamilton
  • 11,973
  • 28
  • 51
Sama Azari
  • 377
  • 4
  • 17
  • 2
    Maybe [this](http://lxr.free-electrons.com/source/arch/arm/mm/dump.c) will help. – Sam Protsenko Jul 05 '15 at 11:40
  • @SamProtsenko Thanks ! – Sama Azari Jul 07 '15 at 09:57
  • @SamProtsenko Now I want to know if I can compile it independently? Or I have to compile the whole kernel to run it? – Sama Azari Jul 07 '15 at 11:15
  • You need to recompile the whole kernel with `CONFIG_ARM_PTDUMP` option enabled (there is no option to build it as loadable module). Also I hope you realize that this is only applicable for ARM architecture. – Sam Protsenko Jul 07 '15 at 11:47
  • @SamProtsenko Sure, I understand, Actually I looked for the code in other variants of kernels for ARM Linux, which is slightly different. However I was hoping to be able to read the kernel Page Table without recompiling the whole Kernel. – Sama Azari Jul 07 '15 at 11:49
  • 1
    Well, you can try to modify `dump.c` so it can be built as module, and then build it as module :) Basically you just need to replace `__initcallcall()` with something like `module_init()` and then choose to build this code as module (`CONFIG_ARM_PTDUMP=m`). Then just build this module and load it. I'm not sure though if it's gonna work with those modifications, but I'd say go for it, maybe it's just what you're looking for. – Sam Protsenko Jul 07 '15 at 12:13
  • @SamProtsenko Super, I will follow this path, will get back here and write if it works for future... – Sama Azari Jul 07 '15 at 13:02
  • @SamProtsenko Just as a hypothesis it might be possible to find mapped addresses by finding the base address of the driver module in kernel space using /proc/modules. – Sama Azari Jul 07 '15 at 13:46

0 Answers0