xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ross Lagerwall <ross.lagerwall@citrix.com>
To: Martin Pohlack <mpohlack@amazon.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	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, boris.ostrovsky@oracle.com,
	daniel.kiper@oracle.com, elena.ufimtseva@oracle.com,
	bob.liu@oracle.com, lars.kurth@citrix.com, hanweidong@huawei.com,
	peter.huangpeng@huawei.com, fanhenglong@huawei.com,
	liuyingdong@huawei.com, john.liuqiming@huawei.com,
	jbeulich@suse.com, andrew.cooper3@citrix.com,
	ian.campbell@citrix.com
Subject: Re: [PATCH v1 1/5] xsplice: Design document.
Date: Tue, 27 Oct 2015 08:45:37 +0000	[thread overview]
Message-ID: <562F39B1.3050205@citrix.com> (raw)
In-Reply-To: <562F3102.8030701@amazon.com>

On 10/27/2015 08:08 AM, Martin Pohlack wrote:
> On 06.10.2015 14:57, Ross Lagerwall wrote:
>> On 09/16/2015 10:01 PM, Konrad Rzeszutek Wilk wrote:
>>> +### xSplice interdependencies
>>> +
>>> +xSplice patches interdependencies are tricky.
>>> +
>>> +There are the ways this can be addressed:
>>> + * A single large patch that subsumes and replaces all previous ones.
>>> +   Over the life-time of patching the hypervisor this large patch
>>> +   grows to accumulate all the code changes.
>>> + * Hotpatch stack - where an mechanism exists that loads the hotpatches
>>> +   in the same order they were built in. We would need an build-id
>>> +   of the hypevisor to make sure the hot-patches are build against the
>>> +   correct build.
>>> + * Payload containing the old code to check against that. That allows
>>> +   the hotpatches to be loaded indepedently (if they don't overlap) - or
>>> +   if the old code also containst previously patched code - even if they
>>> +   overlap.
>>> +
>>> +The disadvantage of the first large patch is that it can grow over
>>> +time and not provide an bisection mechanism to identify faulty patches.
>>> +
>>> +The hot-patch stack puts stricts requirements on the order of the patches
>>> +being loaded and requires an hypervisor build-id to match against.
>>> +
>>> +The old code allows much more flexibility and an additional guard,
>>> +but is more complex to implement.
>>> +
>>
>> If the single large patch mechanism is used, a new REPLACE action is
>> needed to atomically replace one patch with another to prevent a window
>> where the hypervisor is unpatched. kpatch has a "replace" command for
>> this purpose. This may be useful even for the other mechanisms listed above.
>>
>>   From what I can tell:
>> * kSplice uses old code checking (method [3] above), although in
>> practice the userspace tools implement dependency logic to enforce a
>> linear stack of patches.
>> * kPatch and kGraft recommend using the single large patch mechanism
>> although there's nothing preventing two independent patches from being
>> loaded.
>
> To make sure this argument is not lost: I wrote in an earlier email
>
>> * There is a general (and mostly obscure) limitation on unloading
>>    hotpatches:
>>
>>    In contrast to normal kernel modules where the module code adheres
>>    to specific conventions around resource allocation and locking,
>>    hotpatches typically contain code from any context.  That code is
>>    usually not aware that it can be unloaded.
>>
>>    That code could leave behind in Xen references to itself, e.g., by
>>    installing a function pointer in a global data structure, without
>>    incrementing something like a usage count.  While most hotpatch code
>>    will probably be very simple and small, a similar effect could even
>>    be achieved by code called from the hotpatch in Xen, e.g., some code
>>    patch could dynamically generate a backtrace and later decide to
>>    inspect individual elements from the collected trace, later being a
>>    time, where the hotpatch has been unloaded again.
>>
>>    One could approach that proplem from multiple angles: code
>>    inspection of generated hotpatches, testing, and by making unloading
>>    a very special and exceptional operation.
>
> If we follow that argument, we should consider patch unloading to be a
> potentially unsafe operation which should not be part of standard
> workflows.  Consequently, a similar argument holds for REPLACE, because
> removing / unloading older code is part of replacement.
>
> One could now either aim to have special inspection and testing
> regarding unloading to lower the risk there, or:
>
> Structure hotpatches as an ever-increasing stack of modules that are
> loaded on top of each other.  This approach works around the unloading
> problems as well as the temporary-unsafe problem outlined above.  Memory
> usage would be similar to an ever-increasing monolithic hotpatch (+ some
> fragmentation, - the temporary additional memory requirement for
> replacing the monolithic hotpatch).
>

I agree that this could be an issue with the replace operation; in 
practice I don't believe it would be an issue (and it is the choice that 
both kGraft and kpatch use). Since it is trivial to implement the 
replace operation (it's already done in my branch), I think we should 
have both and let vendors choose.

I think we should also aim for a slightly more general concept than a 
stack, and let vendors implement the stack approach if they want. Here 
is what I wrote in an earlier mail:
* Each hypervisor has an embedded build id.
* Each binary patch has an embedded build id.
* The hypervisor should expose its build id and the build id of every 
loaded binary patch.
* Each binary patch specifies one or more build ids on which it depends. 
These build ids can be either a hypervisor build id or another patch 
build id. The dependencies could either identified automatically or by a 
developer.
* The userspace tool enforces dependency management (user can optionally 
force patch apply). I don't see any reason to involve the
hypervisor for dependency management.

The vendor could very easily implement a stack of patches with this 
approach (afaik this is sort of what ksplice does).

The one caveat with having multiple patches is that the patches need to 
be dynamically linked (e.g. consider a patch on top of a patch which 
introduces a new function). I've got a basically working version of 
dynamic linking of modules, but it is certainly more complex than static 
linking and we probably shouldn't aim for it in V1.

-- 
Ross Lagerwall

  reply	other threads:[~2015-10-27  8:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 21:01 [PATCH v1] xSplice initial foundation patches Konrad Rzeszutek Wilk
2015-09-16 21:01 ` [PATCH v1 1/5] xsplice: Design document Konrad Rzeszutek Wilk
2015-10-05 10:02   ` Jan Beulich
2015-10-05 10:28   ` Ross Lagerwall
2015-10-12 11:44     ` xsplice-build prototype (was [PATCH v1 1/5] xsplice: Design document.) Ross Lagerwall
2015-10-12 13:06       ` Konrad Rzeszutek Wilk
2015-10-12 14:20       ` Konrad Rzeszutek Wilk
2015-10-06 12:57   ` [PATCH v1 1/5] xsplice: Design document Ross Lagerwall
2015-10-27  8:08     ` Martin Pohlack
2015-10-27  8:45       ` Ross Lagerwall [this message]
2015-10-06 15:26   ` Jan Beulich
2015-10-26 12:01   ` Martin Pohlack
2015-10-26 12:10     ` Jan Beulich
2015-10-26 13:21     ` Ross Lagerwall
2015-10-26 13:55       ` Konrad Rzeszutek Wilk
2015-09-16 21:01 ` [PATCH v1 2/5] xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op Konrad Rzeszutek Wilk
2015-10-02 15:06   ` Jan Beulich
2015-09-16 21:01 ` [PATCH v1 3/5] libxc: Implementation of XEN_XSPLICE_op in libxc Konrad Rzeszutek Wilk
2015-09-16 21:01 ` [PATCH v1 4/5] xen-xsplice: Tool to manipulate xsplice payloads Konrad Rzeszutek Wilk
2015-09-16 21:01 ` [PATCH v1 5/5] xsplice: Use ld-embedded build-ids Konrad Rzeszutek Wilk
2015-09-16 21:41   ` Andrew Cooper
2015-09-16 21:59     ` Konrad Rzeszutek Wilk
2015-09-16 22:31       ` Andrew Cooper
2015-09-17  6:41         ` Martin Pohlack
2015-09-17  9:35           ` Andrew Cooper
2015-09-17 18:45             ` Is: Make XENVER_* use XSM, seperate the different ops in smaller security domains. Was:Re: " Konrad Rzeszutek Wilk
2015-09-18 11:40               ` Andrew Cooper
2015-09-22 13:22                 ` Konrad Rzeszutek Wilk
2015-09-22 13:33                   ` Andrew Cooper
2015-09-22 13:45                     ` Konrad Rzeszutek Wilk
2015-09-22 16:28                       ` Daniel De Graaf
2015-09-22 16:28               ` Daniel De Graaf
2015-09-25 20:18                 ` Konrad Rzeszutek Wilk
2015-10-02 15:13   ` Jan Beulich
2015-10-02 14:48 ` [PATCH v1] xSplice initial foundation patches Konrad Rzeszutek Wilk
2015-10-09 12:46   ` Konrad Rzeszutek Wilk
     [not found] <560E66D902000078000DA088@prv-mh.provo.novell.com>
2015-10-02 13:36 ` [PATCH v1 1/5] xsplice: Design document 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=562F39B1.3050205@citrix.com \
    --to=ross.lagerwall@citrix.com \
    --cc=aliguori@amazon.com \
    --cc=amesserl@rackspace.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bob.liu@oracle.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=daniel.kiper@oracle.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=fanhenglong@huawei.com \
    --cc=hanweidong@huawei.com \
    --cc=ian.campbell@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jinsong.liu@alibaba-inc.com \
    --cc=john.liuqiming@huawei.com \
    --cc=josh.kearney@rackspace.com \
    --cc=konrad.wilk@oracle.com \
    --cc=lars.kurth@citrix.com \
    --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).