From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, konrad@kernel.org,
sasha.levin@oracle.com, andrew.cooper3@citrix.com,
ross.lagerwall@citrix.com, mpohlack@amazon.de
Cc: Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v7 13/24] x86, xsplice: Print payload's symbol name and payload name in backtraces
Date: Sun, 10 Apr 2016 17:14:45 -0400 [thread overview]
Message-ID: <1460322896-1115-14-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1460322896-1115-1-git-send-email-konrad.wilk@oracle.com>
From: Ross Lagerwall <ross.lagerwall@citrix.com>
Naturally the backtrace is presented when an instruction
hits an bug_frame or %p is used.
The payloads do not support bug_frames yet - however the functions
the payloads call could hit an BUG() or WARN().
The traps.c has logic to scan for it this - and eventually it will
find the correct bug_frame and the walk the stack using %p to print
the backtrace. For %p and symbols to print a string - the
'is_active_kernel_text' is consulted which uses an 'struct virtual_region'.
Therefore we register our start->end addresses so that
'is_active_kernel_text' will include our payload address.
We also register our symbol lookup table function so that it can
scan the list of payloads and retrieve the correct name.
Lastly we change vsprintf to take into account s and namebuf.
For core code they are the same, but for payloads they are different.
This gets us:
Xen call trace:
[<ffff82d080a00041>] revert_hook+0x31/0x35 [xen_hello_world]
[<ffff82d0801431bd>] xsplice.c#revert_payload+0x86/0xc6
[<ffff82d080143502>] check_for_xsplice_work+0x233/0x3cd
[<ffff82d08017a0b2>] domain.c#continue_idle_domain+0x9/0x1f
Which is great if payloads have similar or same symbol names.
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
v2: Add missing full stop.
v3: s/module/payload/
v4: Expand comment and include registration of 'virtual_region'
Redo the vsprintf handling of payload name.
Drop the ->skip function
v6: Add comment explaining the purpose behind the strcmp.
Redid per Jan's review.
v7: Add Andrew's Review-by
Drop the strcmp and just do pointer checks.
---
---
xen/common/vsprintf.c | 19 +++++++++++++++--
xen/common/xsplice.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c
index 18d2634..acabb3a 100644
--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -20,6 +20,7 @@
#include <xen/symbols.h>
#include <xen/lib.h>
#include <xen/sched.h>
+#include <xen/xsplice.h>
#include <asm/div64.h>
#include <asm/page.h>
@@ -331,16 +332,23 @@ static char *pointer(char *str, char *end, const char **fmt_ptr,
{
unsigned long sym_size, sym_offset;
char namebuf[KSYM_NAME_LEN+1];
+ bool_t payload = 0;
/* Advance parents fmt string, as we have consumed 's' or 'S' */
++*fmt_ptr;
s = symbols_lookup((unsigned long)arg, &sym_size, &sym_offset, namebuf);
-
- /* If the symbol is not found, fall back to printing the address */
+ /* If the symbol is not found, fall back to printing the address. */
if ( !s )
break;
+ /*
+ * namebuf contents and s for core hypervisor are same but for xSplice
+ * payloads they differ (namebuf contains the name of the payload).
+ */
+ if ( namebuf != s )
+ payload = 1;
+
/* Print symbol name */
str = string(str, end, s, -1, -1, 0);
@@ -354,6 +362,13 @@ static char *pointer(char *str, char *end, const char **fmt_ptr,
str = number(str, end, sym_size, 16, -1, -1, SPECIAL);
}
+ if ( payload )
+ {
+ str = string(str, end, " [", -1, -1, 0);
+ str = string(str, end, namebuf, -1, -1, 0);
+ str = string(str, end, "]", -1, -1, 0);
+ }
+
return str;
}
diff --git a/xen/common/xsplice.c b/xen/common/xsplice.c
index 27f4822..a92a39b 100644
--- a/xen/common/xsplice.c
+++ b/xen/common/xsplice.c
@@ -14,7 +14,9 @@
#include <xen/smp.h>
#include <xen/softirq.h>
#include <xen/spinlock.h>
+#include <xen/string.h>
#include <xen/symbols.h>
+#include <xen/virtual_region.h>
#include <xen/vmap.h>
#include <xen/wait.h>
#include <xen/xsplice_elf.h>
@@ -52,6 +54,8 @@ struct payload {
struct list_head applied_list; /* Linked to 'applied_list'. */
struct xsplice_patch_func_internal *funcs; /* The array of functions to patch. */
unsigned int nfuncs; /* Nr of functions to patch. */
+ struct virtual_region region; /* symbol, bug.frame patching and
+ exception table (x86). */
struct xsplice_symbol *symtab; /* All symbols. */
char *strtab; /* Pointer to .strtab. */
unsigned int nsyms; /* Nr of entries in .strtab and symbols. */
@@ -140,6 +144,51 @@ unsigned long xsplice_symbols_lookup_by_name(const char *symname)
return 0;
}
+static const char *xsplice_symbols_lookup(unsigned long addr,
+ unsigned long *symbolsize,
+ unsigned long *offset,
+ char *namebuf)
+{
+ struct payload *data;
+ unsigned int i;
+ int best;
+
+ /*
+ * No locking since this list is only ever changed during apply or revert
+ * context.
+ */
+ list_for_each_entry ( data, &applied_list, applied_list )
+ {
+ if ( (void *)addr < data->text_addr &&
+ (void *)addr >= (data->text_addr + data->pages * PAGE_SIZE) )
+ continue;
+
+ best = -1;
+
+ for ( i = 0; i < data->nsyms; i++ )
+ {
+ if ( data->symtab[i].value <= addr &&
+ (best == -1 ||
+ data->symtab[best].value < data->symtab[i].value) )
+ best = i;
+ }
+
+ if ( best == -1 )
+ return NULL;
+
+ if ( symbolsize )
+ *symbolsize = data->symtab[best].size;
+ if ( offset )
+ *offset = addr - data->symtab[best].value;
+ if ( namebuf )
+ strlcpy(namebuf, data->name, KSYM_NAME_LEN);
+
+ return data->symtab[best].name;
+ }
+
+ return NULL;
+}
+
static struct payload *find_payload(const char *name)
{
struct payload *data, *found = NULL;
@@ -361,6 +410,7 @@ static int prepare_payload(struct payload *payload,
const struct xsplice_elf_sec *sec;
unsigned int i;
struct xsplice_patch_func_internal *f;
+ struct virtual_region *region;
sec = xsplice_elf_sec_by_name(elf, ".xsplice.funcs");
ASSERT(sec);
@@ -422,6 +472,13 @@ static int prepare_payload(struct payload *payload,
}
}
+ /* Setup the virtual region with proper data. */
+ region = &payload->region;
+
+ region->symbols_lookup = xsplice_symbols_lookup;
+ region->start = (unsigned long)payload->text_addr;
+ region->end = (unsigned long)(payload->text_addr + payload->text_size);
+
return 0;
}
@@ -766,6 +823,7 @@ static int apply_payload(struct payload *data)
arch_xsplice_patching_leave();
list_add_tail(&data->applied_list, &applied_list);
+ register_virtual_region(&data->region);
return 0;
}
@@ -784,6 +842,7 @@ static int revert_payload(struct payload *data)
arch_xsplice_patching_leave();
list_del_init(&data->applied_list);
+ unregister_virtual_region(&data->region);
return 0;
}
--
2.5.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-04-10 21:15 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-10 21:14 [PATCH v7] xSplice v1 design and implementation Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 01/24] xsplice: Design document Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 02/24] xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 03/24] libxc: Implementation of XEN_XSPLICE_op in libxc Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 04/24] xen-xsplice: Tool to manipulate xsplice payloads Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 05/24] arm/x86: Use struct virtual_region to do bug, symbol, and (x86) exception tables lookup Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 06/24] arm/x86/vmap: Add vmalloc_xen, vfree_xen and vm_init_type Konrad Rzeszutek Wilk
2016-04-11 9:39 ` Andrew Cooper
2016-04-11 13:29 ` Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 07/24] x86/mm: Introduce modify_xen_mappings() Konrad Rzeszutek Wilk
2016-04-11 12:51 ` George Dunlap
2016-04-11 13:00 ` Andrew Cooper
2016-04-11 14:04 ` [PATCH v7.1 " Andrew Cooper
2016-04-11 15:21 ` George Dunlap
2016-04-11 17:18 ` Jan Beulich
2016-04-11 17:33 ` Andrew Cooper
2016-04-11 17:46 ` [PATCH v7.2 " Andrew Cooper
2016-04-11 17:54 ` Jan Beulich
2016-04-12 9:08 ` Andrew Cooper
2016-04-10 21:14 ` [PATCH v7 08/24] xsplice: Add helper elf routines Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 09/24] xsplice: Implement payload loading Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 10/24] xsplice: Implement support for applying/reverting/replacing patches Konrad Rzeszutek Wilk
2016-04-11 10:14 ` Andrew Cooper
2016-04-11 13:29 ` Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 11/24] x86/xen_hello_world.xsplice: Test payload for patching 'xen_extra_version' Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 12/24] xsplice, symbols: Implement symbol name resolution on address Konrad Rzeszutek Wilk
2016-04-10 21:14 ` Konrad Rzeszutek Wilk [this message]
2016-04-10 21:14 ` [PATCH v7 14/24] xsplice: Add support for bug frames Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 15/24] xsplice: Add support for exception tables Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 16/24] xsplice: Add support for alternatives Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 17/24] build_id: Provide ld-embedded build-ids Konrad Rzeszutek Wilk
2016-04-11 12:17 ` Andrew Cooper
2016-04-11 13:31 ` Konrad Rzeszutek Wilk
2016-04-11 13:35 ` Andrew Cooper
2016-04-10 21:14 ` [PATCH v7 18/24] HYPERCALL_version_op: Add VERSION_build_id to retrieve build-id Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 19/24] libxl: info: Display build_id of the hypervisor using XEN_VERSION_build_id Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 20/24] xsplice: Print build_id in keyhandler and on bootup Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 21/24] xsplice: Stacking build-id dependency checking Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 22/24] xsplice/xen_replace_world: Test-case for XSPLICE_ACTION_REPLACE Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 23/24] xsplice: Prevent duplicate payloads from being loaded Konrad Rzeszutek Wilk
2016-04-10 21:14 ` [PATCH v7 24/24] MAINTAINERS/xsplice: Add myself and Ross as the maintainers Konrad Rzeszutek Wilk
2016-04-11 14:32 ` [PATCH v7] xSplice v1 design and implementation Konrad Rzeszutek Wilk
2016-04-11 15:43 ` Konrad Rzeszutek Wilk
2016-04-12 8:10 ` Ross Lagerwall
2016-04-12 20:59 ` Konrad Rzeszutek Wilk
2016-04-12 20:59 ` [PATCH v7 25/24] symbols/xsplice: Implement fast symbol names -> virtual addresses lookup Konrad Rzeszutek Wilk
2016-04-13 2:03 ` Konrad Rzeszutek Wilk
2016-04-13 2:17 ` Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460322896-1115-14-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=konrad@kernel.org \
--cc=mpohlack@amazon.de \
--cc=ross.lagerwall@citrix.com \
--cc=sasha.levin@oracle.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).