Reading thread registers

Denis Huber huber.denis at ...435...
Fri Mar 3 08:35:28 CET 2017


Hallo Christian, and hallo Genode community.

Preliminary: I want to read the registers of a thread A from a task from 
another thread B on another task. I am using Genode 16.08 on Fiasco.OC. 
I am also using the Genode mechanism of Cpu_thread::pause() before 
Cpu_thread::state(), but do not receive the any register values beside 
zeros. Christina told me that this problem comes from thread A being in 
a syscall during the pausing. His suggestion was to extend 
l4_thread_ex_regs_ret() to return the missing registers from the UTCB in 
a non-blocking fashion.

I am trying to do this, but I do not understand the syscall mechanism 
fully. Am I correct with the following understanding:

* Thread A is in a syscall: It is waiting for the answer of its IPC call.
* The answer will be stored in the UTCB.
* While the thread is waiting, another thread B tries to pause thread A.
* The pause mechanism wants to put thread A into an artifical-exception 
state and additionally writes the register data to the UTCB of thread A.
* The pause and syscall mechanism both need the UTCB for themselves.
* To guarantee consistency of the UTCB, the pause method is not allowed 
to be executed while thread A is in a syscall. Otherwise the syscall 
could overrite the pause data (i.e. register values), if it 
spontaneously returns.

Assumed my understanding is correct (please tell me, if it is not), I 
have to wait (i.e. block execution) until the syscall finishes and the 
pause mechanism can write the register data to the UTCB. Christian 
wrote, it is possible to return the missing registers from the UTCB 
without blocking until the syscall finishes. How is it possible, if the 
register data is not in the UTCB?


Kind regards,
Denis

On 30.08.2016 14:49, Denis Huber wrote:
> Hallo Christian,
>
> thank you for your answer. It helped me a lot :)
>
> Best regards,
> Denis
>
> On 30.08.2016 14:34, Christian Prochaska wrote:
>> Hi Denis,
>>
>> On 25.08.2016 15:45, Denis Huber wrote:
>>> Is it possible to aquire the thread's registers through simply reading
>>> them in the UTCB which is pointed by Thread_state::utcb? If yes, what is
>>> the layout of the UTCB in the memory?
>>> Or do I also have to pause the thread to find relevant registers?
>>
>> the thread's registers can be read from the UTCB in userland if the
>> kernel saved them there. On Fiasco.OC, this currently only happens when
>> an exception occurs ('Thread::exception()' in thread-ipc.cpp links
>> '_utcb_handler' to the trap state, which is then copied into the UTCB in
>> 'Thread::copy_ts_to_utcb()' in thread-arm.cpp). When pausing the thread,
>> an artificial exception is triggered, which causes the kernel to copy
>> the thread state into the UTCB. Therefore, it is necessary to pause the
>> thread before the register values are available in the UTCB.
>>
>> Regards,
>> Christian
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> genode-main mailing list
>> genode-main at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/genode-main
>>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> genode-main mailing list
> genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
>




More information about the users mailing list