diff mbox series

[4/5] perf: arm_spe: Decode memory tagging properties

Message ID 20200922101225.183554-5-andre.przywara@arm.com (mailing list archive)
State New, archived
Headers show
Series perf: arm64: Support ARMv8.3-SPE extensions | expand

Commit Message

Andre Przywara Sept. 22, 2020, 10:12 a.m. UTC
When SPE records a physical address, it can additionally tag the event
with information from the Memory Tagging architecture extension.

Decode the two additional fields in the SPE event payload.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 .../util/arm-spe-decoder/arm-spe-pkt-decoder.c  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Comments

Leo Yan Sept. 27, 2020, 3:19 a.m. UTC | #1
On Tue, Sep 22, 2020 at 11:12:24AM +0100, Andre Przywara wrote:
> When SPE records a physical address, it can additionally tag the event
> with information from the Memory Tagging architecture extension.
> 
> Decode the two additional fields in the SPE event payload.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  .../util/arm-spe-decoder/arm-spe-pkt-decoder.c  | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> index 943e4155b246..a033f34846a6 100644
> --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> @@ -8,13 +8,14 @@
>  #include <string.h>
>  #include <endian.h>
>  #include <byteswap.h>
> +#include <linux/bits.h>
>  
>  #include "arm-spe-pkt-decoder.h"
>  
> -#define BIT(n)		(1ULL << (n))
> -
>  #define NS_FLAG		BIT(63)
>  #define EL_FLAG		(BIT(62) | BIT(61))
> +#define CH_FLAG		BIT(62)
> +#define PAT_FLAG	GENMASK_ULL(59, 56)
>  
>  #define SPE_HEADER0_PAD			0x0
>  #define SPE_HEADER0_END			0x1
> @@ -447,10 +448,16 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
>  			return snprintf(buf, buf_len, "%s 0x%llx el%d ns=%d",
>  				        (idx == 1) ? "TGT" : "PC", payload, el, ns);
>  		case 2:	return snprintf(buf, buf_len, "VA 0x%llx", payload);
> -		case 3:	ns = !!(packet->payload & NS_FLAG);
> +		case 3:	{
> +			int ch = !!(packet->payload & CH_FLAG);
> +			int pat = (packet->payload & PAT_FLAG) >> 56;
> +
> +			ns = !!(packet->payload & NS_FLAG);
>  			payload &= ~(0xffULL << 56);
> -			return snprintf(buf, buf_len, "PA 0x%llx ns=%d",
> -					payload, ns);
> +			return snprintf(buf, buf_len,
> +					"PA 0x%llx ns=%d ch=%d, pat=%x",
> +					payload, ns, ch, pat);
> +			}

Reviewed-by: Leo Yan <leo.yan@linaro.org>

>  		default: return 0;
>  		}
>  	case ARM_SPE_CONTEXT:
> -- 
> 2.17.1
>
Arnaldo Carvalho de Melo Oct. 13, 2020, 2:51 p.m. UTC | #2
Em Sun, Sep 27, 2020 at 11:19:18AM +0800, Leo Yan escreveu:
> On Tue, Sep 22, 2020 at 11:12:24AM +0100, Andre Przywara wrote:
> > When SPE records a physical address, it can additionally tag the event
> > with information from the Memory Tagging architecture extension.
> > 
> > Decode the two additional fields in the SPE event payload.
> > 
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
> >  .../util/arm-spe-decoder/arm-spe-pkt-decoder.c  | 17 ++++++++++++-----
> >  1 file changed, 12 insertions(+), 5 deletions(-)
> > 
> > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> > index 943e4155b246..a033f34846a6 100644
> > --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> > @@ -8,13 +8,14 @@
> >  #include <string.h>
> >  #include <endian.h>
> >  #include <byteswap.h>
> > +#include <linux/bits.h>
> >  
> >  #include "arm-spe-pkt-decoder.h"
> >  
> > -#define BIT(n)		(1ULL << (n))
> > -
> >  #define NS_FLAG		BIT(63)
> >  #define EL_FLAG		(BIT(62) | BIT(61))
> > +#define CH_FLAG		BIT(62)
> > +#define PAT_FLAG	GENMASK_ULL(59, 56)
> >  
> >  #define SPE_HEADER0_PAD			0x0
> >  #define SPE_HEADER0_END			0x1
> > @@ -447,10 +448,16 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
> >  			return snprintf(buf, buf_len, "%s 0x%llx el%d ns=%d",
> >  				        (idx == 1) ? "TGT" : "PC", payload, el, ns);
> >  		case 2:	return snprintf(buf, buf_len, "VA 0x%llx", payload);
> > -		case 3:	ns = !!(packet->payload & NS_FLAG);
> > +		case 3:	{
> > +			int ch = !!(packet->payload & CH_FLAG);
> > +			int pat = (packet->payload & PAT_FLAG) >> 56;
> > +
> > +			ns = !!(packet->payload & NS_FLAG);
> >  			payload &= ~(0xffULL << 56);
> > -			return snprintf(buf, buf_len, "PA 0x%llx ns=%d",
> > -					payload, ns);
> > +			return snprintf(buf, buf_len,
> > +					"PA 0x%llx ns=%d ch=%d, pat=%x",
> > +					payload, ns, ch, pat);
> > +			}
> 
> Reviewed-by: Leo Yan <leo.yan@linaro.org>

