assemblyx86illegal-instructionintel-tsx

Assembler xbegin raise Illegal instruction


My assembly code raises Illegal Instruction when calls xbegin.

Is there any problem?

Here is my code.

main.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

Solution

  • First you need to check whether your version of assembler supports the TSX instructions or not.

    Then it could be that your CPU doesn't have TSX feature. As per Intel® 64 and IA-32 architectures software developer’s manual, 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.

    Also to mitigate Zombieload 2 vulnerability, TSX could be disabled by the OS (related info for Windows, for Linux)