Observing stale instruction fetching on x86 with self-modifying code

前端 未结 3 626
甜味超标
甜味超标 2020-11-22 13:42

I\'ve been told and have read from Intel\'s manuals that it is possible to write instructions to memory, but the instruction prefetch queue has already fetched the stale ins

3条回答
  •  温柔的废话
    2020-11-22 13:58

    I've been told and have read from Intel's manuals that it is possible to write instructions to memory, but the instruction prefetch queue has [may have] already fetched the stale instructions and will [may] execute those old instructions. I have been unsuccessful in observing this behavior.

    Yes, you would be.

    All or almost all modern Intel processors are stricter than the manual:

    They snoop the pipeline based on physical address, not just linear.

    Processor implementations are allowed to be stricter than the manuals.

    They may choose to be so because they have encountered code that does not adhere to the rules in the manuals, that they do not want to break.

    Or... because the easiest way to adhere to the architectural specification (which in the case of SMC used to be officially "up until the next serializing instruction" but in practice, for legacy code, was "up until the next taken branch that is more than ??? bytes away") might be to be stricter.

提交回复
热议问题