Skip to contentSkip to conversation

perf/urgent fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 5 messages Sep 1, 2015 – Sep 2, 2015 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit 532026612455a4a6fd27c1b2e7111263f63218a2:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2015-09-01 10:25:57 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo

for you to fetch changes up to af4aeadd8c04303c0aa2d112145c3627e2ebd026:

perf tools: Fix link time error with sample_reg_masks on non x86 (2015-09-01 13:04:41 -0300)

----------------------------------------------------------------
perf/urgent fixes:

- Fix link time error with sample_reg_masks on non x86 (Stephane Eranian)

- Fix potential array out of bounds access (Wang Nan)

- Fix Intel PT instruction decoder dependency problem (Wang Nan)

----------------------------------------------------------------
Stephane Eranian (1):
perf tools: Fix link time error with sample_reg_masks on non x86

Wang Nan (2):
perf dwarf: Fix potential array out of bounds access perf build: Fix Intel PT instruction decoder dependency problem

 tools/perf/arch/sh/util/dwarf-regs.c    |  2 +-
 tools/perf/arch/sparc/util/dwarf-regs.c |  2 +-
 tools/perf/arch/x86/util/dwarf-regs.c   |  2 +-
 tools/perf/arch/x86/util/perf_regs.c    | 44 ++++++++++++++++-----------------
 tools/perf/util/intel-pt-decoder/Build  |  1 +
 tools/perf/util/perf_regs.c             |  4 +++
 tools/perf/util/perf_regs.h             |  2 ++
 7 files changed, 31 insertions(+), 26 deletions(-)
author maintainer
#1 lore raw

PATCH 1/3 perf dwarf: Fix potential array out of bounds access

From: Wang Nan <[email protected]>

There is a problem in the dwarf-regs.c files for sh, sparc and x86 where it is possible to make an out-of-bounds array access when searching for register names.

This patch fixes it by replacing '<=' to '<', so when register (number == XXX_MAX_REGS), get_arch_regstr() will return NULL.

---
 tools/perf/arch/sh/util/dwarf-regs.c    | 2 +-
 tools/perf/arch/sparc/util/dwarf-regs.c | 2 +-
 tools/perf/arch/x86/util/dwarf-regs.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/arch/sh/util/dwarf-regs.c +1 -1
