From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Gray <bgray@linux.ibm.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: "ajd@linux.ibm.com" <ajd@linux.ibm.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"ardb@kernel.org" <ardb@kernel.org>,
"jbaron@akamai.com" <jbaron@akamai.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"npiggin@gmail.com" <npiggin@gmail.com>,
"jpoimboe@kernel.org" <jpoimboe@kernel.org>
Subject: Re: [PATCH 2/6] powerpc/module: Handle caller-saved TOC in module linker
Date: Mon, 19 Sep 2022 06:09:18 +0000 [thread overview]
Message-ID: <afad1073-d870-cd7d-040a-77ab10b3bb78@csgroup.eu> (raw)
In-Reply-To: <20220916062330.430468-3-bgray@linux.ibm.com>
Le 16/09/2022 à 08:23, Benjamin Gray a écrit :
> The callee may set a field in `st_other` to 1 to indicate r2 should be
> treated as caller-saved. This means a trampoline must be used to save
> the current TOC before calling it and restore it afterwards, much like
> external calls.
>
> This is necessary for supporting V2 ABI static calls that do not
> preserve the TOC.
>
> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
> ---
> arch/powerpc/kernel/module_64.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
> index 7e45dc98df8a..3656476097c2 100644
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -55,6 +55,11 @@ static unsigned int local_entry_offset(const Elf64_Sym *sym)
> * of function and try to derive r2 from it). */
> return PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
> }
> +
> +static bool need_r2save_stub(unsigned char st_other) {
Please read
https://docs.kernel.org/process/coding-style.html#placing-braces-and-spaces
" ... functions: they have the opening brace at the beginning of the
next line ..."
> + return ((st_other & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT) == 1;
> +}
> +
> #else
>
> static func_desc_t func_desc(unsigned long addr)
> @@ -66,6 +71,10 @@ static unsigned int local_entry_offset(const Elf64_Sym *sym)
> return 0;
> }
>
> +static bool need_r2save_stub(unsigned char st_other) {
> + return false;
> +}
> +
> void *dereference_module_function_descriptor(struct module *mod, void *ptr)
> {
> if (ptr < (void *)mod->arch.start_opd ||
> @@ -632,7 +641,8 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
> case R_PPC_REL24:
> /* FIXME: Handle weak symbols here --RR */
> if (sym->st_shndx == SHN_UNDEF ||
> - sym->st_shndx == SHN_LIVEPATCH) {
> + sym->st_shndx == SHN_LIVEPATCH ||
> + need_r2save_stub(sym->st_other)) {
> /* External: go via stub */
> value = stub_for_addr(sechdrs, value, me,
> strtab + sym->st_name);
next prev parent reply other threads:[~2022-09-19 6:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 6:23 [PATCH 0/6] Out-of-line static calls for powerpc64 ELF V2 Benjamin Gray
2022-09-16 6:23 ` [PATCH 1/6] powerpc/code-patching: Implement generic text patching function Benjamin Gray
2022-09-16 9:39 ` kernel test robot
2022-09-16 11:16 ` kernel test robot
2022-09-19 6:04 ` Christophe Leroy
2022-09-19 6:49 ` Benjamin Gray
2022-09-19 7:16 ` Christophe Leroy
2022-09-20 2:32 ` Benjamin Gray
2022-09-20 5:44 ` Christophe Leroy
2022-09-20 7:01 ` Benjamin Gray
2022-09-19 6:38 ` Christophe Leroy
2022-09-20 1:49 ` Benjamin Gray
2022-09-16 6:23 ` [PATCH 2/6] powerpc/module: Handle caller-saved TOC in module linker Benjamin Gray
2022-09-19 6:09 ` Christophe Leroy [this message]
2022-09-16 6:23 ` [PATCH 3/6] powerpc/module: Optimise nearby branches in ELF V2 ABI stub Benjamin Gray
2022-09-19 6:11 ` Christophe Leroy
2022-09-16 6:23 ` [PATCH 4/6] static_call: Move static call selftest to static_call_selftest.c Benjamin Gray
2022-09-20 4:30 ` Andrew Donnellan
2022-09-16 6:23 ` [PATCH 5/6] powerpc/64: Add support for out-of-line static calls Benjamin Gray
2022-09-16 8:32 ` kernel test robot
2022-09-16 6:23 ` [PATCH 6/6] powerpc/64: Add tests " 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=afad1073-d870-cd7d-040a-77ab10b3bb78@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=ajd@linux.ibm.com \
--cc=ardb@kernel.org \
--cc=bgray@linux.ibm.com \
--cc=jbaron@akamai.com \
--cc=jpoimboe@kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.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).