summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol-elf.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2018-05-22 13:54:44 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-05-23 10:26:43 -0300
commita1a3a0624e6cd0e2c46a7400800a5e687521a504 (patch)
treef8b8312e9d817c1b70043ccf59d7120bf5a6a961 /tools/perf/util/symbol-elf.c
parentb4503cdb67098b2f08320c2c83df758ea72a4431 (diff)
downloadop-kernel-dev-a1a3a0624e6cd0e2c46a7400800a5e687521a504.zip
op-kernel-dev-a1a3a0624e6cd0e2c46a7400800a5e687521a504.tar.gz
perf kcore_copy: Copy x86 PTI entry trampoline sections
Identify and copy any sections for x86 PTI entry trampolines. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: x86@kernel.org Link: http://lkml.kernel.org/r/1526986485-6562-17-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol-elf.c')
-rw-r--r--tools/perf/util/symbol-elf.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 37d9324..5849669 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1392,6 +1392,11 @@ struct phdr_data {
struct list_head node;
};
+struct sym_data {
+ u64 addr;
+ struct list_head node;
+};
+
struct kcore_copy_info {
u64 stext;
u64 etext;
@@ -1401,6 +1406,7 @@ struct kcore_copy_info {
u64 last_module_symbol;
size_t phnum;
struct list_head phdrs;
+ struct list_head syms;
};
#define kcore_copy__for_each_phdr(k, p) \
@@ -1441,6 +1447,29 @@ static void kcore_copy__free_phdrs(struct kcore_copy_info *kci)
}
}
+static struct sym_data *kcore_copy__new_sym(struct kcore_copy_info *kci,
+ u64 addr)
+{
+ struct sym_data *s = zalloc(sizeof(*s));
+
+ if (s) {
+ s->addr = addr;
+ list_add_tail(&s->node, &kci->syms);
+ }
+
+ return s;
+}
+
+static void kcore_copy__free_syms(struct kcore_copy_info *kci)
+{
+ struct sym_data *s, *tmp;
+
+ list_for_each_entry_safe(s, tmp, &kci->syms, node) {
+ list_del(&s->node);
+ free(s);
+ }
+}
+
static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
u64 start)
{
@@ -1471,6 +1500,9 @@ static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
return 0;
}
+ if (is_entry_trampoline(name) && !kcore_copy__new_sym(kci, start))
+ return -1;
+
return 0;
}
@@ -1538,6 +1570,7 @@ static int kcore_copy__read_map(u64 start, u64 len, u64 pgoff, void *data)
{
struct kcore_copy_info *kci = data;
u64 end = start + len;
+ struct sym_data *sdat;
if (kcore_copy__map(kci, start, end, pgoff, kci->stext, kci->etext))
return -1;
@@ -1546,6 +1579,13 @@ static int kcore_copy__read_map(u64 start, u64 len, u64 pgoff, void *data)
kci->last_module_symbol))
return -1;
+ list_for_each_entry(sdat, &kci->syms, node) {
+ u64 s = round_down(sdat->addr, page_size);
+
+ if (kcore_copy__map(kci, start, end, pgoff, s, s + len))
+ return -1;
+ }
+
return 0;
}
@@ -1740,6 +1780,7 @@ int kcore_copy(const char *from_dir, const char *to_dir)
struct phdr_data *p;
INIT_LIST_HEAD(&kci.phdrs);
+ INIT_LIST_HEAD(&kci.syms);
if (kcore_copy__copy_file(from_dir, to_dir, "kallsyms"))
return -1;
@@ -1806,6 +1847,7 @@ out_unlink_kallsyms:
kcore_copy__unlink(to_dir, "kallsyms");
kcore_copy__free_phdrs(&kci);
+ kcore_copy__free_syms(&kci);
return err;
}
OpenPOWER on IntegriCloud