x86上的零变化跳转会清除指令预取队列吗? [英] Does a zero change jump on x86 clear the instruction prefetch queue?

查看:96
本文介绍了x86上的零变化跳转会清除指令预取队列吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On the x86, can someone confirm, whether or not a zero displacement jump (i.e. a jump that doesn't alter the values in CS or IP) clears the Instruction Prefetch Queue?

推荐答案

跳转到将始终执行的下一条语句会清除任何具有一个的Intel x86 CPU上的指令预取队列.在自修改代码中这样做通常是很常见的,以确保修改后的代码得以实际执行.英特尔到目前为止已经记录了使用跳转的方法,以确保即使在现代CPU上也能正确执行自行修改的代码.

A jump to the next statement that would have been executed anyways does clear the instruction prefetch queue on any Intel x86 CPU that has one. It was a common to do so in self-modifying code in order to ensure that modified code was actually executed. Intel has gone so far as to document using a jump as means to ensure that self-modified code gets executed correctly even on modern CPUs.

来自英特尔64和IA-32体系结构软件开发人员手册 第3卷:系统编程指南:

From Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 3: System Programming Guide:

8.1.3处理自修改代码和交叉修改代码

...

随着处理器的微体系结构变得越来越复杂,并在退休之前开始推测性地执行代码 点(例如在P6和更新的处理器系列中),有关应执行,预执行或预执行的代码的规则 后修改,变得模糊.编写自我修改的代码并确保其符合当前和 IA-32体系结构的未来版本,请使用以下编码选项之一:

As processor microarchitectures become more complex and start to speculatively execute code ahead of the retirement point (as in P6 and more recent processor families), the rules regarding which code should execute, pre- or post-modification, become blurred. To write self-modifying code and ensure that it is compliant with current and future 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上不存在这些指令.)

(Option 2 is to use a serializing instruction instead of a jump, but these don't exist on early x86 CPUs.)

这篇关于x86上的零变化跳转会清除指令预取队列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