Skip to content

Commit f83b6b6

Browse files
ahunter6acmel
authored andcommitted
x86/insn: perf tools: Add new xsave instructions
Add xsavec, xsaves and xrstors to the op code map and the perf tools new instructions test. To run the test: $ tools/perf/perf test "x86 ins" 39: Test x86 instruction decoder - new instructions : Ok Or to see the details: $ tools/perf/perf test -v "x86 ins" 2>&1 | grep 'xsave\|xrst' For information about xsavec, xsaves and xrstors, refer the Intel SDM. Signed-off-by: Adrian Hunter <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Qiaowei Ren <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 978260c commit f83b6b6

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

arch/x86/lib/x86-opcode-map.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ EndTable
899899

900900
GrpTable: Grp9
901901
1: CMPXCHG8B/16B Mq/Mdq
902+
3: xrstors
903+
4: xsavec
904+
5: xsaves
902905
6: VMPTRLD Mq | VMCLEAR Mq (66) | VMXON Mq (F3) | RDRAND Rv (11B)
903906
7: VMPTRST Mq | VMPTRST Mq (F3) | RDSEED Rv (11B)
904907
EndTable

tools/perf/tests/insn-x86-dat-32.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,5 +636,23 @@
636636
"0f ae 30 \txsaveopt (%eax)",},
637637
{{0x0f, 0xae, 0xf0, }, 3, 0, "", "",
638638
"0f ae f0 \tmfence ",},
639+
{{0x0f, 0xc7, 0x20, }, 3, 0, "", "",
640+
"0f c7 20 \txsavec (%eax)",},
641+
{{0x0f, 0xc7, 0x25, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
642+
"0f c7 25 78 56 34 12 \txsavec 0x12345678",},
643+
{{0x0f, 0xc7, 0xa4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
644+
"0f c7 a4 c8 78 56 34 12 \txsavec 0x12345678(%eax,%ecx,8)",},
645+
{{0x0f, 0xc7, 0x28, }, 3, 0, "", "",
646+
"0f c7 28 \txsaves (%eax)",},
647+
{{0x0f, 0xc7, 0x2d, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
648+
"0f c7 2d 78 56 34 12 \txsaves 0x12345678",},
649+
{{0x0f, 0xc7, 0xac, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
650+
"0f c7 ac c8 78 56 34 12 \txsaves 0x12345678(%eax,%ecx,8)",},
651+
{{0x0f, 0xc7, 0x18, }, 3, 0, "", "",
652+
"0f c7 18 \txrstors (%eax)",},
653+
{{0x0f, 0xc7, 0x1d, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
654+
"0f c7 1d 78 56 34 12 \txrstors 0x12345678",},
655+
{{0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
656+
"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%eax,%ecx,8)",},
639657
{{0x66, 0x0f, 0xae, 0xf8, }, 4, 0, "", "",
640658
"66 0f ae f8 \tpcommit ",},

tools/perf/tests/insn-x86-dat-64.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,5 +734,35 @@
734734
"41 0f ae 30 \txsaveopt (%r8)",},
735735
{{0x0f, 0xae, 0xf0, }, 3, 0, "", "",
736736
"0f ae f0 \tmfence ",},
737+
{{0x0f, 0xc7, 0x20, }, 3, 0, "", "",
738+
"0f c7 20 \txsavec (%rax)",},
739+
{{0x41, 0x0f, 0xc7, 0x20, }, 4, 0, "", "",
740+
"41 0f c7 20 \txsavec (%r8)",},
741+
{{0x0f, 0xc7, 0x24, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
742+
"0f c7 24 25 78 56 34 12 \txsavec 0x12345678",},
743+
{{0x0f, 0xc7, 0xa4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
744+
"0f c7 a4 c8 78 56 34 12 \txsavec 0x12345678(%rax,%rcx,8)",},
745+
{{0x41, 0x0f, 0xc7, 0xa4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
746+
"41 0f c7 a4 c8 78 56 34 12 \txsavec 0x12345678(%r8,%rcx,8)",},
747+
{{0x0f, 0xc7, 0x28, }, 3, 0, "", "",
748+
"0f c7 28 \txsaves (%rax)",},
749+
{{0x41, 0x0f, 0xc7, 0x28, }, 4, 0, "", "",
750+
"41 0f c7 28 \txsaves (%r8)",},
751+
{{0x0f, 0xc7, 0x2c, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
752+
"0f c7 2c 25 78 56 34 12 \txsaves 0x12345678",},
753+
{{0x0f, 0xc7, 0xac, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
754+
"0f c7 ac c8 78 56 34 12 \txsaves 0x12345678(%rax,%rcx,8)",},
755+
{{0x41, 0x0f, 0xc7, 0xac, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
756+
"41 0f c7 ac c8 78 56 34 12 \txsaves 0x12345678(%r8,%rcx,8)",},
757+
{{0x0f, 0xc7, 0x18, }, 3, 0, "", "",
758+
"0f c7 18 \txrstors (%rax)",},
759+
{{0x41, 0x0f, 0xc7, 0x18, }, 4, 0, "", "",
760+
"41 0f c7 18 \txrstors (%r8)",},
761+
{{0x0f, 0xc7, 0x1c, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
762+
"0f c7 1c 25 78 56 34 12 \txrstors 0x12345678",},
763+
{{0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
764+
"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%rax,%rcx,8)",},
765+
{{0x41, 0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
766+
"41 0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%r8,%rcx,8)",},
737767
{{0x66, 0x0f, 0xae, 0xf8, }, 4, 0, "", "",
738768
"66 0f ae f8 \tpcommit ",},

tools/perf/tests/insn-x86-dat-src.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,30 @@ int main(void)
445445
asm volatile("xsaveopt (%r8)");
446446
asm volatile("mfence");
447447

448+
/* xsavec mem */
449+
450+
asm volatile("xsavec (%rax)");
451+
asm volatile("xsavec (%r8)");
452+
asm volatile("xsavec (0x12345678)");
453+
asm volatile("xsavec 0x12345678(%rax,%rcx,8)");
454+
asm volatile("xsavec 0x12345678(%r8,%rcx,8)");
455+
456+
/* xsaves mem */
457+
458+
asm volatile("xsaves (%rax)");
459+
asm volatile("xsaves (%r8)");
460+
asm volatile("xsaves (0x12345678)");
461+
asm volatile("xsaves 0x12345678(%rax,%rcx,8)");
462+
asm volatile("xsaves 0x12345678(%r8,%rcx,8)");
463+
464+
/* xrstors mem */
465+
466+
asm volatile("xrstors (%rax)");
467+
asm volatile("xrstors (%r8)");
468+
asm volatile("xrstors (0x12345678)");
469+
asm volatile("xrstors 0x12345678(%rax,%rcx,8)");
470+
asm volatile("xrstors 0x12345678(%r8,%rcx,8)");
471+
448472
#else /* #ifdef __x86_64__ */
449473

450474
/* bndmk m32, bnd */
@@ -822,6 +846,24 @@ int main(void)
822846
asm volatile("xsaveopt (%eax)");
823847
asm volatile("mfence");
824848

849+
/* xsavec mem */
850+
851+
asm volatile("xsavec (%eax)");
852+
asm volatile("xsavec (0x12345678)");
853+
asm volatile("xsavec 0x12345678(%eax,%ecx,8)");
854+
855+
/* xsaves mem */
856+
857+
asm volatile("xsaves (%eax)");
858+
asm volatile("xsaves (0x12345678)");
859+
asm volatile("xsaves 0x12345678(%eax,%ecx,8)");
860+
861+
/* xrstors mem */
862+
863+
asm volatile("xrstors (%eax)");
864+
asm volatile("xrstors (0x12345678)");
865+
asm volatile("xrstors 0x12345678(%eax,%ecx,8)");
866+
825867
#endif /* #ifndef __x86_64__ */
826868

827869
/* pcommit */

tools/perf/util/intel-pt-decoder/x86-opcode-map.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ EndTable
899899

900900
GrpTable: Grp9
901901
1: CMPXCHG8B/16B Mq/Mdq
902+
3: xrstors
903+
4: xsavec
904+
5: xsaves
902905
6: VMPTRLD Mq | VMCLEAR Mq (66) | VMXON Mq (F3) | RDRAND Rv (11B)
903906
7: VMPTRST Mq | VMPTRST Mq (F3) | RDSEED Rv (11B)
904907
EndTable

0 commit comments

Comments
 (0)