On 04/18/2016 06:13 PM, Michael Matz wrote: > On Mon, 18 Apr 2016, Andrew Haley wrote: > >> On 04/15/2016 06:29 PM, Alexander Monakov wrote: >> >>> Alternatively: replace first nop with a short forward branch that >>> jumps over the rest of the pad, patch rest of the pad, patch the >>> initial forward branch. >> >> That may not be safe. Consider an implementation which looks ahead in >> the instruction stream and decodes the instructions speculatively. > > It should go without saying that patching instructions is followed by > whatever means necessary to flush any such caches on a particular > implementation (here after patching the jump, after patching the rest, and > after patching the first insn again, i.e. three times).
That doesn't necessarily help you, though, without an ISB in the reading thread. Andrew.