Page MenuHomeFreeBSD

[PowerPC] Implement jump table processing (Secure-PLT only) in ppc32 in-kernel linker, allow MD code to participate in DYNAMIC parsing.
ClosedPublic

Authored by bdragon on Nov 29 2019, 8:37 PM.

Details

Summary

Due to issues like https://reviews.llvm.org/D70570 (with more details @ https://reviews.llvm.org/D38554 ), clang's support for freestanding / static model / "EABI" code is still lacking on ppc32, and things like compiler builtins assume the availability of a PLT.

As such, implement the missing linker bits on ppc32 to support jump tables.

However, since GCC4 currently crashes on linker sets when building PIC on powerpc32, defer the actual PIC switch to clang flag day. ( D22798)

  • Add elf_cpu_parse_dynamic() to allow MD code to do its own DYNAMIC parsing. Add stubs to all link_elf.c platforms.
  • Implement jump table relocation for ppc32 secure-plt LD_BIND_NOW style and add a check to ensure it is only loading secure-plt modules (using elf_cpu_parse_dynamic())
  • Build kernel modules -fPIC on powerpc*. Moved to D22798 for flag day.
  • Poison the powerpc32 runtime resolver to ensure any attempts to call it cause an appropriate panic instead of a branch-to-zero.

Todo:

  • Figure out why dtrace is broken again. Was due to CTF type bloat, again.
  • Use elf_cpu_parse_dynamic() to make ppc64 module loading more robust?
  • ELFv1 (gcc4) testing. ELFv1 works with -fPIC (and doesn't generate PLT slots.)

Contra indications:

  • Using PIC kernel modules crashes GCC4 when compiling module<->module linker sets. (accf_http, etc.) As such, actual flipping of the switch will happen on the powerpc* clang flag day.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Looks good to me.

sys/powerpc/powerpc/elf32_machdep.c
423 ↗(On Diff #65060)

The return style is not very consistent on this file, but I think that on new functions at least it is better to always enclose return values in parentheses, as documented in style(9).

LGTM, modulo @luporl's remark about style.

This revision is now accepted and ready to land.Dec 10 2019, 7:11 PM

Address review comments, separate the actual kmod changes so I can get the kernel linker bits in separately from the actual switch-to-PIC.

This revision now requires review to proceed.Dec 13 2019, 6:32 PM
bdragon retitled this revision from [PowerPC] Switch to Secure-PLT PIC modules, allow MD code to participate in DYNAMIC parsing. to [PowerPC] Implement jump table processing (Secure-PLT only) in ppc32 in-kernel linker, allow MD code to participate in DYNAMIC parsing..Dec 13 2019, 6:44 PM
bdragon edited the summary of this revision. (Show Details)
bdragon added reviewers: kib, jhb.
bdragon edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Dec 13 2019, 7:32 PM