Hi everyone, I am trying to use the three tsx instructions xbegin, xend, and xabort in marss86.
I pulled the "features" branch of marss86 git repository, which had been claimed to have supported these three RTM instruction. And I compiled and ran the qemu simulator with a configuration file where I configured marss86 by using "-machine shared_l2_tsx". After the simulator has successfully started, I tried to run a program containing these three instructions in the simulator. But it seems that some problems occur unexpectedly. Here I have contructed the simpest assembly programs in order to reveal the problem. ------------------------------------------------------------------------------------------------------ 1 ; tsx_test1.asm a program for nasm for testing tsx instructions: xbegin and xend 2 ; 3 ; assemble: nasm -f elf64 -l tsx_test1.lst tsx_test1.asm 4 ; link: gcc -o tsx_test1 tsx_test1.o 5 6 SECTION .text ; code section 7 global main ; make label available to linker 8 main: 9 mov eax,0xffffffff 10 xbegin 0x00000000 11 xend ----------------------------------------------------------------------------------------------------- 1 ; tsx_test2.asm a program for nasm for testing tsx instructions: xbegin, xend and xabort 2 ; 3 ; assemble: nasm -f elf64 -l tsx_test2.lst tsx_test2.asm 4 ; link: gcc -o tsx_test2 tsx_test2.o 5 SECTION .text ; code section 6 global main ; make label available to linker 7 main: 8 mov eax,0xffffffff 9 mov ecx, 0x0032 10 xbegin 0x00000000 11 sub ecx, 0x0001 12 jecxz AA 13 xabort 0x12 14 jmp BB 15 AA: 16 xend 17 BB: 18 nop 19 ret ----------------------------------------------------------------------------------------------------- I compiled the two assembly code using the assembler nasm nasm -f elf64 -l tsx_test1.lst -o tsx_test1.o tsx_test1.asm nasm -f elf64 -l tsx_test1.lst -o tsx_test1.o tsx_test1.asm And then I link the .o files and generating two 64-bit executables: tsx_test1 and tsx_test2 However, when I ran these two executables I got two errors: $./tsx_test1 Illegal instructions $./tsx_test2 $ I am almost certain that I have generated the correct opcodes for the xbegin, xend and xabort by using nasm assembler. From the two generated .lst file, we can see that the opcodes for these three instructions: XBEGIN C7F8(00000000) XEND 0F01D5 XABORT C6F812 And we can easily double-check the Intel's manual to find that they are correct. However, since the first testing program is just a dummy program with nothing between the transaction. it seems weired to get an "Illegal instruction" error. I suppose the error comes from the use of XEND instruction because when I remove this instruction, compile and run the first test program again, this "Illegal instruction" error message did not show up again. As for the second testing program, I have deliberately designed this program to test how abort behaves. Before the transaction begins, I assign the value 0x0032 to the ecx register at line 9. after the transaction begins, I test if the ecx register has decreased to zero. If this is the case, the program jumps to line 16 and run xend (which will lead to an "Illegal instruction" error message! as has been shown by the first testing program); if this is not true, then the program would run xabort which will lead the program to run the fall-back path from line 11 - deceasing ecx by 1 and test again. So if xabort really controls the program to execute the fall-back path, then the content of register ecx would eventually have become 0 and xend at line 16 would have been executed. However, we did not see any "Illegal instruction" message shown when running the second testing program, which means that the abort instruction might not work properly either. I think I am using the three RTM instructions correctly. But they do not perform as they are expected. Is there any sample code as a guidance for using the three instructions in marss86? Or probably this is a potential bug in the implementation of marss86. Hope to get your reply as to how to solve this problem. Thanks! Sincerely Chao Wang
_______________________________________________ http://www.marss86.org Marss86-Devel mailing list [email protected] https://www.cs.binghamton.edu/mailman/listinfo/marss86-devel
