当前位置: 动力学知识库 > 问答 > 编程问答 >

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.

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: