public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: catalin.marinas@arm.com, linux-kernel@vger.kernel.org,
	christophe.leroy@csgroup.eu, zhangjinhao2@huawei.com,
	yangjihong1@huawei.com, Li Huafei <lihuafei1@huawei.com>,
	gregory.herrero@oracle.com, xukuohai@huawei.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] recordmcount: Fix the wrong use of w* in arm64_is_fake_mcount()
Date: Thu, 25 Feb 2021 16:01:17 +0000	[thread overview]
Message-ID: <20210225160116.GA13604@willie-the-truck> (raw)
In-Reply-To: <20210225094426.7729b9cc@gandalf.local.home>

On Thu, Feb 25, 2021 at 09:44:26AM -0500, Steven Rostedt wrote:
> This requires an acked-by from one of the ARM64 maintainers.
> 
> -- Steve
> 
> 
> On Thu, 25 Feb 2021 22:07:47 +0800
> Li Huafei <lihuafei1@huawei.com> wrote:
> 
> > When cross-compiling the kernel, the endian of the target machine and
> > the local machine may not match, at this time the recordmcount tool
> > needs byte reversal when processing elf's variables to get the correct
> > value. w* callback function is used to solve this problem, w is used for
> > 4-byte variable processing, while w8 is used for 8-byte.
> > 
> > arm64_is_fake_mcount() is used to filter '_mcount' relocations that are
> > not used by ftrace. In arm64_is_fake_mcount(), rp->info is 8 bytes in
> > size, but w is used. This causes arm64_is_fake_mcount() to get the wrong
> > type of relocation when we cross-compile the arm64_be kernel image on an
> > x86_le machine, and all valid '_mcount' is filtered out. The
> > recordmcount tool does not collect any mcount function call locations.
> > At kernel startup, the following ftrace log is seen:
> > 
> > 	ftrace: No functions to be traced?
> > 
> > and thus ftrace cannot be used.
> > 
> > Using w8 to get the value of rp->r_info will fix the problem.
> > 
> > Fixes: ea0eada45632 ("recordmcount: only record relocation of type
> > R_AARCH64_CALL26 on arm64")
> > Signed-off-by: Li Huafei <lihuafei1@huawei.com>
> > ---
> >  scripts/recordmcount.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
> > index b9c2ee7ab43f..cce12e1971d8 100644
> > --- a/scripts/recordmcount.c
> > +++ b/scripts/recordmcount.c
> > @@ -438,7 +438,7 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp)
> >  
> >  static int arm64_is_fake_mcount(Elf64_Rel const *rp)
> >  {
> > -	return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26;
> > +	return ELF64_R_TYPE(w8(rp->r_info)) != R_AARCH64_CALL26;

Acked-by: Will Deacon <will@kernel.org>

But you know you could avoid these sorts of problems by moving to little
endian along with everybody else? ;)

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-02-25 16:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210225140747.10818-1-lihuafei1@huawei.com>
2021-02-25 14:44 ` [PATCH] recordmcount: Fix the wrong use of w* in arm64_is_fake_mcount() Steven Rostedt
2021-02-25 16:01   ` Will Deacon [this message]
2021-02-25 16:08     ` Steven Rostedt
2021-03-02 22:30     ` Steven Rostedt
2021-03-02 22:33       ` Steven Rostedt
2021-03-03 13:12         ` Will Deacon
2021-03-03  1:25       ` Li Huafei

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=20210225160116.GA13604@willie-the-truck \
    --to=will@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=gregory.herrero@oracle.com \
    --cc=lihuafei1@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=xukuohai@huawei.com \
    --cc=yangjihong1@huawei.com \
    --cc=zhangjinhao2@huawei.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