xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Martin Pohlack <mpohlack@amazon.com>,
	Konrad Rzeszutek Wilk <konrad@kernel.org>,
	xen-devel@lists.xenproject.org, msw@amazon.com,
	aliguori@amazon.com, amesserl@rackspace.com,
	rick.harris@rackspace.com, paul.voccio@rackspace.com,
	steven.wilson@rackspace.com, major.hayden@rackspace.com,
	josh.kearney@rackspace.com, jinsong.liu@alibaba-inc.com,
	xiantao.zxt@alibaba-inc.com, daniel.kiper@oracle.com,
	elena.ufimtseva@oracle.com, bob.liu@oracle.com,
	hanweidong@huawei.com, peter.huangpeng@huawei.com,
	fanhenglong@huawei.com, liuyingdong@huawei.com,
	john.liuqiming@huawei.com, jbeulich@suse.com, jeremy@goop.org,
	dslutz@verizon.com, "Doebel, Bjoern" <doebel@amazon.de>
Subject: Re: Hotpatch construction and __LINE__
Date: Wed, 5 Aug 2015 14:25:23 +0100	[thread overview]
Message-ID: <55C20EC3.9080102@citrix.com> (raw)
In-Reply-To: <55C1CF8E.5090907@amazon.com>

On 05/08/15 09:55, Martin Pohlack wrote:
> Hi,
>
> Another high-level point to think about is how we want to handle inlined
> __LINE__ references.  This problem is related to hotpatch construction
> and potentially has influence on the design of the hotpatching
> infrastructure in Xen.
>
> Let me try to explain the problem:
>
> We have file1.c with functions f1 and f2 (in that order).  f2 contains a
> BUG() (or WARN()) macro and at that point embeds the source line number
> into the generated code for f2.
>
> Now we want to hotpatch f1 and the hotpatch source-code patch adds 2
> lines to f1 and as a consequence shifts out f2 by two lines.  The newly
> constructed file1.o will now contain differences in both binary
> functions f1 (because we actually changed it with the applied patch) and
> f2 (because the contained BUG macro embeds the new line number).
>
> Without additional information, an algorithm comparing file1.o before
> and after hotpatch application will determine both functions to be
> changed and will have to include both into the binary hotpatch.
>
> Options:
>
> 1. Transform source code patches for hotpatches to be line-neutral for
>    each chunk.  This can be done in almost all cases with either
>    reformatting of the source code or by introducing artificial
>    preprocessor "#line n" directives to adjust for the introduced
>    differences.
>
>    This approach is low-tech and simple.  Potentially generated
>    backtraces and existing debug information refers to the original
>    build and does not reflect hotpatching state except for actually
>    hotpatched functions but should be mostly correct.
>
> 2. Ignoring the problem and living with artificially large hotpatches
>    that unnecessarily patch many functions.
>
>    This approach might lead to some very large hotpatches depending on
>    content of specific source file.  It may also trigger pulling in
>    functions into the hotpatch that cannot reasonable be hotpatched due
>    to limitations of a hotpatching framework (init-sections, parts of
>    the hotpatching framework itself, ...) and may thereby prevent us
>    from patching a specific problem.
>
>    The decision between 1. and 2. can be made on a patch--by-patch
>    basis.
>
> 3. Introducing an indirection table for storing line numbers and
>    treating that specially for binary diffing.  I believe Linux follows
>    this approach, but the details escape me ATM.
>
>    We might either use this indirection table for runtime use and patch
>    that with each hotpatch (similarly to exception tables) or we might
>    purely use it when building hotpatches to ignore functions that only
>    differ at exactly the location where a line-number is embedded.
>
> Similar considerations are true to a lesser extent for __FILE__, but I
> would argue that file renaming should be done outside of hotpatches.

Looking at `strings xen-syms`, we have very few embedded
__FILE__/__LINE__'s in other strings, meaning that most come from %s/%d
formatting.

bug/warn/assert frames have their references in the exception table, so
should be reasonably self contained to fix up.

