Skip to contentSkip to conversation

perf disasm: Fix off-by-one bug in outside check

PATCH Applied Peter Collingbourne 3 participants 6 messages Mar 4 – Mar 10 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf disasm: Fix off-by-one bug in outside check

If a branch target points to one past the end of a function, the branch should be treated as a branch to another function. This can happen e.g. with a tail call to a function that is laid out immediately after the caller.

---
 tools/perf/util/disasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/disasm.c +1 -1
index ddcc488f2e5f0..9e0420e14be19 100644
@@ -384,7 +384,7 @@ static int jump__parse(const struct arch *arch, struct ins_operands *ops, struct
 	start = map__unmap_ip(map, sym->start);
 	end = map__unmap_ip(map, sym->end);
 
-	ops->target.outside = target.addr < start || target.addr > end;
+	ops->target.outside = target.addr < start || target.addr >= end;
 
 	/*
 	 * FIXME: things like this in _cpp_lex_token (gcc's cc1 program):
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Peter Collingbourne

If a branch target points to one past the end of a function, the branch should be treated as a branch to another function. This can happen e.g. with a tail call to a function that is laid out immediately after the caller.

Fixes 751b1783da78 ("perf annotate: Mark jumps to outher functions

with the call arrow")

Thanks!
Ian

Quoted 20 lines
---
 tools/perf/util/disasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/disasm.c +1 -2
index ddcc488f2e5f0..9e0420e14be19 100644
@@ -384,7 +384,7 @@ static int jump__parse(const struct arch *arch, struct ins_operands *ops, struct
        start = map__unmap_ip(map, sym->start);
        end = map__unmap_ip(map, sym->end);
 
-       ops->target.outside = target.addr < start || target.addr > end;
+       ops->target.outside = target.addr < start || target.addr >= end;
 
        /*
         * FIXME: things like this in _cpp_lex_token (gcc's cc1 program):
--

2.53.0.473.g4a7958ca14-goog

maintainer Applied
#2 lore raw
Quoted 7 lines · Ian Rogers
Quoted 6 lines · Peter Collingbourne

If a branch target points to one past the end of a function, the branch should be treated as a branch to another function. This can happen e.g. with a tail call to a function that is laid out immediately after the caller.

Quoted 6 lines
Quoted 2 lines
Fixes 751b1783da78 ("perf annotate: Mark jumps to outher functions

with the call arrow")

Thanks, applied to perf-tools, for v7.0.

- Arnaldo

Quoted 23 lines

Thanks!
Ian

Quoted 20 lines
---
 tools/perf/util/disasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/disasm.c +1 -2
index ddcc488f2e5f0..9e0420e14be19 100644
@@ -384,7 +384,7 @@ static int jump__parse(const struct arch *arch, struct ins_operands *ops, struct
        start = map__unmap_ip(map, sym->start);
        end = map__unmap_ip(map, sym->end);
 
-       ops->target.outside = target.addr < start || target.addr > end;
+       ops->target.outside = target.addr < start || target.addr >= end;
 
        /*
         * FIXME: things like this in _cpp_lex_token (gcc's cc1 program):
--

2.53.0.473.g4a7958ca14-goog

reviewer
#3 lore raw

PATCH 1/1 perf annotate loongarch: Fix off-by-one bug in outside check

In reply to Peter Collingbourne

A copy-paste of an issue fixed by Peter Collingbourne in:
https://lore.kernel.org/linux-perf-users/[email protected]/

---
 tools/perf/util/annotate-arch/annotate-loongarch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate-arch/annotate-loongarch.c +1 -1
index 3aeab453a059..950f34e59e5c 100644
@@ -93,7 +93,7 @@ static int loongarch_jump__parse(const struct arch *arch, struct ins_operands *o
 	start = map__unmap_ip(map, sym->start);
 	end = map__unmap_ip(map, sym->end);
 
-	ops->target.outside = target.addr < start || target.addr > end;
+	ops->target.outside = target.addr < start || target.addr >= end;
 
 	if (maps__find_ams(thread__maps(ms->thread), &target) == 0 &&
 	    map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
maintainer Applied
#4 lore raw

Re: [PATCH v1] perf annotate loongarch: Fix off-by-one bug in outside check

Quoted 2 lines · Ian Rogers

A copy-paste of an issue fixed by Peter Collingbourne in:
https://lore.kernel.org/linux-perf-users/[email protected]/

Thanks, applied to perf-tools, for v7.0.

- Arnaldo

Quoted 20 lines
---
 tools/perf/util/annotate-arch/annotate-loongarch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate-arch/annotate-loongarch.c +1 -1
index 3aeab453a059..950f34e59e5c 100644
@@ -93,7 +93,7 @@ static int loongarch_jump__parse(const struct arch *arch, struct ins_operands *o
 	start = map__unmap_ip(map, sym->start);
 	end = map__unmap_ip(map, sym->end);
 
-	ops->target.outside = target.addr < start || target.addr > end;
+	ops->target.outside = target.addr < start || target.addr >= end;
 
 	if (maps__find_ams(thread__maps(ms->thread), &target) == 0 &&
 	    map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
maintainer Applied
#5 lore raw

Re: [PATCH v1] perf annotate loongarch: Fix off-by-one bug in outside check

In reply to Ian Rogers
Quoted 4 lines · Ian Rogers

A copy-paste of an issue fixed by Peter Collingbourne in:
https://lore.kernel.org/linux-perf-users/[email protected]/

Thanks, applied to perf-tools, for v7.0.

- Arnaldo

Quoted 19 lines
---
 tools/perf/util/annotate-arch/annotate-loongarch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate-arch/annotate-loongarch.c +1 -1
index 3aeab453a059..950f34e59e5c 100644
@@ -93,7 +93,7 @@ static int loongarch_jump__parse(const struct arch *arch, struct ins_operands *o
 	start = map__unmap_ip(map, sym->start);
 	end = map__unmap_ip(map, sym->end);
 
-	ops->target.outside = target.addr < start || target.addr > end;
+	ops->target.outside = target.addr < start || target.addr >= end;
 
 	if (maps__find_ams(thread__maps(ms->thread), &target) == 0 &&
 	    map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
Signature · 1 line
2.53.0.473.g4a7958ca14-goog