lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1472418058-28659-13-git-send-email-maddy@linux.vnet.ibm.com>
Date:   Mon, 29 Aug 2016 02:30:57 +0530
From:   Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>
To:     linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Cc:     Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Jiri Olsa <jolsa@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Stephane Eranian <eranian@...il.com>,
        Russell King <linux@....linux.org.uk>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will.deacon@....com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Subject: [PATCH 12/13] tool/perf: Add perf_arch_reg mask and arch_reg_names structure

Add arch_reg_names structure and define perf_arch_reg_name() function
to aid the printing of arch_regs values. Also, extend regs_dump__printf()
to include perf_arch_regs_mask to enable printing support.

Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Stephane Eranian <eranian@...il.com>
Cc: Russell King <linux@....linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@....com>
Cc: Will Deacon <will.deacon@....com>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>
---
 tools/perf/arch/arm/include/perf_regs.h     |  5 +++++
 tools/perf/arch/arm64/include/perf_regs.h   |  5 +++++
 tools/perf/arch/powerpc/include/perf_regs.h | 25 +++++++++++++++++++++++++
 tools/perf/arch/x86/include/perf_regs.h     |  5 +++++
 tools/perf/builtin-script.c                 |  7 +++++++
 tools/perf/util/perf_regs.h                 |  5 +++++
 tools/perf/util/session.c                   | 12 ++++++++++--
 7 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h
index f619c9c5a4bf..db5a5f0ad439 100644
--- a/tools/perf/arch/arm/include/perf_regs.h
+++ b/tools/perf/arch/arm/include/perf_regs.h
@@ -56,4 +56,9 @@ static inline const char *perf_reg_name(int id)
 	return NULL;
 }
 
+static inline const char *perf_arch_reg_name(int id __maybe_unused)
+{
+	return NULL;
+}
+
 #endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/arch/arm64/include/perf_regs.h b/tools/perf/arch/arm64/include/perf_regs.h
index 4e5af27e3fbf..20f8067b3e93 100644
--- a/tools/perf/arch/arm64/include/perf_regs.h
+++ b/tools/perf/arch/arm64/include/perf_regs.h
@@ -90,4 +90,9 @@ static inline const char *perf_reg_name(int id)
 	return NULL;
 }
 
+static inline const char *perf_arch_reg_name(int id __maybe_unused)
+{
+	return NULL;
+}
+
 #endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/arch/powerpc/include/perf_regs.h b/tools/perf/arch/powerpc/include/perf_regs.h
index 75de0e92e71e..801de6def8da 100644
--- a/tools/perf/arch/powerpc/include/perf_regs.h
+++ b/tools/perf/arch/powerpc/include/perf_regs.h
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <linux/types.h>
 #include <asm/perf_regs.h>
+#include <uapi/asm/perf_regs.h>
 
 #define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
 #define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
@@ -66,4 +67,28 @@ static inline const char *perf_reg_name(int id)
 {
 	return reg_names[id];
 }
+
+static const char *arch_reg_names[] = {
+	[PERF_ARCH_REG_POWERPC_PVR] = "pvr",
+	[PERF_ARCH_REG_POWERPC_PMC1] = "pmc1",
+	[PERF_ARCH_REG_POWERPC_PMC2] = "pmc2",
+	[PERF_ARCH_REG_POWERPC_PMC3] = "pmc3",
+	[PERF_ARCH_REG_POWERPC_PMC4] = "pmc4",
+	[PERF_ARCH_REG_POWERPC_PMC5] = "pmc5",
+	[PERF_ARCH_REG_POWERPC_PMC6] = "pmc6",
+	[PERF_ARCH_REG_POWERPC_PMC7] = "pmc7",
+	[PERF_ARCH_REG_POWERPC_PMC8] = "pmc8",
+	[PERF_ARCH_REG_POWERPC_MMCR0] = "mmcr0",
+	[PERF_ARCH_REG_POWERPC_MMCR1] = "mmcr1",
+	[PERF_ARCH_REG_POWERPC_SIER] = "sier",
+	[PERF_ARCH_REG_POWERPC_SIAR] = "siar",
+	[PERF_ARCH_REG_POWERPC_SDAR] = "sdar",
+	[PERF_ARCH_REG_POWERPC_MMCRA] = "mmcra",
+	[PERF_ARCH_REG_POWERPC_MMCR2] = "mmcr2"
+};
+
+static inline const char *perf_arch_reg_name(int id)
+{
+	return arch_reg_names[id];
+}
 #endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index 7df517acfef8..a555541697b3 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -83,4 +83,9 @@ static inline const char *perf_reg_name(int id)
 	return NULL;
 }
 
+static inline const char *perf_arch_reg_name(int id __maybe_unused)
+{
+	return NULL;
+}
+
 #endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index db270b4f892a..c2a84484b95b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -420,6 +420,7 @@ static void print_sample_iregs(struct perf_sample *sample,
 {
 	struct regs_dump *regs = &sample->intr_regs;
 	uint64_t mask = attr->sample_regs_intr;
+	uint64_t arch_regs_mask = regs->arch_regs_mask;
 	unsigned i = 0, r;
 	DECLARE_BITMAP(_mask, 64);
 
@@ -431,6 +432,12 @@ static void print_sample_iregs(struct perf_sample *sample,
 		u64 val = regs->regs[i++];
 		printf("%5s:0x%"PRIx64" ", perf_reg_name(r), val);
 	}
+
+	bitmap_from_u64(_mask, arch_regs_mask);
+	for_each_set_bit(r, _mask, sizeof(mask) * 8) {
+		u64 val = regs->regs[i++];
+		printf("%5s:0x%"PRIx64" ", perf_arch_reg_name(r), val);
+	}
 }
 
 static void print_sample_start(struct perf_sample *sample,
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index 679d6e493962..1a044728bd45 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -29,6 +29,11 @@ static inline const char *perf_reg_name(int id __maybe_unused)
 	return NULL;
 }
 
+static inline const char *perf_arch_reg_name(int id __maybe_unused)
+{
+	return NULL;
+}
+
 static inline int perf_reg_value(u64 *valp __maybe_unused,
 				 struct regs_dump *regs __maybe_unused,
 				 int id __maybe_unused)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 440a9fb2a6fb..ca5c057c88af 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -941,7 +941,7 @@ static void branch_stack__printf(struct perf_sample *sample)
 	}
 }
 
-static void regs_dump__printf(u64 mask, u64 *regs)
+static void regs_dump__printf(u64 mask, u64 arch_regs_mask, u64 *regs)
 {
 	unsigned rid, i = 0;
 	DECLARE_BITMAP(_mask, 64);
@@ -953,6 +953,14 @@ static void regs_dump__printf(u64 mask, u64 *regs)
 		printf(".... %-5s 0x%" PRIx64 "\n",
 		       perf_reg_name(rid), val);
 	}
+
+	bitmap_from_u64(_mask, arch_regs_mask);
+	for_each_set_bit(rid, _mask, sizeof(mask) * 8) {
+		u64 val = regs[i++];
+
+		printf(".... %-5s 0x%" PRIx64 "\n",
+			perf_arch_reg_name(rid), val);
+	}
 }
 
 static const char *regs_abi[] = {
@@ -978,7 +986,7 @@ static void regs__printf(const char *type, struct regs_dump *regs)
 	       mask,
 	       regs_dump_abi(regs));
 
-	regs_dump__printf(mask, regs->regs);
+	regs_dump__printf(mask, regs->arch_regs_mask, regs->regs);
 }
 
 static void regs_user__printf(struct perf_sample *sample)
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