gpt4 book ai didi

assembly - x86 上的零变化跳转是否会清除指令预取队列?

转载 作者:行者123 更新时间:2023-12-03 09:38:58 25 4
gpt4 key购买 nike

在 x86 上,有人可以确认零位移跳转(即不改变 CS 或 IP 中的值的跳转)是否清除指令预取队列?

最佳答案

跳转到无论如何都会执行的下一条语句确实会清除任何具有指令预取队列的 Intel x86 CPU 上的指令预取队列。在自修改代码中这样做是很常见的,以确保实际执行修改后的代码。英特尔已经将使用跳转作为一种手段,以确保即使在现代 CPU 上也能正确执行自我修改的代码。
来自 Intel 64 and IA-32 Architectures Software Developer’s ManualVolume 3: System Programming Guide :

8.1.3 Handling Self- and Cross-Modifying Code

...

As processor microarchitectures become more complex and start to speculatively execute code ahead of the retirementpoint (as in P6 and more recent processor families), the rules regarding which code should execute, pre- orpost-modification, become blurred. To write self-modifying code and ensure that it is compliant with current andfuture versions of the IA-32 architectures, use one of the following coding options:

(* OPTION 1 *)
Store modified code (as data) into code segment;
Jump to new code or an intermediate location;
Execute new code;

(选项 2 是使用序列化指令而不是跳转,但这些在早期的 x86 CPU 上不存在。)

关于assembly - x86 上的零变化跳转是否会清除指令预取队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43241618/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com