From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH v2 10/13] xen_hello_world.xsplice: Test payload for patching 'xen_extra_version'. Date: Tue, 19 Jan 2016 11:14:34 +0000 Message-ID: <20160119111434.GQ1691@citrix.com> References: <1452808031-706-1-git-send-email-konrad.wilk@oracle.com> <1452808031-706-11-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLUFD-0004iI-Vk for xen-devel@lists.xenproject.org; Tue, 19 Jan 2016 11:14:40 +0000 Content-Disposition: inline In-Reply-To: <1452808031-706-11-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, mpohlack@amazon.com, ross.lagerwall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, sasha.levin@oracle.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On Thu, Jan 14, 2016 at 04:47:08PM -0500, Konrad Rzeszutek Wilk wrote: > This change demonstrates how to generate an xSplice ELF payload. > > The idea here is that we want to patch in the hypervisor > the 'xen_version_extra' function with an function that will > return 'Hello World'. The 'xl info | grep extraversion' > will reflect the new value after the patching. > > To generate this ELF payload file we need: > - C code of the new code. > - C code generating the .xsplice.func structure. > - The address of the old code (xen_extra_version). We > do it by using 'nm' but that is a bit of hack. > > The linker script file: > - Discards .debug* and .comments* sections. > - Changes the name of .data.local.xsplice_hello_world to > .xsplice.func > - Figures out the size of the new code. > > Also if you are curious on the input/output sections > magic the linker does, add these to the GCC line: > -Wl,-M -Wl,-t -Wl,-verbose > which are: print linking map, provide trace and be verbose. > > The use-case is simple: > > $xen-xsplice load /usr/lib/xen/bin/xen_hello_world.xsplice > $xen-xsplice list > ID | status > ----------------------------------------+------------ > xen_hello_world APPLIED > $xl info | grep extra > xen_extra : Hello World > $xen-xsplice revert xen_hello_world > Performing revert: completed > $xen-xsplice unload xen_hello_world > Performing unload: completed > $xl info | grep extra > xen_extra : -unstable > > Note that it does not build under a 32-bit toolstack as > there is no access to the hypervisor (xen-syms). > > We also force it to be built every time - as the hypervisor > may have been rebuilt. > > Signed-off-by: Konrad Rzeszutek Wilk > --- > docs/misc/xsplice.markdown | 50 ++++++++++++++++++++++++++++++++++++++++++++ > tools/misc/Makefile | 25 +++++++++++++++++++++- > tools/misc/xen_hello_world.c | 15 +++++++++++++ > tools/misc/xsplice.h | 12 +++++++++++ > tools/misc/xsplice.lds | 11 ++++++++++ Please put the files of this test case into a dedicated directory. Wei.