I'm writing thread-switch code in which the kernel dumps relevant state to memory, but the actual thread switch occurs entirely in user mode.
This works fine, except in the case where the preemption point occurs inside a Thumb If-Then (IT) block. In that case, I cannot work out how to restore ITSTATE (i.e. bits [15:10] and [26:25] of the CPSR), since these bits are user RAZ/WI, and in any case it probably doesn't make sense given the semantics of ITSTATE.
What (if any) is the correct way to restore this state without trapping into the kernel?
I have considered rewinding execution and continuing from the IT instruction, but apart from being quite heavy-weight, I'm not sure if this is always possible.
EDIT: interested in ARMv7-A