Commit 830fadfd authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Add bpf image check to __map__is_kmodule

When validating kcore modules the do_validate_kcore_modules function
checks on every kernel module dso against modules record. The
__map__is_kmodule check is used to get only kernel module dso objects
through.

Currently the bpf images are slipping through the check and making the
validation to fail, so report falls back from kcore usage to kallsyms.

Adding __map__is_bpf_image check for bpf image and adding it to
__map__is_kmodule check.

Fixes: 3c29d448 ("perf annotate: Add basic support for bpf_image")
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200826213017.818788-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e48a73a3
...@@ -736,12 +736,6 @@ int machine__process_switch_event(struct machine *machine __maybe_unused, ...@@ -736,12 +736,6 @@ int machine__process_switch_event(struct machine *machine __maybe_unused,
return 0; return 0;
} }
static int is_bpf_image(const char *name)
{
return strncmp(name, "bpf_trampoline_", sizeof("bpf_trampoline_") - 1) == 0 ||
strncmp(name, "bpf_dispatcher_", sizeof("bpf_dispatcher_") - 1) == 0;
}
static int machine__process_ksymbol_register(struct machine *machine, static int machine__process_ksymbol_register(struct machine *machine,
union perf_event *event, union perf_event *event,
struct perf_sample *sample __maybe_unused) struct perf_sample *sample __maybe_unused)
......
...@@ -267,6 +267,22 @@ bool __map__is_bpf_prog(const struct map *map) ...@@ -267,6 +267,22 @@ bool __map__is_bpf_prog(const struct map *map)
return name && (strstr(name, "bpf_prog_") == name); return name && (strstr(name, "bpf_prog_") == name);
} }
bool __map__is_bpf_image(const struct map *map)
{
const char *name;
if (map->dso->binary_type == DSO_BINARY_TYPE__BPF_IMAGE)
return true;
/*
* If PERF_RECORD_KSYMBOL is not included, the dso will not have
* type of DSO_BINARY_TYPE__BPF_IMAGE. In such cases, we can
* guess the type based on name.
*/
name = map->dso->short_name;
return name && is_bpf_image(name);
}
bool __map__is_ool(const struct map *map) bool __map__is_ool(const struct map *map)
{ {
return map->dso && map->dso->binary_type == DSO_BINARY_TYPE__OOL; return map->dso && map->dso->binary_type == DSO_BINARY_TYPE__OOL;
......
...@@ -147,12 +147,14 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, ...@@ -147,12 +147,14 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
bool __map__is_kernel(const struct map *map); bool __map__is_kernel(const struct map *map);
bool __map__is_extra_kernel_map(const struct map *map); bool __map__is_extra_kernel_map(const struct map *map);
bool __map__is_bpf_prog(const struct map *map); bool __map__is_bpf_prog(const struct map *map);
bool __map__is_bpf_image(const struct map *map);
bool __map__is_ool(const struct map *map); bool __map__is_ool(const struct map *map);
static inline bool __map__is_kmodule(const struct map *map) static inline bool __map__is_kmodule(const struct map *map)
{ {
return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) && return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
!__map__is_bpf_prog(map) && !__map__is_ool(map); !__map__is_bpf_prog(map) && !__map__is_ool(map) &&
!__map__is_bpf_image(map);
} }
bool map__has_symbols(const struct map *map); bool map__has_symbols(const struct map *map);
...@@ -164,4 +166,9 @@ static inline bool is_entry_trampoline(const char *name) ...@@ -164,4 +166,9 @@ static inline bool is_entry_trampoline(const char *name)
return !strcmp(name, ENTRY_TRAMPOLINE_NAME); return !strcmp(name, ENTRY_TRAMPOLINE_NAME);
} }
static inline bool is_bpf_image(const char *name)
{
return strncmp(name, "bpf_trampoline_", sizeof("bpf_trampoline_") - 1) == 0 ||
strncmp(name, "bpf_dispatcher_", sizeof("bpf_dispatcher_") - 1) == 0;
}
#endif /* __PERF_MAP_H */ #endif /* __PERF_MAP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment