linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: "Fāng-ruì Sòng" <maskray@google.com>,
	"Alexey Kardashevskiy" <aik@ozlabs.ru>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	linuxppc-dev@lists.ozlabs.org,
	Nathan Chancellor <nathan@kernel.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] powerpc: Replace ppc64 DT_RELACOUNT usage with DT_RELASZ/24
Date: Fri, 11 Mar 2022 15:15:59 +1100	[thread overview]
Message-ID: <87a6dxm8e8.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <CAFP8O3+jJf=amTYjm6YQbJKAuK0XRNoG3Gwc6C+E0=CPd46ZAw@mail.gmail.com>

Fāng-ruì Sòng <maskray@google.com> writes:
> On Thu, Mar 10, 2022 at 11:48 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
>>
>> On Tue, Mar 8, 2022 at 9:53 PM Fangrui Song <maskray@google.com> wrote:
>> >
>> > DT_RELACOUNT is an ELF dynamic tag inherited from SunOS indicating the
>> > number of R_*_RELATIVE relocations. It is optional but {ld.lld,ld.lld}
>> > -z combreloc always creates it (if non-zero) to slightly speed up glibc
>> > ld.so relocation resolving by avoiding R_*R_PPC64_RELATIVE type
>> > comparison. The tag is otherwise nearly unused in the wild and I'd
>> > recommend that software avoids using it.
>> >
>> > lld>=14.0.0 (since commit da0e5b885b25cf4ded0fa89b965dc6979ac02ca9)
>> > underestimates DT_RELACOUNT for ppc64 when position-independent long
>> > branch thunks are used. Correcting it needs non-trivial arch-specific
>> > complexity which I'd prefer to avoid. Since our code always compares the
>> > relocation type with R_PPC64_RELATIVE, replacing every occurrence of
>> > DT_RELACOUNT with DT_RELASZ/sizeof(Elf64_Rela)=DT_RELASZ/24 is a correct
>> > alternative.
>>
>> checking that sizeof(Elf64_Rela) == 24, yep: https://godbolt.org/z/bb4aKbo5T
>>
>> >
>> > DT_RELASZ is in practice bounded by an uint32_t. Dividing x by 24 can be
>> > implemented as (uint32_t)(x*0xaaaaaaab) >> 4.
>>
>> Yep: https://godbolt.org/z/x9445ePPv
>>
>> >
>> > Link: https://github.com/ClangBuiltLinux/linux/issues/1581
>> > Reported-by: Nathan Chancellor <nathan@kernel.org>
>> > Signed-off-by: Fangrui Song <maskray@google.com>
>> > ---
>> >  arch/powerpc/boot/crt0.S       | 28 +++++++++++++++++-----------
>> >  arch/powerpc/kernel/reloc_64.S | 15 +++++++++------
>> >  2 files changed, 26 insertions(+), 17 deletions(-)
...

> I rebased the patch on
> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
> master and got a conflict.
> Seems that https://lore.kernel.org/linuxppc-dev/20220309061822.168173-1-aik@ozlabs.ru/T/#u
> ("[PATCH kernel v4] powerpc/64: Add UADDR64 relocation support") fixed
> the issue.
> It just doesn't change arch/powerpc/boot/crt0.S

Yeah sorry, I applied Alexey's v4 just before I saw your patch arrive on
the list.

If one of you can rework this so it applies on top that would be great :)

cheers

  reply	other threads:[~2022-03-11  4:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09  5:51 [PATCH] powerpc: Replace ppc64 DT_RELACOUNT usage with DT_RELASZ/24 Fangrui Song
2022-03-09 19:01 ` Nathan Chancellor
2022-03-10 19:48 ` Nick Desaulniers
2022-03-10 21:08   ` Fāng-ruì Sòng
2022-03-11  4:15     ` Michael Ellerman [this message]
2022-03-11  4:35       ` Alexey Kardashevskiy

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=87a6dxm8e8.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=aik@ozlabs.ru \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=llvm@lists.linux.dev \
    --cc=maskray@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.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;
as well as URLs for NNTP newsgroup(s).