xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ross Lagerwall <ross.lagerwall@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	konrad@kernel.org, xen-devel@lists.xenproject.org,
	sasha.levin@oracle.com, andrew.cooper3@citrix.com,
	mpohlack@amazon.de
Cc: Keir Fraser <keir@xen.org>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH v9 16/27] x86, xsplice: Print payload's symbol name and payload name in backtraces
Date: Tue, 26 Apr 2016 12:06:03 +0100	[thread overview]
Message-ID: <571F4B9B.5000405@citrix.com> (raw)
In-Reply-To: <1461598514-5440-17-git-send-email-konrad.wilk@oracle.com>

On 04/25/2016 04:35 PM, Konrad Rzeszutek Wilk wrote:
snip
> +static DEFINE_RCU_READ_LOCK(rcu_applied_lock);
>   static LIST_HEAD(applied_list);
>
>   static unsigned int payload_cnt;
> @@ -56,6 +57,8 @@ struct payload {
>       unsigned int nfuncs;                 /* Nr of functions to patch. */
>       const struct xsplice_symbol *symtab; /* All symbols. */
>       const char *strtab;                  /* Pointer to .strtab. */
> +    struct virtual_region region;        /* symbol, bug.frame patching and
> +                                            exception table (x86). */
>       unsigned int nsyms;                  /* Nr of entries in .strtab and symbols. */
>       char name[XEN_XSPLICE_NAME_SIZE];    /* Name of it. */
>   };
> @@ -142,6 +145,55 @@ void *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)
> +{
> +    const struct payload *data;
> +    unsigned int i, best;
> +    const void *va = (const void *)addr;
> +    const char *n = NULL;
> +
> +    /*
> +     * Only RCU locking since this list is only ever changed during apply
> +     * or revert context. And in case it dies there we need an safe list.
> +     */
> +    rcu_read_lock(&rcu_applied_lock);
> +    list_for_each_entry_rcu ( data, &applied_list, applied_list )
> +    {
> +        if ( va < data->text_addr &&
> +             va >= (data->text_addr + data->pages * PAGE_SIZE) )

This calculation is wrong due to the use of void * and results in 
incorrect backtrace results.

You also need to have || rather than &&.

Additionally, I think it should use data->text_size rather than 
data->pages * PAGE_SIZE.

> +            continue;
> +
> +        best = UINT_MAX;
> +
> +        for ( i = 0; i < data->nsyms; i++ )
> +        {
> +            if ( data->symtab[i].value <= va &&
> +                 (best == UINT_MAX ||
> +                  data->symtab[best].value < data->symtab[i].value) )
> +                best = i;
> +        }
> +
> +        if ( best == UINT_MAX )
> +            break;
> +
> +        if ( symbolsize )
> +            *symbolsize = data->symtab[best].size;
> +        if ( offset )
> +            *offset = va - data->symtab[best].value;
> +        if ( namebuf )
> +            strlcpy(namebuf, data->name, KSYM_NAME_LEN);
> +
> +        n = data->symtab[best].name;
> +        break;
> +    }
> +    rcu_read_unlock(&rcu_applied_lock);
> +
> +    return n;
> +}
> +
>   static struct payload *find_payload(const char *name)
>   {
>       struct payload *data, *found = NULL;
> @@ -366,6 +418,7 @@ static int prepare_payload(struct payload *payload,
>       const struct xsplice_elf_sec *sec;
>       unsigned int i;
>       struct xsplice_patch_func *f;
> +    struct virtual_region *region;
>
>       sec = xsplice_elf_sec_by_name(elf, ELF_XSPLICE_FUNC);
>       ASSERT(sec);
> @@ -422,6 +475,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 = payload->text_addr;
> +    region->end = payload->text_addr + payload->text_size;

This calculation is wrong due to the use of void *.

-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-04-26 11:06 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 15:34 [PATCH 9] xSplice v1 design and implementation Konrad Rzeszutek Wilk
2016-04-25 15:34 ` [PATCH v9 01/27] Revert "libxc/libxl/python/xenstat/ocaml: Use new XEN_VERSION hypercall" Konrad Rzeszutek Wilk
2016-04-25 15:48   ` Jan Beulich
2016-04-25 15:53     ` Wei Liu
2016-04-25 15:34 ` [PATCH v9 02/27] Revert "HYPERCALL_version_op. New hypercall mirroring XENVER_ but sane." Konrad Rzeszutek Wilk
2016-04-25 15:34 ` [PATCH v9 03/27] xsplice: Design document Konrad Rzeszutek Wilk
2016-04-25 15:34 ` [PATCH v9 04/27] xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op Konrad Rzeszutek Wilk
2016-04-26  7:48   ` Ross Lagerwall
2016-04-26  7:52   ` Ross Lagerwall
2016-04-26 10:21   ` Jan Beulich
2016-04-26 17:50     ` Konrad Rzeszutek Wilk
2016-04-27  6:51       ` Jan Beulich
2016-04-27 13:47         ` Konrad Rzeszutek Wilk
2016-04-27 14:11           ` Jan Beulich
2016-04-25 15:34 ` [PATCH v9 05/27] libxc: Implementation of XEN_XSPLICE_op in libxc Konrad Rzeszutek Wilk
2016-04-26  7:51   ` Ross Lagerwall
2016-04-25 15:34 ` [PATCH v9 06/27] xen-xsplice: Tool to manipulate xsplice payloads Konrad Rzeszutek Wilk
2016-04-26  7:49   ` Ross Lagerwall
2016-04-25 15:34 ` [PATCH v9 07/27] arm/x86: Use struct virtual_region to do bug, symbol, and (x86) exception tables lookup Konrad Rzeszutek Wilk
2016-04-26 10:31   ` Jan Beulich
2016-04-25 15:34 ` [PATCH v9 08/27] arm/x86/vmap: Add v[z|m]alloc_xen and vm_init_type Konrad Rzeszutek Wilk
2016-04-26 10:47   ` Jan Beulich
2016-04-27  2:38     ` Konrad Rzeszutek Wilk
2016-04-27  7:12       ` Jan Beulich
2016-04-27 13:46         ` Konrad Rzeszutek Wilk
2016-04-27 14:15           ` Jan Beulich
2016-04-25 15:34 ` [PATCH v9 09/27] x86/mm: Introduce modify_xen_mappings() Konrad Rzeszutek Wilk
2016-04-25 15:34 ` [PATCH v9 10/27] xsplice: Add helper elf routines Konrad Rzeszutek Wilk
2016-04-26 10:05   ` Ross Lagerwall
2016-04-26 11:52     ` Jan Beulich
2016-04-26 12:37   ` Jan Beulich
2016-04-27  1:59     ` Konrad Rzeszutek Wilk
2016-04-27  7:27       ` Jan Beulich
2016-04-27 14:00         ` Konrad Rzeszutek Wilk
2016-04-27  4:06     ` Konrad Rzeszutek Wilk
2016-04-27  7:52       ` Jan Beulich
2016-04-27 18:45         ` Konrad Rzeszutek Wilk
2016-04-25 15:34 ` [PATCH v9 11/27] xsplice: Implement payload loading Konrad Rzeszutek Wilk
2016-04-26 10:48   ` Ross Lagerwall
2016-04-26 13:39   ` Jan Beulich
2016-04-27  1:47     ` Konrad Rzeszutek Wilk
2016-04-27  7:57       ` Jan Beulich
2016-04-27  3:28     ` Konrad Rzeszutek Wilk
2016-04-27  8:28       ` Jan Beulich
2016-04-27 15:48         ` Konrad Rzeszutek Wilk
2016-04-27 16:06           ` Jan Beulich
2016-04-27 16:14           ` Jan Beulich
2016-04-27 18:40             ` Konrad Rzeszutek Wilk
2016-04-25 15:34 ` [PATCH v9 12/27] xsplice: Implement support for applying/reverting/replacing patches Konrad Rzeszutek Wilk
2016-04-26 15:21   ` Jan Beulich
2016-04-27  3:39     ` Konrad Rzeszutek Wilk
2016-04-27  8:36       ` Jan Beulich
2016-05-11  9:51       ` Martin Pohlack
2016-05-11 13:56         ` Konrad Rzeszutek Wilk
2016-04-25 15:35 ` [PATCH v9 13/27] x86/xen_hello_world.xsplice: Test payload for patching 'xen_extra_version' Konrad Rzeszutek Wilk
2016-04-26 15:31   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 14/27] xsplice, symbols: Implement symbol name resolution on address Konrad Rzeszutek Wilk
2016-04-26 15:48   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 15/27] xsplice, symbols: Implement fast symbol names -> virtual addresses lookup Konrad Rzeszutek Wilk
2016-04-26 15:53   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 16/27] x86, xsplice: Print payload's symbol name and payload name in backtraces Konrad Rzeszutek Wilk
2016-04-26 11:06   ` Ross Lagerwall [this message]
2016-04-26 12:41     ` Jan Beulich
2016-04-26 12:48       ` Ross Lagerwall
2016-04-26 13:41         ` Jan Beulich
2016-04-27  3:31           ` Konrad Rzeszutek Wilk
2016-04-27  8:37             ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 17/27] xsplice: Add support for bug frames Konrad Rzeszutek Wilk
2016-04-26 11:05   ` Ross Lagerwall
2016-04-26 13:08     ` Ross Lagerwall
2016-04-26 15:58   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 18/27] xsplice: Add support for exception tables Konrad Rzeszutek Wilk
2016-04-26 16:01   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 19/27] xsplice: Add support for alternatives Konrad Rzeszutek Wilk
2016-04-27  8:58   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 20/27] build_id: Provide ld-embedded build-ids Konrad Rzeszutek Wilk
2016-04-25 15:35 ` [PATCH v9 21/27] xsplice: Print build_id in keyhandler and on bootup Konrad Rzeszutek Wilk
2016-04-25 15:35 ` [PATCH v9 22/27] XENVER_build_id/libxc: Provide ld-embedded build-id Konrad Rzeszutek Wilk
2016-04-25 15:35 ` [PATCH v9 23/27] libxl: info: Display build_id of the hypervisor Konrad Rzeszutek Wilk
2016-04-25 15:35 ` [PATCH v9 24/27] xsplice: Stacking build-id dependency checking Konrad Rzeszutek Wilk
2016-04-27  9:27   ` Jan Beulich
2016-04-27 16:36     ` Konrad Rzeszutek Wilk
2016-04-28  9:47       ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 25/27] xsplice/xen_replace_world: Test-case for XSPLICE_ACTION_REPLACE Konrad Rzeszutek Wilk
2016-04-25 15:35 ` [PATCH v9 26/27] xsplice: Prevent duplicate payloads from being loaded Konrad Rzeszutek Wilk
2016-04-27  9:31   ` Jan Beulich
2016-04-25 15:35 ` [PATCH v9 27/27] MAINTAINERS/xsplice: Add myself and Ross as the maintainers Konrad Rzeszutek Wilk
2016-04-25 15:41 ` [PATCH 9] xSplice v1 design and implementation Jan Beulich
2016-04-25 15:47   ` Konrad Rzeszutek Wilk
2016-04-25 15:54     ` Jan Beulich

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=571F4B9B.5000405@citrix.com \
    --to=ross.lagerwall@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=konrad@kernel.org \
    --cc=mpohlack@amazon.de \
    --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).