perf intel_pt: Add vmlaunch and vmresume as branches
authorAdrian Hunter <adrian.hunter@intel.com>
Thu, 18 Feb 2021 09:57:52 +0000 (11:57 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 18 Feb 2021 19:13:30 +0000 (16:13 -0300)
In preparation to support Intel PT decoding of virtual machine traces, add
vmlaunch and vmresume as branch instructions.

Note, sample flags will show "VMentry" even if the VM-Entry fails.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20210218095801.19576-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/x86/tests/insn-x86.c
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h

index 745f29a..f782ef8 100644 (file)
@@ -48,6 +48,7 @@ static int get_op(const char *op_str)
                {"int",     INTEL_PT_OP_INT},
                {"syscall", INTEL_PT_OP_SYSCALL},
                {"sysret",  INTEL_PT_OP_SYSRET},
+               {"vmentry",  INTEL_PT_OP_VMENTRY},
                {NULL, 0},
        };
        struct val_data *val;
index fb8a355..2f6cc7e 100644 (file)
@@ -43,6 +43,17 @@ static void intel_pt_insn_decoder(struct insn *insn,
        switch (insn->opcode.bytes[0]) {
        case 0xf:
                switch (insn->opcode.bytes[1]) {
+               case 0x01:
+                       switch (insn->modrm.bytes[0]) {
+                       case 0xc2: /* vmlaunch */
+                       case 0xc3: /* vmresume */
+                               op = INTEL_PT_OP_VMENTRY;
+                               branch = INTEL_PT_BR_INDIRECT;
+                               break;
+                       default:
+                               break;
+                       }
+                       break;
                case 0x05: /* syscall */
                case 0x34: /* sysenter */
                        op = INTEL_PT_OP_SYSCALL;
@@ -213,6 +224,7 @@ const char *branch_name[] = {
        [INTEL_PT_OP_INT]       = "Int",
        [INTEL_PT_OP_SYSCALL]   = "Syscall",
        [INTEL_PT_OP_SYSRET]    = "Sysret",
+       [INTEL_PT_OP_VMENTRY]   = "VMentry",
 };
 
 const char *intel_pt_insn_name(enum intel_pt_insn_op op)
@@ -267,6 +279,9 @@ int intel_pt_insn_type(enum intel_pt_insn_op op)
        case INTEL_PT_OP_SYSRET:
                return PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN |
                       PERF_IP_FLAG_SYSCALLRET;
+       case INTEL_PT_OP_VMENTRY:
+               return PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL |
+                      PERF_IP_FLAG_VMENTRY;
        default:
                return 0;
        }
index 95a1eb0..c2861cf 100644 (file)
@@ -24,6 +24,7 @@ enum intel_pt_insn_op {
        INTEL_PT_OP_INT,
        INTEL_PT_OP_SYSCALL,
        INTEL_PT_OP_SYSRET,
+       INTEL_PT_OP_VMENTRY,
 };
 
 enum intel_pt_insn_branch {