From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH v3 17/23] xsplice: Print dependency and payloads build_id in the keyhandler. Date: Thu, 25 Feb 2016 01:47:06 -0700 Message-ID: <56CECD9A02000078000D6084@prv-mh.provo.novell.com> References: <1455300361-13092-1-git-send-email-konrad.wilk@oracle.com> <1455300361-13092-18-git-send-email-konrad.wilk@oracle.com> <56C384A9.7040309@citrix.com> <56C4632402000078000D311E@prv-mh.provo.novell.com> <20160224215406.GA5874@char.us.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.80) (envelope-from ) id 1aYrtM-0006f3-Qv for xen-devel@lists.xenproject.org; Thu, 25 Feb 2016 09:07:24 +0000 In-Reply-To: <20160224215406.GA5874@char.us.oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Konrad Rzeszutek Wilk Cc: Keir Fraser , Ian Campbell , jinsong.liu@alibaba-inc.com, Ian Jackson , Tim Deegan , mpohlack@amazon.de, ross.lagerwall@citrix.com, Andrew Cooper , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 24.02.16 at 22:54, wrote: > On Wed, Feb 17, 2016 at 04:10:12AM -0700, Jan Beulich wrote: >> >>> On 16.02.16 at 21:20, wrote: >> > On 12/02/16 18:05, Konrad Rzeszutek Wilk wrote: >> >> +static void xsplice_print_build_id(char *id, unsigned int len) >> >> +{ >> >> + unsigned int i; >> >> + >> >> + if ( !len ) >> >> + return; >> >> + >> >> + for ( i = 0; i < len; i++ ) >> >> + { >> >> + uint8_t c = id[i]; >> >> + printk("%02x", c); >> > >> > What about the already existing %*ph custom format? If the spaces are a >> > problem we could introduce %*phN from Linux which has no spaces. >> > >> > The advantage of this is that it is a single call to printk, rather than >> > many, and avoids the ability for a different cpu to interleave in the >> > middle of a line. >> >> I don't think this ability exists anymore after we've switched to >> per-CPU there. Which isn't to say, though, that I wouldn't also >> like to see this be just a single printk(). > > Would this work for folks: Well, while it looks like it would work, it doesn't really follow Andrew's suggestion. Jan > commit e1905ecf7034635f2a82cd2bbc4f5ff03ee957b0 > Author: Konrad Rzeszutek Wilk > Date: Wed Feb 24 15:06:15 2016 -0500 > > xsplice: Print build_id in keyhandler and on bootup. > > As it should be an useful debug mechanism. > > Signed-off-by: Konrad Rzeszutek Wilk > > diff --git a/xen/common/xsplice.c b/xen/common/xsplice.c > index da26b58..b15a2de 100644 > --- a/xen/common/xsplice.c > +++ b/xen/common/xsplice.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1079,10 +1080,33 @@ static const char *state2str(uint32_t state) > return names[state]; > } > > +static void xsplice_print_build_id(const char *hdr, const char *id, > + unsigned int len) > +{ > + unsigned int i; > + > + if ( !len ) > + return; > + > + /* Each byte is two ASCII characters. */ > + if ( len*2 + 1 > sizeof(keyhandler_scratch) ) > + return; > + > + memset(keyhandler_scratch, 0, len * 2 + 1); > + for ( i = 0; i < len; i++ ) > + snprintf(&keyhandler_scratch[i * 2], 3, "%02x", (uint8_t)id[i]); > + > + printk("%s%s\n", hdr, keyhandler_scratch); > +} > + > static void xsplice_printall(unsigned char key) > { > struct payload *data; > - unsigned int i; > + char *binary_id = NULL; > + unsigned int len = 0, i; > + > + if ( !xen_build_id(&binary_id, &len) ) > + xsplice_print_build_id("build-id: ", binary_id, len); > > spin_lock_recursive(&payload_lock); > > @@ -1106,8 +1130,14 @@ static void xsplice_printall(unsigned char key) > > static int __init xsplice_init(void) > { > + char *binary_id = NULL; > + unsigned int len = 0; > BUILD_BUG_ON( sizeof(struct xsplice_patch_func) != 64 ); > > + if ( !xen_build_id(&binary_id, &len) ) > + xsplice_print_build_id("build-id: ", binary_id, len); > + > + xsplice_print_build_id("Hypervisor build-id: ", binary_id, len); > register_keyhandler('x', xsplice_printall, "print xsplicing info", 1); > return 0; > } >> >> Jan >>