On 19 July 2015 at 06:40, Igor R <boost.li...@gmail.com> wrote:
>>> On x86 one can get the current PGD from CR3. What's the right way to
>>> do this on ARM?
>>
>> What's a PGD ?
>
> Page global directory

That doesn't help much -- I don't know x86 terminology and
it's not an ARM term.

>>> But in the recent QEMU version c2_base0 field is absent. Instead,
>>> there's ttbr0[] array. So should I just use ttbr0[current_el]?
>>
>> What are you trying to do inside QEMU with the page tables?
>
> When debugging (via gdbstub), I would like to get the current process
> id by a virtual address. When the virtual address is in the
> user-space, the only way to find the current task_struct I can think
> of is to iterate over all the task_struct's (assuming we know
> task_init and the offsets of the relevant fields), and compare
> task->mm->pgd against the current PGD.

If your kernel is configured with CONFIG_PID_IN_CONTEXTIDR
you can just read the PID out of CONTEXTIDR, which will
be much simpler. (You'd need to expose the contextidr via
gdbstub somehow, but then you'd need to do something in
QEMU to get at the TTBRs too.)

-- PMM

Reply via email to