From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbbIQNL6 (ORCPT ); Thu, 17 Sep 2015 09:11:58 -0400 Received: from smtprelay0196.hostedemail.com ([216.40.44.196]:50735 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751500AbbIQNL5 (ORCPT ); Thu, 17 Sep 2015 09:11:57 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:6120:6261:7514:7875:7901:8603:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12296:12517:12519:12555:12740:13019:13138:13231:13255:14096:14097:21080:21088,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: pain66_4b0c976a36621 X-Filterd-Recvd-Size: 3600 Date: Thu, 17 Sep 2015 09:11:54 -0400 From: Steven Rostedt To: Kapileshwar Singh Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Namhyung Kim , Javi Merino , David Ahern , Jiri Olsa Subject: Re: [PATCH] tools lib traceevent: Mask higher bits of str addresses for 32-bit traces Message-ID: <20150917091154.575d031f@gandalf.local.home> In-Reply-To: <1442488476-15366-1-git-send-email-kapileshwar.singh@arm.com> References: <1442488476-15366-1-git-send-email-kapileshwar.singh@arm.com> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 17 Sep 2015 12:14:36 +0100 Kapileshwar Singh wrote: > When a trace recorded on a 32-bit device is processed with a 64-bit > binary, the higher 32-bits of the address need to be masked. > > The lack of this results in the output of the 64-bit pointer > value to the trace as the 32-bit address lookup fails in find_printk. > > Before: > burn-1778 [003] 548.600305: bputs: 0xc0046db2s: 2cec5c058d98c > > After: > burn-1778 [003] 548.600305: bputs: 0xc0046db2s: RT throttling activated > > The problem occurs in PRINT_FEILD when the field is recognized as a pointer > to a string (of the type const char *) Actually, there's two bugs here. You only fixed one of them. > > Cc: Steven Rostedt > Cc: Arnaldo Carvalho de Melo > Cc: Namhyung Kim > Cc: Javi Merino > Cc: David Ahern > Cc: Jiri Olsa > Reported-by: Juri-Lelli > Signed-off-by: Kapileshwar Singh > --- > tools/lib/traceevent/event-parse.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c > index 4d885934b919..39163ea4a048 100644 > --- a/tools/lib/traceevent/event-parse.c > +++ b/tools/lib/traceevent/event-parse.c > @@ -3829,6 +3829,17 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, > if (!(field->flags & FIELD_IS_ARRAY) && > field->size == pevent->long_size) { > addr = *(unsigned long *)(data + field->offset); addr is of type unsigned long. That means if we read a 64 bit record on a 32 bit machine (which is supported), this will be truncated. Perhaps we need to make addr into a unsigned long long, and then add: addr = (pevent->long_size == 8) ? *(unsigned long long *)(data + field->offset) : (unsigned long long )*(unsigned int *)(data + field->offset); -- Steve > + > + /* In case the long_size is 4. The higher 32bits > + * need to be masked for a successful lookup in > + * in the printk table. As the pointers are 32-bit > + * long. This could happen if a trace recorded on > + * 32-bit platform is processed using a 64-bit > + * binary > + */ > + if (pevent->long_size == 4) > + addr = addr & 0xffffffff; > + > /* Check if it matches a print format */ > printk = find_printk(pevent, addr); > if (printk)