From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH v3 17/23] xsplice: Print dependency and payloads build_id in the keyhandler. Date: Wed, 24 Feb 2016 16:54:06 -0500 Message-ID: <20160224215406.GA5874@char.us.oracle.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> 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 1aYhO3-0001st-Uv for xen-devel@lists.xenproject.org; Wed, 24 Feb 2016 21:54:24 +0000 Content-Disposition: inline In-Reply-To: <56C4632402000078000D311E@prv-mh.provo.novell.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: Jan Beulich Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Ian Jackson , Tim Deegan , mpohlack@amazon.de, ross.lagerwall@citrix.com, jinsong.liu@alibaba-inc.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org 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: 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 >