Thanks, applied.

- Arnaldo
Arnaldo Carvalho de Melo Oct. 13, 2020, 2:52 p.m. UTC | #3
Em Tue, Oct 13, 2020 at 11:51:03AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sun, Sep 27, 2020 at 11:19:18AM +0800, Leo Yan escreveu:
> > On Tue, Sep 22, 2020 at 11:12:24AM +0100, Andre Przywara wrote:
> > > When SPE records a physical address, it can additionally tag the event
> > > with information from the Memory Tagging architecture extension.
> > > 
> > > Decode the two additional fields in the SPE event payload.
> > > 
> > > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > > ---
> > >  .../util/arm-spe-decoder/arm-spe-pkt-decoder.c  | 17 ++++++++++++-----
> > >  1 file changed, 12 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> > > index 943e4155b246..a033f34846a6 100644
> > > --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> > > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
> > > @@ -8,13 +8,14 @@
> > >  #include <string.h>
> > >  #include <endian.h>
> > >  #include <byteswap.h>
> > > +#include <linux/bits.h>
> > >  
> > >  #include "arm-spe-pkt-decoder.h"
> > >  
> > > -#define BIT(n)		(1ULL << (n))
> > > -
> > >  #define NS_FLAG		BIT(63)
> > >  #define EL_FLAG		(BIT(62) | BIT(61))
> > > +#define CH_FLAG		BIT(62)
> > > +#define PAT_FLAG	GENMASK_ULL(59, 56)
> > >  
> > >  #define SPE_HEADER0_PAD			0x0
> > >  #define SPE_HEADER0_END			0x1
> > > @@ -447,10 +448,16 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
> > >  			return snprintf(buf, buf_len, "%s 0x%llx el%d ns=%d",
> > >  				        (idx == 1) ? "TGT" : "PC", payload, el, ns);
> > >  		case 2:	return snprintf(buf, buf_len, "VA 0x%llx", payload);
> > > -		case 3:	ns = !!(packet->payload & NS_FLAG);
> > > +		case 3:	{
> > > +			int ch = !!(packet->payload & CH_FLAG);
> > > +			int pat = (packet->payload & PAT_FLAG) >> 56;
> > > +
> > > +			ns = !!(packet->payload & NS_FLAG);
> > >  			payload &= ~(0xffULL << 56);
> > > -			return snprintf(buf, buf_len, "PA 0x%llx ns=%d",
> > > -					payload, ns);
> > > +			return snprintf(buf, buf_len,
> > > +					"PA 0x%llx ns=%d ch=%d, pat=%x",
> > > +					payload, ns, ch, pat);
> > > +			}
> > 
> > Reviewed-by: Leo Yan <leo.yan@linaro.org>
> 
> Thanks, applied.

I take that back, I'm applying Leo's series that Andre reviewed instead.

- Arnaldo
diff mbox series

Patch

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index 943e4155b246..a033f34846a6 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -8,13 +8,14 @@ 
 #include <string.h>
 #include <endian.h>
 #include <byteswap.h>
+#include <linux/bits.h>
 
 #include "arm-spe-pkt-decoder.h"
 
-#define BIT(n)		(1ULL << (n))
-
 #define NS_FLAG		BIT(63)
 #define EL_FLAG		(BIT(62) | BIT(61))
+#define CH_FLAG		BIT(62)
+#define PAT_FLAG	GENMASK_ULL(59, 56)
 
 #define SPE_HEADER0_PAD			0x0
 #define SPE_HEADER0_END			0x1
@@ -447,10 +448,16 @@  int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
 			return snprintf(buf, buf_len, "%s 0x%llx el%d ns=%d",
 				        (idx == 1) ? "TGT" : "PC", payload, el, ns);
 		case 2:	return snprintf(buf, buf_len, "VA 0x%llx", payload);
-		case 3:	ns = !!(packet->payload & NS_FLAG);
+		case 3:	{
+			int ch = !!(packet->payload & CH_FLAG);
+			int pat = (packet->payload & PAT_FLAG) >> 56;
+
+			ns = !!(packet->payload & NS_FLAG);
 			payload &= ~(0xffULL << 56);
-			return snprintf(buf, buf_len, "PA 0x%llx ns=%d",
-					payload, ns);
+			return snprintf(buf, buf_len,
+					"PA 0x%llx ns=%d ch=%d, pat=%x",
+					payload, ns, ch, pat);
+			}
 		default: return 0;
 		}
 	case ARM_SPE_CONTEXT: