A simple signal like mechanism could quickly dispatch the Coprocessor Not Available exception back to user space using siginfo and a ucontext_t with the state of the lwp at the time of exception. The FP user code can then do the emulation, fixup the ucontext_t contents as needed, and then clean up with a setcontext(ucp) to resume execution. This does mean that setcontext will need to be able to restore entire context, not just the callee-saved registers.
This also means you can try different emulators without having to recompile your kernel or reboot. You've already taken the exception into the kernel for Coprocessor Not Available. You still need to return to userspace. The only difference is where you do the emulation. The flexibility you get by placing letting usermode do the emulation seems to be a clear winner.
One thing to note in this model is that the kernel never really has a copy of the FP state, that state is contained solely in user somewhere, probably in a per-thread context area.
No comments:
Post a Comment