Regular printk()s are definitely more problematic however.  Their
references will typically be in %rsi/%rdx and shifting any #line
reference across the 256 boundary will change the encoding size of
setting the print up.

Jan had a plan to make Xen read its own DWARF symbol table rather than
using the current cludge we have where we partially link Xen, extract
the public symbol table, rewrite symbol-offsets.c and relink it onto the
end.

Perhaps there is an opportunity to piggy-back onto that and have all
file/line references coming from the DWARF information.  I suspect this
will be similar to what Linux does, as it already has support for using
its own DWARF/STABS information.

Personally, I think #2 should be avoided wherever possible.  The bigger
the hotpatch, the greater the opportunity for something to go wrong.

Any panic/stack trace should be able to identify exactly which Xen is
running, including some hotpatch status.  Hopatches will be[1] small
targeted fixes, so I don't think it is unreasonable to expect someone
interpreting a stack trace to need to adjust file/line references by the
hotpatch delta.

~Andrew

[1] woe betide anyone attempting to use hotpatches for general software
updates.

  reply	other threads:[~2015-08-05 13:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 19:20 [RFC PATCH v3.1] xSplice design Konrad Rzeszutek Wilk
2015-07-27 19:20 ` [RFC PATCH v3.1 1/2] xsplice: rfc.v3.1 Konrad Rzeszutek Wilk
2015-07-30 16:47   ` Johannes Erdfelt
2015-07-31 15:46     ` Konrad Rzeszutek Wilk
2015-08-11 14:17       ` Jan Beulich
2015-07-27 19:20 ` [RFC PATCH v3.1 2/2] xsplice: Add hook for build_id Konrad Rzeszutek Wilk
2015-07-28 15:51   ` Andrew Cooper
2015-07-28 16:35     ` Konrad Rzeszutek Wilk
2015-08-05  8:50   ` Martin Pohlack
2015-08-05  8:58     ` Andrew Cooper
2015-08-05 13:27       ` Martin Pohlack
2015-08-05 14:06         ` (no subject) Martin Pohlack
2015-08-05 14:09         ` [PATCH] xsplice: Use ld-embedded build-ids Martin Pohlack
2015-08-11 14:12           ` Jan Beulich
2015-08-14 12:59             ` Martin Pohlack
2015-08-14 13:54               ` Jan Beulich
2015-08-14 13:57                 ` Martin Pohlack
2015-09-15 18:38                   ` Konrad Rzeszutek Wilk
2015-08-11 14:02   ` [RFC PATCH v3.1 2/2] xsplice: Add hook for build_id Jan Beulich
2015-08-05  8:55 ` Hotpatch construction and __LINE__ (was: [RFC PATCH v3.1] xSplice design.) Martin Pohlack
2015-08-05 13:25   ` Andrew Cooper [this message]
2015-08-12  8:09     ` Hotpatch construction and __LINE__ Jan Beulich
2015-08-12  9:55       ` Andrew Cooper
2015-11-03 18:21   ` Ross Lagerwall

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=55C20EC3.9080102@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=aliguori@amazon.com \
    --cc=amesserl@rackspace.com \
    --cc=bob.liu@oracle.com \
    --cc=daniel.kiper@oracle.com \
    --cc=doebel@amazon.de \
    --cc=dslutz@verizon.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=fanhenglong@huawei.com \
    --cc=hanweidong@huawei.com \
    --cc=jbeulich@suse.com \
    --cc=jeremy@goop.org \
    --cc=jinsong.liu@alibaba-inc.com \
    --cc=john.liuqiming@huawei.com \
    --cc=josh.kearney@rackspace.com \
    --cc=konrad@kernel.org \
    --cc=liuyingdong@huawei.com \
    --cc=major.hayden@rackspace.com \
    --cc=mpohlack@amazon.com \
    --cc=msw@amazon.com \
    --cc=paul.voccio@rackspace.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=rick.harris@rackspace.com \
    --cc=steven.wilson@rackspace.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xiantao.zxt@alibaba-inc.com \
    /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).