On Wed, 2 Nov 2016, Jiri Kosina wrote: > 5) Patching scheduler functions > > Patching schedule() is a tricky operation, as it returns with a different stack. > New schedule() generated by compiler might be completely different. Hence if a > task enters new schedule() and returns with a stack that has been set up by the > old schedule(), explosion happens. > > Steven suggested to make the %rip saving conditional on livepatching being turned > on, and doesn't see an issue with that. > > Vlastimil noted that upon starting of the live patching (and enabling the static > branch), all the running tasks would need to have their thread_ip updated in task > struct. > > The conclusion has quickly been reached that we would pursue this upstream. Good news. We do not have to do anything here. It should be ok with 4.9 thanks to commit 0100301bfdf5 ("sched/x86: Rewrite the switch_to() code") from Brian Gerst. There is __switch_to_asm function now (implemented in assembly) called properly from context_switch(). RIP is thus saved on the stack and a task would return to proper version of schedule() et al. functions. Of course __switch_to_asm() is not patchable for the reason described above. But there is no __fentry__ call and I cannot imagine a reason to do it anyway. Miroslav -- To unsubscribe from this list: send the line "unsubscribe live-patching" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html