Re: Tracing text poke / kernel self-modifying code (Was: Re: [RFC v2 0/6] x86: dynamic indirect branch promotion)

From: Peter Zijlstra
Date: Thu Aug 29 2019 - 07:46:19 EST


On Thu, Aug 29, 2019 at 12:40:56PM +0300, Adrian Hunter wrote:
> Can you expand on "and ensure the poke_handler preserves the existing
> control flow"? Whatever the INT3-handler does will be traced normally so
> long as it does not itself execute self-modified code.

My thinking was that the code shouldn't change semantics before emitting
the RECORD_TEXT_POKE; but you're right in that that doesn't seem to
matter much.

Either we run the old code or INT3 does 'something'. Then we get
RECORD_TEXT_POKE and finish the poke. Which tells that the moment INT3
stops the new text is in place.

I suppose that works too, and requires less changes.