From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
Naveen N Rao <naveen@kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] powerpc/ftrace: Ignore ftrace locations in exit text sections
Date: Tue, 13 Feb 2024 12:51:56 +1100 [thread overview]
Message-ID: <87ttmd6shv.fsf@mail.lhotse> (raw)
In-Reply-To: <669b8cbe-3fd4-44fb-be8d-f21def9f728e@csgroup.eu>
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 09/02/2024 à 08:59, Naveen N Rao a écrit :
>> Michael reported that we are seeing ftrace bug on bootup when KASAN is
>> enabled, and if we are using -fpatchable-function-entry:
>>
...
>> diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h
>> index ea26665f82cf..d389dcecdb0b 100644
>> --- a/arch/powerpc/include/asm/sections.h
>> +++ b/arch/powerpc/include/asm/sections.h
>> @@ -14,6 +14,7 @@ typedef struct func_desc func_desc_t;
>>
>> extern char __head_end[];
>> extern char __srwx_boundary[];
>> +extern char _sexittext[], _eexittext[];
>
> Should we try to at least use the same symbols as others, or best try to
> move this into include/asm-generic/sections.h, just like inittext ?
>
> $ git grep exittext
> arch/arm64/include/asm/sections.h:extern char __exittext_begin[],
> __exittext_end[];
> arch/arm64/kernel/patching.c: addr >= (unsigned
> long)__exittext_begin &&
> arch/arm64/kernel/patching.c: addr < (unsigned
> long)__exittext_end;
> arch/arm64/kernel/vmlinux.lds.S: __exittext_begin = .;
> arch/arm64/kernel/vmlinux.lds.S: __exittext_end = .;
> arch/riscv/include/asm/sections.h:extern char __exittext_begin[],
> __exittext_end[];
> arch/riscv/kernel/patch.c:static inline bool
> is_kernel_exittext(uintptr_t addr)
> arch/riscv/kernel/patch.c: addr >=
> (uintptr_t)__exittext_begin &&
> arch/riscv/kernel/patch.c: addr < (uintptr_t)__exittext_end;
> arch/riscv/kernel/patch.c: if (core_kernel_text(uintaddr) ||
> is_kernel_exittext(uintaddr))
> arch/riscv/kernel/vmlinux-xip.lds.S: __exittext_begin = .;
> arch/riscv/kernel/vmlinux-xip.lds.S: __exittext_end = .;
> arch/riscv/kernel/vmlinux.lds.S: __exittext_begin = .;
> arch/riscv/kernel/vmlinux.lds.S: __exittext_end = .;
I'll change it to use __exittext_begin/end.
>> diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
>> index 82010629cf88..b5efd8d7bc01 100644
>> --- a/arch/powerpc/kernel/trace/ftrace.c
>> +++ b/arch/powerpc/kernel/trace/ftrace.c
>> @@ -27,10 +27,22 @@
>> #include <asm/ftrace.h>
>> #include <asm/syscall.h>
>> #include <asm/inst.h>
>> +#include <asm/sections.h>
>>
>> #define NUM_FTRACE_TRAMPS 2
>> static unsigned long ftrace_tramps[NUM_FTRACE_TRAMPS];
>>
>> +unsigned long ftrace_call_adjust(unsigned long addr)
>> +{
>> + if (addr >= (unsigned long)_sexittext && addr < (unsigned long)_eexittext)
>> + return 0;
>
> Then arm64 has a function called is_exit_text() and riscv has
> is_kernel_exittext(). Can we refactor ?
I'd like to get the fix in and backported, so I'll take it as-is but
with the section names changed to match the other arches.
We can do further refactoring on top.
cheers
next prev parent reply other threads:[~2024-02-13 1:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 7:59 [PATCH] powerpc/ftrace: Ignore ftrace locations in exit text sections Naveen N Rao
2024-02-12 19:31 ` Christophe Leroy
2024-02-13 1:51 ` Michael Ellerman [this message]
2024-02-13 5:30 ` Naveen N Rao
2024-02-13 4:20 ` Benjamin Gray
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=87ttmd6shv.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=christophe.leroy@csgroup.eu \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=naveen@kernel.org \
--cc=rostedt@goodmis.org \
/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;
as well as URLs for NNTP newsgroup(s).