我的汇编代码在调用 xbegin 时引发非法指令。
有什么问题吗?
这是我的代码。
主.c
if ( rtm_begin() == 0 ) {
//do something.
}
rtm.S
rtm_begin:
xbegin 1f
mov $0, %rax
retq
1:
mov $-1, %rax
retq
.globl rtm_end
.type rtm_end, @function
.section .text
最佳答案
首先你需要检查你的汇编版本是否支持TSX说明与否。
那可能是你的 CPU 没有 TSX 功能。根据 Intel® 64 和 IA-32 架构软件开发人员手册,ch.16.3.1.2 Detection of RTM Support :
A processor supports RTM execution if CPUID.07H.EBX.RTM [bit 11] = 1. An application must check if the processor supports RTM before it uses the RTM instructions (XBEGI N, XEND, XABORT). These instructions will generate a #UD exception when used on a processor that does not support RTM.
同样为了缓解 Zombieload 2 漏洞,TSX 可以被操作系统禁用(相关信息 for Windows,for Linux)
关于assembly - 汇编程序 xbegin 引发非法指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59209381/