All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount
@ 2021-02-22 13:58 Chen Jun
  2021-02-22 15:50 ` 答复: " chenjun (AM)
  0 siblings, 1 reply; 4+ messages in thread
From: Chen Jun @ 2021-02-22 13:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregory.herrero, catalin.marinas, rostedt, rui.xiang

On little endian system, Use aarch64_be(gcc v7.3) downloaded from
linaro.org to build image with CONFIG_CPU_BIG_ENDIAN = y,
CONFIG_FTRACE = y, CONFIG_DYNAMIC_FTRACE = y.

gcc will create symbols of _mcount but recordmcount can not create
mcount_loc for *.o.
aarch64_be-linux-gnu-objdump -r fs/namei.o | grep mcount
00000000000000d0 R_AARCH64_CALL26  _mcount
...
0000000000007190 R_AARCH64_CALL26  _mcount

The reason is than funciton arm64_is_fake_mcount can not work correctly.
A symbol of _mcount in *.o compiled with big endian compiler likes:
00 00 00 2d 00 00 01 1b
w(rp->r_info) will return 0x2d instead of 0x011b. Because w() takes
uint32_t as parameter, which truncates rp->r_info.

Use w8() instead w() to read relp->r_info

Fixes: ea0eada45632 ("recordmcount: only record relocation of type R_AARCH64_CALL26 on arm64.")
Signed-off-by: Chen Jun <chenjun102@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;
 }
 
 /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* 答复: [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount
  2021-02-22 13:58 [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount Chen Jun
@ 2021-02-22 15:50 ` chenjun (AM)
  2021-02-23 22:26   ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: chenjun (AM) @ 2021-02-22 15:50 UTC (permalink / raw)
  To: chenjun (AM), linux-kernel
  Cc: gregory.herrero, catalin.marinas, rostedt, Xiangrui (Euler)

Hi

There is no problem when I use aarch64_be(gcc v10.2). Because gcc v10.2 use __patchable_function_entries
instead of __mcount. I am not sure when the change happened.

Regards,
Chen Jun

-----邮件原件-----
发件人: Chen Jun [mailto:chenjun102@huawei.com] 
发送时间: 2021年2月22日 21:59
收件人: linux-kernel@vger.kernel.org
抄送: gregory.herrero@oracle.com; catalin.marinas@arm.com; rostedt@goodmis.org; Xiangrui (Euler) <rui.xiang@huawei.com>
主题: [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount

On little endian system, Use aarch64_be(gcc v7.3) downloaded from linaro.org to build image with CONFIG_CPU_BIG_ENDIAN = y, CONFIG_FTRACE = y, CONFIG_DYNAMIC_FTRACE = y.

gcc will create symbols of _mcount but recordmcount can not create mcount_loc for *.o.
aarch64_be-linux-gnu-objdump -r fs/namei.o | grep mcount
00000000000000d0 R_AARCH64_CALL26  _mcount ...
0000000000007190 R_AARCH64_CALL26  _mcount

The reason is than funciton arm64_is_fake_mcount can not work correctly.
A symbol of _mcount in *.o compiled with big endian compiler likes:
00 00 00 2d 00 00 01 1b
w(rp->r_info) will return 0x2d instead of 0x011b. Because w() takes uint32_t as parameter, which truncates rp->r_info.

Use w8() instead w() to read relp->r_info

Fixes: ea0eada45632 ("recordmcount: only record relocation of type R_AARCH64_CALL26 on arm64.")
Signed-off-by: Chen Jun <chenjun102@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;
 }
 
 /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
--
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount
  2021-02-22 15:50 ` 答复: " chenjun (AM)
@ 2021-02-23 22:26   ` Steven Rostedt
  2021-02-24  3:12     ` chenjun (AM)
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2021-02-23 22:26 UTC (permalink / raw)
  To: chenjun (AM)
  Cc: linux-kernel, gregory.herrero, catalin.marinas, Xiangrui (Euler)

On Mon, 22 Feb 2021 15:50:19 +0000
"chenjun (AM)" <chenjun102@huawei.com> wrote:

> Hi
> 
> There is no problem when I use aarch64_be(gcc v10.2). Because gcc v10.2 use __patchable_function_entries
> instead of __mcount. I am not sure when the change happened.

But you are still saying that this patch needs to be applied, right?

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount
  2021-02-23 22:26   ` Steven Rostedt
@ 2021-02-24  3:12     ` chenjun (AM)
  0 siblings, 0 replies; 4+ messages in thread
From: chenjun (AM) @ 2021-02-24  3:12 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, gregory.herrero, catalin.marinas, Xiangrui (Euler)

在 2021/2/24 6:26, Steven Rostedt 写道:
> On Mon, 22 Feb 2021 15:50:19 +0000
> "chenjun (AM)" <chenjun102@huawei.com> wrote:
> 
>> Hi
>>
>> There is no problem when I use aarch64_be(gcc v10.2). Because gcc v10.2 use __patchable_function_entries
>> instead of __mcount. I am not sure when the change happened.
> 
> But you are still saying that this patch needs to be applied, right?
> 
> -- Steve
> .
> 

Yes,this patch needs to be applied.

-- 
Regards
Chen Jun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-24  3:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 13:58 [PATCH] recordmcount: use w8 to read relp->r_info in arm64_is_fake_mcount Chen Jun
2021-02-22 15:50 ` 答复: " chenjun (AM)
2021-02-23 22:26   ` Steven Rostedt
2021-02-24  3:12     ` chenjun (AM)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.