Reproducing Unexpected Behavior w/Cross-Modifying Code on x86-64 CPUs

前端 未结 2 1526
刺人心
刺人心 2021-02-13 18:36

Question

What are some ideas for cross-modifying code that could trigger unexpected behavior on x86 or x86-x64 systems, where everything is done correctly in the cross

2条回答
  •  太阳男子
    2021-02-13 19:21

    The odds you can repro this behavior are very close to zero. First keep in mind that self- and cross-modifying code is nothing unusual. Happens every day when, say, you use a debugger and set a breakpoint or modify memory. Or when a DLL gets loaded and it needs to be relocated to a different address.

    Even if you intentionally omit the serializing instruction, you'd still have a hard time avoiding one to tinker with the code of the other processor. Simple things you need, like implementing the synchronization or changing the page protection attributes so you can modify the code are very likely to go through a code path inside the operating system that will serialize.

    Furthermore, the errata and the FUD email you quoted are old, they date back to the time that multi-core processors first became commonly available. Intel always documents recommended approaches that work on any processor, including ones that did not have the erratum fixed. Whether current models still actually require the serializing instruction is hard to discover.

    Best not to waste your time on this.

提交回复
热议问题