Page MenuHomeFreeBSD

powerpc64: only sync icache if we relocated in executable segment
Needs RevisionPublic

Authored by kib on Dec 16 2025, 6:17 AM.
Referenced Files
Unknown Object (File)
Tue, Jan 27, 10:52 AM
Unknown Object (File)
Tue, Jan 27, 7:24 AM
Unknown Object (File)
Tue, Jan 27, 6:14 AM
Unknown Object (File)
Tue, Jan 27, 4:38 AM
Unknown Object (File)
Sat, Jan 24, 6:18 PM
Unknown Object (File)
Tue, Jan 20, 6:11 AM
Unknown Object (File)
Fri, Jan 16, 3:57 AM
Unknown Object (File)
Jan 6 2026, 6:04 AM

Details

Reviewers
adrian
jrtc27
Group Reviewers
PowerPC
Summary

and only after all relocations for the segment are processed.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Dec 16 2025, 6:17 AM

ok, I cleaned this up and have tested it in a chroot constantly doing buildkernel. It didn't trigger any make failures so far.

https://people.freebsd.org/~adrian/powerpc64/20260125-D54246-fixup-1.diff

libexec/rtld-elf/powerpc64/reloc.c
421–423

we dont need this loop anymore, no?

kib marked an inline comment as done.

Remove nop loop.

libexec/rtld-elf/powerpc64/reloc.c
352

oops I didn't convert this from c-- to c++, please update

kib marked an inline comment as done.Sun, Jan 25, 6:37 PM

This works for me on freebsd-16 on power8, I'm doing test buildworld -j32 on it right now!

This revision is now accepted and ready to land.Sun, Jan 25, 10:00 PM
jrtc27 requested changes to this revision.Sun, Jan 25, 10:03 PM
jrtc27 added a subscriber: jrtc27.

This works for me on freebsd-16 on power8, I'm doing test buildworld -j32 on it right now!

But does the isync code ever get hit? This doesn't make sense to me. It's a whole bunch of complexity for something that we are missing a crucial part of to actually be useful, namely handling the relocations actually used for instructions rather than data.

This revision now requires changes to proceed.Sun, Jan 25, 10:03 PM
libexec/rtld-elf/powerpc64/reloc.c
335–336

I believe this should never end up being printed. Please test that? If it does, I would be extremely interested in what the object in question is.

ok, but on insistence from jrtc27 i added some debug logging here and it's never actually invoking syncicache in my tests.

ivy, what were you running make on? just buildworld/buildkernel or something else?

ok, but on insistence from jrtc27 i added some debug logging here and it's never actually invoking syncicache in my tests.

This does not mean much. It only shows that the current binaries do not have this issue. But old binaries might have, then removing the hack breaks them.

This is really about Tier 2 arch, where the project officially does not care about ABI and ability to run all existing binaries.

In D54246#1254644, @kib wrote:

ok, but on insistence from jrtc27 i added some debug logging here and it's never actually invoking syncicache in my tests.

This does not mean much. It only shows that the current binaries do not have this issue. But old binaries might have, then removing the hack breaks them.

Please, read what I've said many times. There is no world in which flushing the icache is helpful for the set of dynamic relocations that rtld supports, and none of them are relocations that glibc will ever flush the icache for. Therefore it is utterly pointless to have code to do so.

This is really about Tier 2 arch, where the project officially does not care about ABI and ability to run all existing binaries.

No, I would say the exact same thing if it were Tier 1. This is useless code that only serves to slow down program loading.

ok so I had a chat with jessica, and after some more digging to try and understand what's going on here, I see both views:

  • jessica says we shouldn't /see/ instruction relocation because we don't have any of the relocated bits here
  • kib says we should support the relocation bits in case someone finds/found a silly way to use it in the text segment.

I've tested building some ports and kernel/world, I haven't seen it fire once on an executable segment.

So, I don't necessarily like deleting it without having some runtime checks to know that someone's not doing anything daft.
So how about the worst of both worlds? This diff, but in the call to syncicache we actually put a _rtld_fdprintf(STDERR_FILENO, ...) and abort() call for -16.

That way we can catch if something happens that's unexpected hopefully by said error print/abort rather than weird occasional
stuff happening.