linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] perf intel-pt: Small updates
@ 2023-03-20 18:35 Adrian Hunter
  2023-03-20 18:35 ` [PATCH 1/2] perf intel-pt: Add event type names UINTR and UIRET Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Adrian Hunter @ 2023-03-20 18:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel, linux-perf-users

Hi

Here are 2 small updates for Intel PT.

The first is just a couple of new event type names.

The second is a small change to Intel PT as it relates to
Intel FRED.  The patch is standalone but, for anyone
interested, you can search LKML for FRED to find out more
about Intel FRED implementation.


Adrian Hunter (2):
      perf intel-pt: Add event type names UINTR and UIRET
      perf intel-pt: Add support for new branch instructions ERETS and ERETU

 tools/perf/arch/x86/tests/insn-x86.c                   |  4 ++++
 tools/perf/builtin-script.c                            |  2 +-
 .../perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 18 ++++++++++++++++++
 .../perf/util/intel-pt-decoder/intel-pt-insn-decoder.h |  2 ++
 4 files changed, 25 insertions(+), 1 deletion(-)


Regards
Adrian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] perf intel-pt: Add event type names UINTR and UIRET
  2023-03-20 18:35 [PATCH 0/2] perf intel-pt: Small updates Adrian Hunter
@ 2023-03-20 18:35 ` Adrian Hunter
  2023-03-20 18:35 ` [PATCH 2/2] perf intel-pt: Add support for new branch instructions ERETS and ERETU Adrian Hunter
  2023-03-20 18:40 ` [PATCH 0/2] perf intel-pt: Small updates Ian Rogers
  2 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2023-03-20 18:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel, linux-perf-users

UINTR and UIRET are listed in table 32-50 "CFE Packet Type and Vector
Fields Details" in the Intel Processor Trace chapter of The Intel SDM
Volume 3 version 078.

