Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting pointer to the current translation table on MIPS (Linux)

Long story short: I'd like to get the pointer to the current process' first level translation table on MIPS.

On x86 I get it from CR3. On ARM I use TTBR for this purpose. How to do this on MIPS (without accessing current task_struct->mm->pgd)?

Here is some elaboration on why I need it.

I have to get some info on the current process in Linux running in QEMU system emulator. My code runs on the host, as a part of QEMU. Lets assume that I know all the relevant offsets in the guest kernel structures.

When the guest is in kernel mode (if it's not a kernel thread), it is possible to get the current task_struct directly, via thread_info that is located on the kernel stack.

However, when the guest is in user mode, I have to traverse the task_struct list, comparing each task->mm->pgd (actually the appropriate physical address) to the current translation table pointer. The latter is what I'm looking for.

like image 875
Igor R. Avatar asked Dec 09 '25 07:12

Igor R.


1 Answers

The PTE base address can be read from the MIPS CP0 Context register (#4).

See chapter 16 of See MIPS Run: Low-level Memory Management and the TLB.

like image 162
markgz Avatar answered Dec 11 '25 01:12

markgz