[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1525866228-30321-19-git-send-email-adrian.hunter@intel.com>
Date: Wed, 9 May 2018 14:43:47 +0300
From: Adrian Hunter <adrian.hunter@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>, Andi Kleen <ak@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>, Jiri Olsa <jolsa@...hat.com>,
linux-kernel@...r.kernel.org, x86@...nel.org
Subject: [PATCH RFC 18/19] perf buildid-cache: kcore_copy: Copy x86_64 entry trampoline sections
Identify and copy any sections for x86_64 KPTI entry trampolines.
Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
tools/perf/util/symbol-elf.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 6c6c3481477e..152e56ae9cba 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 list;
};
+struct sym_data {
+ u64 addr;
+ struct list_head list;
+};
+
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) \
@@ -1431,6 +1437,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->list, &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, list) {
+ list_del(&s->list);
+ free(s);
+ }
+}
+
static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
u64 start)
{
@@ -1461,6 +1490,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;
}
@@ -1528,6 +1560,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;
@@ -1536,6 +1569,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, list) {
+ u64 s = round_down(sdat->addr, page_size);
+
+ if (kcore_copy__map(kci, start, end, pgoff, s, s + len))
+ return -1;
+ }
+
return 0;
}
@@ -1730,6 +1770,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;
@@ -1796,6 +1837,7 @@ int kcore_copy(const char *from_dir, const char *to_dir)
kcore_copy__unlink(to_dir, "kallsyms");
kcore_copy__free_phdrs(&kci);
+ kcore_copy__free_syms(&kci);
return err;
}
--
1.9.1
Powered by blists - more mailing lists