From: Greg Kroah-Hartman Date: Thu, 27 May 2021 10:23:04 +0000 (+0200) Subject: 5.4-stable patches X-Git-Tag: v5.4.123~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=514d15ebd7b6bf6b7e84d2f8e038fc426ad43b62;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: perf-unwind-fix-separate-debug-info-files-when-using-elfutils-libdw-s-unwinder.patch perf-unwind-set-userdata-for-all-__report_module-paths.patch --- diff --git a/queue-5.4/perf-unwind-fix-separate-debug-info-files-when-using-elfutils-libdw-s-unwinder.patch b/queue-5.4/perf-unwind-fix-separate-debug-info-files-when-using-elfutils-libdw-s-unwinder.patch new file mode 100644 index 00000000000..298a3ccf53d --- /dev/null +++ b/queue-5.4/perf-unwind-fix-separate-debug-info-files-when-using-elfutils-libdw-s-unwinder.patch @@ -0,0 +1,86 @@ +From bf53fc6b5f415cddc7118091cb8fd6a211b2320d Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 4 Dec 2020 09:17:02 -0300 +Subject: perf unwind: Fix separate debug info files when using elfutils' libdw's unwinder + +From: Jan Kratochvil + +commit bf53fc6b5f415cddc7118091cb8fd6a211b2320d upstream. + +elfutils needs to be provided main binary and separate debug info file +respectively. Providing separate debug info file instead of the main +binary is not sufficient. + +One needs to try both supplied filename and its possible cache by its +build-id depending on the use case. + +Signed-off-by: Jan Kratochvil +Tested-by: Jiri Olsa +Cc: Adrian Hunter +Cc: David Ahern +Cc: Ian Rogers +Cc: Namhyung Kim +Signed-off-by: Arnaldo Carvalho de Melo +Cc: "Tommi Rantala" +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/util/unwind-libdw.c | 32 +++++++++++++++++++++++++++----- + 1 file changed, 27 insertions(+), 5 deletions(-) + +--- a/tools/perf/util/unwind-libdw.c ++++ b/tools/perf/util/unwind-libdw.c +@@ -20,10 +20,24 @@ + + static char *debuginfo_path; + ++static int __find_debuginfo(Dwfl_Module *mod __maybe_unused, void **userdata, ++ const char *modname __maybe_unused, Dwarf_Addr base __maybe_unused, ++ const char *file_name, const char *debuglink_file __maybe_unused, ++ GElf_Word debuglink_crc __maybe_unused, char **debuginfo_file_name) ++{ ++ const struct dso *dso = *userdata; ++ ++ assert(dso); ++ if (dso->symsrc_filename && strcmp (file_name, dso->symsrc_filename)) ++ *debuginfo_file_name = strdup(dso->symsrc_filename); ++ return -1; ++} ++ + static const Dwfl_Callbacks offline_callbacks = { +- .find_debuginfo = dwfl_standard_find_debuginfo, ++ .find_debuginfo = __find_debuginfo, + .debuginfo_path = &debuginfo_path, + .section_address = dwfl_offline_section_address, ++ // .find_elf is not set as we use dwfl_report_elf() instead. + }; + + static int __report_module(struct addr_location *al, u64 ip, +@@ -46,16 +60,24 @@ static int __report_module(struct addr_l + mod = dwfl_addrmodule(ui->dwfl, ip); + if (mod) { + Dwarf_Addr s; ++ void **userdatap; + +- dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL); ++ dwfl_module_info(mod, &userdatap, &s, NULL, NULL, NULL, NULL, NULL); ++ *userdatap = dso; + if (s != al->map->start - al->map->pgoff) + mod = 0; + } + + if (!mod) +- mod = dwfl_report_elf(ui->dwfl, dso->short_name, +- (dso->symsrc_filename ? dso->symsrc_filename : dso->long_name), -1, al->map->start - al->map->pgoff, +- false); ++ mod = dwfl_report_elf(ui->dwfl, dso->short_name, dso->long_name, -1, ++ al->map->start - al->map->pgoff, false); ++ if (!mod) { ++ char filename[PATH_MAX]; ++ ++ if (dso__build_id_filename(dso, filename, sizeof(filename), false)) ++ mod = dwfl_report_elf(ui->dwfl, dso->short_name, filename, -1, ++ al->map->start - al->map->pgoff, false); ++ } + + return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1; + } diff --git a/queue-5.4/perf-unwind-set-userdata-for-all-__report_module-paths.patch b/queue-5.4/perf-unwind-set-userdata-for-all-__report_module-paths.patch new file mode 100644 index 00000000000..492f7fdfc7d --- /dev/null +++ b/queue-5.4/perf-unwind-set-userdata-for-all-__report_module-paths.patch @@ -0,0 +1,60 @@ +From 4e1481445407b86a483616c4542ffdc810efb680 Mon Sep 17 00:00:00 2001 +From: Dave Rigby +Date: Thu, 18 Feb 2021 16:56:54 +0000 +Subject: perf unwind: Set userdata for all __report_module() paths + +From: Dave Rigby + +commit 4e1481445407b86a483616c4542ffdc810efb680 upstream. + +When locating the DWARF module for a given address, __find_debuginfo() +requires a 'struct dso' passed via the userdata argument. + +However, this field is only set in __report_module() if the module is +found in via dwfl_addrmodule(), not if it is found later via +dwfl_report_elf(). + +Set userdata irrespective of how the DWARF module was found, as long as +we found a module. + +Fixes: bf53fc6b5f41 ("perf unwind: Fix separate debug info files when using elfutils' libdw's unwinder") +Signed-off-by: Dave Rigby +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211801 +Acked-by: Jan Kratochvil +Acked-by: Jiri Olsa +Link: https://lore.kernel.org/linux-perf-users/20210218165654.36604-1-d.rigby@me.com/ +Signed-off-by: Arnaldo Carvalho de Melo +Cc: "Tommi Rantala" +Signed-off-by: Greg Kroah-Hartman +--- + tools/perf/util/unwind-libdw.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +--- a/tools/perf/util/unwind-libdw.c ++++ b/tools/perf/util/unwind-libdw.c +@@ -60,10 +60,8 @@ static int __report_module(struct addr_l + mod = dwfl_addrmodule(ui->dwfl, ip); + if (mod) { + Dwarf_Addr s; +- void **userdatap; + +- dwfl_module_info(mod, &userdatap, &s, NULL, NULL, NULL, NULL, NULL); +- *userdatap = dso; ++ dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL); + if (s != al->map->start - al->map->pgoff) + mod = 0; + } +@@ -79,6 +77,13 @@ static int __report_module(struct addr_l + al->map->start - al->map->pgoff, false); + } + ++ if (mod) { ++ void **userdatap; ++ ++ dwfl_module_info(mod, &userdatap, NULL, NULL, NULL, NULL, NULL, NULL); ++ *userdatap = dso; ++ } ++ + return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1; + } + diff --git a/queue-5.4/series b/queue-5.4/series index a90508552b3..4fa912b660c 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -2,3 +2,5 @@ bpf-wrap-aux-data-inside-bpf_sanitize_info-container.patch bpf-fix-mask-direction-swap-upon-off-reg-sign-change.patch bpf-no-need-to-simulate-speculative-domain-for-immediates.patch usb-dwc3-gadget-enable-suspend-events.patch +perf-unwind-fix-separate-debug-info-files-when-using-elfutils-libdw-s-unwinder.patch +perf-unwind-set-userdata-for-all-__report_module-paths.patch