This patch series adds the infrastructure required to support kprobes in Thumb code. As it stands, it allows probes to be inserted onto NOP instructions.
Work Remaining --------------
- Add decoding and emulation code for all the different Thumb instructions. - Make framework test for probes on conditionally executed instructions and not execute callback functions if the relevant condition isn't met. - Write test code for all Thumb and ARM instruction types. (Does Linux have in tree test code or do I need to stash this elsewhere?)
Open Issue ----------
32-bit Thumb breakpoints may straddle two memory words, which means that when we set or clear them there is a window of opportunity where another CPU may only see half of the new instruction and execute invalid code. To prevent this I've used stop_machine() to get all CPUs to synchronously modify the instruction and update their I-caches. To my thinking, something like this would also be needed so that other CPUs see the new instruction, otherwise they could indefinately be executing the old one from their local I-cache.
The problem with using stop_machine() is that the breakpoint setting code is called from enable_kprobe() which holds the text_mutex and has this comment which says:
since [the breakpoint setting code] doesn't use stop_machine(), this doesn't cause deadlock on text_mutex. So, we don't need get_online_cpus()
Now I am using stop_machine() I need to understand what the consequences and alternatives are.
I do note, that when probes are disabled, the existing ARM kprobe implementation uses stop_machine() and we have a similar issue with this being called from disarm_kprobe() which takes the text_mutex.