index 0d0897f57a10..f8dfa89696f4 100644
@@ -51,5 +51,5 @@ const char *sh_regs_table[SH_MAX_REGS] = {
 /* Return architecture dependent register string (for kprobe-tracer) */
 const char *get_arch_regstr(unsigned int n)
 {
-	return (n <= SH_MAX_REGS) ? sh_regs_table[n] : NULL;
+	return (n < SH_MAX_REGS) ? sh_regs_table[n] : NULL;
 }
tools/perf/arch/sparc/util/dwarf-regs.c +1 -1
index 92eda412fed3..b704fdb9237a 100644
@@ -39,5 +39,5 @@ const char *sparc_regs_table[SPARC_MAX_REGS] = {
  */
 const char *get_arch_regstr(unsigned int n)
 {
-	return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL;
+	return (n < SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL;
 }
tools/perf/arch/x86/util/dwarf-regs.c +1 -1
index be22dd463232..a08de0a35b83 100644
@@ -71,5 +71,5 @@ const char *x86_64_regs_table[X86_64_MAX_REGS] = {
 /* Return architecture dependent register string (for kprobe-tracer) */
 const char *get_arch_regstr(unsigned int n)
 {
-	return (n <= ARCH_MAX_REGS) ? arch_regs_table[n] : NULL;
+	return (n < ARCH_MAX_REGS) ? arch_regs_table[n] : NULL;
 }
Signature · 1 line
2.1.0
author maintainer
#2 lore raw

PATCH 2/3 perf build: Fix Intel PT instruction decoder dependency problem

In reply to Arnaldo Carvalho de Melo

From: Wang Nan <[email protected]>

I hit following building error randomly:

    ...
  /bin/sh: /path/to/kernel/buildperf/util/intel-pt-decoder/inat-tables.c: No such file or directory
    ...
    LINK     /path/to/kernel/buildperf/plugin_mac80211.so
    LINK     /path/to/kernel/buildperf/plugin_kmem.so
    LINK     /path/to/kernel/buildperf/plugin_xen.so
    LINK     /path/to/kernel/buildperf/plugin_hrtimer.so
  In file included from util/intel-pt-decoder/intel-pt-insn-decoder.c:25:0:
  util/intel-pt-decoder/inat.c:24:25: fatal error: inat-tables.c: No such file or directory
   #include "inat-tables.c"
                           ^

compilation terminated.
make[4]: *** [/path/to/kernel/buildperf/util/intel-pt-decoder/intel-pt-insn-decoder.o] Error 1 make[4]: *** Waiting for unfinished jobs....
LINK /path/to/kernel/buildperf/plugin_function.so

This is caused by tools/perf/util/intel-pt-decoder/Build that, it tries to generate $(OUTPUT)util/intel-pt-decoder/inat-tables.c atomatically but forget to ensure the existance of $(OUTPUT)util/intel-pt-decoder directory.

This patch fixes it by adding $(call rule_mkdir) like other similar rules.

---
 tools/perf/util/intel-pt-decoder/Build | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/intel-pt-decoder/Build +1 -0
index 240730d682c1..2386322ece4f 100644
@@ -4,6 +4,7 @@ inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk
 inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt
 
 $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
+	$(call rule_mkdir)
 	@$(call echo-cmd,gen)$(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ || rm -f $@
 
 $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c
Signature · 1 line
2.1.0
author maintainer
#3 lore raw

PATCH 3/3 perf tools: Fix link time error with sample_reg_masks on non x86

In reply to Arnaldo Carvalho de Melo

From: Stephane Eranian <[email protected]>

This patch makes perf compile on non x86 platforms by defining a weak symbol for sample_reg_masks[] in util/perf_regs.c.

The patch also moves the REG() and REG_END() macros into the util/per_regs.h header file. The macros are renamed to SMPL_REG/SMPL_REG_END to avoid clashes with other header files.

---
 tools/perf/arch/x86/util/perf_regs.c | 44 +++++++++++++++++-------------------
 tools/perf/util/perf_regs.c          |  4 ++++
 tools/perf/util/perf_regs.h          |  2 ++
 3 files changed, 27 insertions(+), 23 deletions(-)
tools/perf/arch/x86/util/perf_regs.c +21 -23
index 087c84ef5234..c5db14f36cc7 100644
@@ -1,30 +1,28 @@
 #include "../../perf.h"
 #include "../../util/perf_regs.h"
 
-#define REG(n, b) { .name = #n, .mask = 1ULL << (b) }
-#define REG_END { .name = NULL }
 const struct sample_reg sample_reg_masks[] = {
-	REG(AX, PERF_REG_X86_AX),
-	REG(BX, PERF_REG_X86_BX),
-	REG(CX, PERF_REG_X86_CX),
-	REG(DX, PERF_REG_X86_DX),
-	REG(SI, PERF_REG_X86_SI),
-	REG(DI, PERF_REG_X86_DI),
-	REG(BP, PERF_REG_X86_BP),
-	REG(SP, PERF_REG_X86_SP),
-	REG(IP, PERF_REG_X86_IP),
-	REG(FLAGS, PERF_REG_X86_FLAGS),
-	REG(CS, PERF_REG_X86_CS),
-	REG(SS, PERF_REG_X86_SS),
+	SMPL_REG(AX, PERF_REG_X86_AX),
+	SMPL_REG(BX, PERF_REG_X86_BX),
+	SMPL_REG(CX, PERF_REG_X86_CX),
+	SMPL_REG(DX, PERF_REG_X86_DX),
+	SMPL_REG(SI, PERF_REG_X86_SI),
+	SMPL_REG(DI, PERF_REG_X86_DI),
+	SMPL_REG(BP, PERF_REG_X86_BP),
+	SMPL_REG(SP, PERF_REG_X86_SP),
+	SMPL_REG(IP, PERF_REG_X86_IP),
+	SMPL_REG(FLAGS, PERF_REG_X86_FLAGS),
+	SMPL_REG(CS, PERF_REG_X86_CS),
+	SMPL_REG(SS, PERF_REG_X86_SS),
 #ifdef HAVE_ARCH_X86_64_SUPPORT
-	REG(R8, PERF_REG_X86_R8),
-	REG(R9, PERF_REG_X86_R9),
-	REG(R10, PERF_REG_X86_R10),
-	REG(R11, PERF_REG_X86_R11),
-	REG(R12, PERF_REG_X86_R12),
-	REG(R13, PERF_REG_X86_R13),
-	REG(R14, PERF_REG_X86_R14),
-	REG(R15, PERF_REG_X86_R15),
+	SMPL_REG(R8, PERF_REG_X86_R8),
+	SMPL_REG(R9, PERF_REG_X86_R9),
+	SMPL_REG(R10, PERF_REG_X86_R10),
+	SMPL_REG(R11, PERF_REG_X86_R11),
+	SMPL_REG(R12, PERF_REG_X86_R12),
+	SMPL_REG(R13, PERF_REG_X86_R13),
+	SMPL_REG(R14, PERF_REG_X86_R14),
+	SMPL_REG(R15, PERF_REG_X86_R15),
 #endif
-	REG_END
+	SMPL_REG_END
 };
tools/perf/util/perf_regs.c +4 -0
index 43168fb0d9a2..885e8ac83997 100644
@@ -2,6 +2,10 @@
 #include "perf_regs.h"
 #include "event.h"
 
+const struct sample_reg __weak sample_reg_masks[] = {
+	SMPL_REG_END
+};
+
 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
 {
 	int i, idx = 0;
tools/perf/util/perf_regs.h +2 -0
index 92c1fff2153e..2984dcc54d67 100644
@@ -9,6 +9,8 @@ struct sample_reg {
 	const char *name;
 	uint64_t mask;
 };
+#define SMPL_REG(n, b) { .name = #n, .mask = 1ULL << (b) }
+#define SMPL_REG_END { .name = NULL }
 
 extern const struct sample_reg sample_reg_masks[];
 
Signature · 1 line
2.1.0
#4 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 37 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit 532026612455a4a6fd27c1b2e7111263f63218a2:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2015-09-01 10:25:57 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo

for you to fetch changes up to af4aeadd8c04303c0aa2d112145c3627e2ebd026:

perf tools: Fix link time error with sample_reg_masks on non x86 (2015-09-01 13:04:41 -0300)

----------------------------------------------------------------
perf/urgent fixes:

- Fix link time error with sample_reg_masks on non x86 (Stephane Eranian)

- Fix potential array out of bounds access (Wang Nan)

- Fix Intel PT instruction decoder dependency problem (Wang Nan)

----------------------------------------------------------------
Stephane Eranian (1):
perf tools: Fix link time error with sample_reg_masks on non x86

Wang Nan (2):
perf dwarf: Fix potential array out of bounds access perf build: Fix Intel PT instruction decoder dependency problem

Quoted 8 lines
 tools/perf/arch/sh/util/dwarf-regs.c    |  2 +-
 tools/perf/arch/sparc/util/dwarf-regs.c |  2 +-
 tools/perf/arch/x86/util/dwarf-regs.c   |  2 +-
 tools/perf/arch/x86/util/perf_regs.c    | 44 ++++++++++++++++-----------------
 tools/perf/util/intel-pt-decoder/Build  |  1 +
 tools/perf/util/perf_regs.c             |  4 +++
 tools/perf/util/perf_regs.h             |  2 ++
 7 files changed, 31 insertions(+), 26 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo