assembly - 汇编程序 xbegin 引发非法指令

标签 assembly x86 illegal-instruction intel-tsx

我的汇编代码在调用 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 Windowsfor Linux)

关于assembly - 汇编程序 xbegin 引发非法指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59209381/

相关文章:

c++ - 在Windows 10上构建并在Windows 7上运行时,为什么会出现 “Illegal Instruction”错误

python - 非法指令 : 4 on MacOS High Sierra

c++ - 如何使用 NASM 创建 .dll 文件?

c - 如何在 Turbo C 的 C 代码中包含汇编代码?

linux - 条件 eax != 0 和 edx == 0?

assembly - 了解 x86 MOV 语法

linux - ELF标签地址

assembly - 在实模式下访问 pci 配置空间

winapi - 如何在不使用高级汇编程序的情况下显示 "Hello, world!"?

linux - 当 skylake 有 fsgsbase 时,为什么使用 __builtin_ia32_wrfsbase64 会收到非法指令?