The codes are for "User interrupt delivered" and "Exiting from user
interrupt routine" respectively.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 976f8bfe099c..c9296d8b33c0 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1906,7 +1906,7 @@ static int perf_sample__fprintf_synth_evt(struct perf_sample *sample, FILE *fp)
 	struct perf_synth_intel_evt *data = perf_sample__synth_ptr(sample);
 	const char *cfe[32] = {NULL, "INTR", "IRET", "SMI", "RSM", "SIPI",
 			       "INIT", "VMENTRY", "VMEXIT", "VMEXIT_INTR",
-			       "SHUTDOWN"};
+			       "SHUTDOWN", NULL, "UINTR", "UIRET"};
 	const char *evd[64] = {"PFA", "VMXQ", "VMXR"};
 	const char *s;
 	int len, i;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] perf intel-pt: Add support for new branch instructions ERETS and ERETU
  2023-03-20 18:35 [PATCH 0/2] perf intel-pt: Small updates Adrian Hunter
  2023-03-20 18:35 ` [PATCH 1/2] perf intel-pt: Add event type names UINTR and UIRET Adrian Hunter
@ 2023-03-20 18:35 ` Adrian Hunter
  2023-03-20 18:40 ` [PATCH 0/2] perf intel-pt: Small updates Ian Rogers
  2 siblings, 0 replies; 5+ messages in thread
From: Adrian Hunter @ 2023-03-20 18:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Ian Rogers, linux-kernel, linux-perf-users

Intel Flexible Return and Event Delivery (FRED) adds instructions ERETS
(return to supervisor) and ERETU (return to user). Intel PT instruction
decoder needs to know about these instructions because they are
branch instructions. Similar to IRET instructions, when the decoder
encounters one of these instructions it will match it to a TIP (target
instruction pointer) packet that informs what the branch destination is.

The existing "x86 instruction decoder - new instructions" test can be
used to test the result e.g.

  $ perf test -v ins |& grep eret
  Decoded ok: f2 0f 01 ca         erets
  Decoded ok: f3 0f 01 ca         eretu

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/arch/x86/tests/insn-x86.c           |  4 ++++
 .../intel-pt-decoder/intel-pt-insn-decoder.c   | 18 ++++++++++++++++++
 .../intel-pt-decoder/intel-pt-insn-decoder.h   |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/tools/perf/arch/x86/tests/insn-x86.c b/tools/perf/arch/x86/tests/insn-x86.c
index 94b490c434d0..735257d205b5 100644
--- a/tools/perf/arch/x86/tests/insn-x86.c
+++ b/tools/perf/arch/x86/tests/insn-x86.c
@@ -29,6 +29,8 @@ struct test_data test_data_64[] = {
 #include "insn-x86-dat-64.c"
 	{{0x0f, 0x01, 0xee}, 3, 0, NULL, NULL, "0f 01 ee             \trdpkru"},
 	{{0x0f, 0x01, 0xef}, 3, 0, NULL, NULL, "0f 01 ef             \twrpkru"},
+	{{0xf2, 0x0f, 0x01, 0xca}, 4, 0, "erets", "indirect", "f2 0f 01 ca  \terets"},
+	{{0xf3, 0x0f, 0x01, 0xca}, 4, 0, "eretu", "indirect", "f3 0f 01 ca  \teretu"},
 	{{0}, 0, 0, NULL, NULL, NULL},
 };
 
@@ -49,6 +51,8 @@ static int get_op(const char *op_str)
 		{"syscall", INTEL_PT_OP_SYSCALL},
 		{"sysret",  INTEL_PT_OP_SYSRET},
 		{"vmentry",  INTEL_PT_OP_VMENTRY},
+		{"erets",   INTEL_PT_OP_ERETS},
+		{"eretu",   INTEL_PT_OP_ERETU},
 		{NULL, 0},
 	};
 	struct val_data *val;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
index 22308dd93010..c5d57027ec23 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
@@ -52,6 +52,20 @@ static void intel_pt_insn_decoder(struct insn *insn,
 				op = INTEL_PT_OP_VMENTRY;
 				branch = INTEL_PT_BR_INDIRECT;
 				break;
+			case 0xca:
+				switch (insn->prefixes.bytes[3]) {
+				case 0xf2: /* erets */
+					op = INTEL_PT_OP_ERETS;
+					branch = INTEL_PT_BR_INDIRECT;
+					break;
+				case 0xf3: /* eretu */
+					op = INTEL_PT_OP_ERETU;
+					branch = INTEL_PT_BR_INDIRECT;
+					break;
+				default:
+					break;
+				}
+				break;
 			default:
 				break;
 			}
@@ -230,6 +244,8 @@ const char *branch_name[] = {
 	[INTEL_PT_OP_SYSCALL]	= "Syscall",
 	[INTEL_PT_OP_SYSRET]	= "Sysret",
 	[INTEL_PT_OP_VMENTRY]	= "VMentry",
+	[INTEL_PT_OP_ERETS]	= "Erets",
+	[INTEL_PT_OP_ERETU]	= "Eretu",
 };
 
 const char *intel_pt_insn_name(enum intel_pt_insn_op op)
@@ -273,6 +289,8 @@ int intel_pt_insn_type(enum intel_pt_insn_op op)
 	case INTEL_PT_OP_LOOP:
 		return PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL;
 	case INTEL_PT_OP_IRET:
+	case INTEL_PT_OP_ERETS:
+	case INTEL_PT_OP_ERETU:
 		return PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN |
 		       PERF_IP_FLAG_INTERRUPT;
 	case INTEL_PT_OP_INT:
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h
index e3338b56a75f..7fb7fe3a1566 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h
@@ -25,6 +25,8 @@ enum intel_pt_insn_op {
 	INTEL_PT_OP_SYSCALL,
 	INTEL_PT_OP_SYSRET,
 	INTEL_PT_OP_VMENTRY,
+	INTEL_PT_OP_ERETS,
+	INTEL_PT_OP_ERETU,
 };
 
 enum intel_pt_insn_branch {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] perf intel-pt: Small updates
  2023-03-20 18:35 [PATCH 0/2] perf intel-pt: Small updates Adrian Hunter
  2023-03-20 18:35 ` [PATCH 1/2] perf intel-pt: Add event type names UINTR and UIRET Adrian Hunter
  2023-03-20 18:35 ` [PATCH 2/2] perf intel-pt: Add support for new branch instructions ERETS and ERETU Adrian Hunter
@ 2023-03-20 18:40 ` Ian Rogers
  2023-03-20 22:25   ` Arnaldo Carvalho de Melo
  2 siblings, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2023-03-20 18:40 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim, linux-kernel,
	linux-perf-users

On Mon, Mar 20, 2023 at 11:35 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Hi
>
> Here are 2 small updates for Intel PT.
>
> The first is just a couple of new event type names.
>
> The second is a small change to Intel PT as it relates to
> Intel FRED.  The patch is standalone but, for anyone
> interested, you can search LKML for FRED to find out more
> about Intel FRED implementation.
>

Series:
Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> Adrian Hunter (2):
>       perf intel-pt: Add event type names UINTR and UIRET
>       perf intel-pt: Add support for new branch instructions ERETS and ERETU
>
>  tools/perf/arch/x86/tests/insn-x86.c                   |  4 ++++
>  tools/perf/builtin-script.c                            |  2 +-
>  .../perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 18 ++++++++++++++++++
>  .../perf/util/intel-pt-decoder/intel-pt-insn-decoder.h |  2 ++
>  4 files changed, 25 insertions(+), 1 deletion(-)
>
>
> Regards
> Adrian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] perf intel-pt: Small updates
  2023-03-20 18:40 ` [PATCH 0/2] perf intel-pt: Small updates Ian Rogers
@ 2023-03-20 22:25   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-20 22:25 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Adrian Hunter, Jiri Olsa, Namhyung Kim, linux-kernel, linux-perf-users

Em Mon, Mar 20, 2023 at 11:40:06AM -0700, Ian Rogers escreveu:
> On Mon, Mar 20, 2023 at 11:35 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
> >
> > Hi
> >
> > Here are 2 small updates for Intel PT.
> >
> > The first is just a couple of new event type names.
> >
> > The second is a small change to Intel PT as it relates to
> > Intel FRED.  The patch is standalone but, for anyone
> > interested, you can search LKML for FRED to find out more
> > about Intel FRED implementation.
> >
> 
> Series:
> Acked-by: Ian Rogers <irogers@google.com>

Thanks, applied.

- Arnaldo


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-20 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20 18:35 [PATCH 0/2] perf intel-pt: Small updates Adrian Hunter
2023-03-20 18:35 ` [PATCH 1/2] perf intel-pt: Add event type names UINTR and UIRET Adrian Hunter
2023-03-20 18:35 ` [PATCH 2/2] perf intel-pt: Add support for new branch instructions ERETS and ERETU Adrian Hunter
2023-03-20 18:40 ` [PATCH 0/2] perf intel-pt: Small updates Ian Rogers
2023-03-20 22:25   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).