On Thu Mar 16, 2017 at 13:33:18 +0100, Denis Huber wrote:
Why not use ex_regs() on the thread to trigger an exception. That way, the attached userland exception handler can introspect the thread's complete register set. It can also alter the registers, so that the thread continues to run with the modified register set.
Is there anything more you need?
I already tried ex_regs(). The problem with this function is, that it does not return all registers, if the thread is in a syscall. It only returns the PC and SP registers.
I think Christian wants to point you to the L4_THREAD_EX_REGS_TRIGGER_EXCEPTION flag that one can give to ex_regs() that triggers an exception for the thread. With this exception all the CPU state will be delivered.
A thread's userland registers are stored on every entry to the kernel. The class in Fiasco is called Entry_frame.
The userland exception handler mentioned above modifies that Entry_frame.
Where does the kernel store the Entry_frame object for each thread? Is it the location where Context::regs() points to?
Yes.
When the scheduler selects a thread, its userland state (Entry_frame) is restored on exit from kernel mode.
Can you point to the function that executes this code?
There are several places, for all architectures in the assembly paths. For x86 in entry.S, look for code paths with 'iret' in them. For ARM in ivt.S, look for return_from_exception.
Adam