Page MenuHomeFreeBSD

[PowerPC] Define powerpc IFUNC kernel/userspace ABI.
ClosedPublic

Authored by bdragon on Dec 12 2019, 11:18 PM.
Referenced Files
Unknown Object (File)
Fri, Apr 19, 9:07 PM
Unknown Object (File)
Wed, Apr 10, 2:39 PM
Unknown Object (File)
Mon, Apr 1, 2:14 AM
Unknown Object (File)
Mar 18 2024, 10:03 PM
Unknown Object (File)
Jan 27 2024, 5:44 PM
Unknown Object (File)
Jan 27 2024, 5:44 PM
Unknown Object (File)
Jan 27 2024, 5:43 PM
Unknown Object (File)
Jan 27 2024, 5:43 PM

Details

Summary

This is a prerequisite for anything IFUNC in the ELFv2 / clang switch.

Since probing cpu info on powerpc is a privileged operation, define that we pass AT_HWCAP / AT_HWCAP2 through as cpu_features and cpu_features2 to ifunc resolvers. (This is particularly important when dealing with non-PLT GNU IFUNC, which is not allowed to PLT call from resolvers and therefore can't access global variables.)

This naming convention matches how we expose these two variables in machine/cpu.h. It is a FreeBSD/powerpc specific convention.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/powerpc/include/ifunc.h
2 ↗(On Diff #65566)

I'm not sure what to do about the license header. Is it okay to leave it as is?

46 ↗(On Diff #65566)

Specifically defining as register_t on purpose here.
We only use the low order 32 bits of the variables so it should be okay on *any* powerpc variant.

kib added inline comments.
sys/powerpc/include/ifunc.h
2 ↗(On Diff #65566)

I think you should add your copyright assert there.

5 ↗(On Diff #65566)

Part of this software. If you want to keep this line.

53 ↗(On Diff #65566)

Does PPC allows to pass up to 10 args in registers ?

sys/powerpc/include/ifunc.h
46 ↗(On Diff #65566)

Why not use int, in that case? Are you expecting sys/types.h be included in all resolver files?

sys/powerpc/include/ifunc.h
46 ↗(On Diff #65566)

I am, yes. This file defines a contract between software (especially libc) and the runtime linker (in DEFINE_UIFUNC) and between the kernel and the kernel linker (in DEFINE_IFUNC).

This is a machine dependent interface, and I'd rather be precise about it.

53 ↗(On Diff #65566)

Register passing is r3-r10, so 8 args total.

sys/powerpc/include/ifunc.h
46 ↗(On Diff #65566)

Additionally, if non PLT gnu ifunc is in use, there are severe restrictions on how a resolver works -- it can not make PLT calls of any sort, and it may be called at any point, so must be self-contained.

sys/powerpc/include/ifunc.h
2 ↗(On Diff #65566)

Not a copyright expert by any means, but I think kib's saying the triviality of the file means the FreeBSD Foundation copyright is unnecessary, as is his below. You effectively have copyright over more than half the non-license portion of the file, relative to the x86 ifunc.h.

46 ↗(On Diff #65566)

Why not include sys/types.h in this file, then? It's not without precedent (machine/cpufunc.h does already).

This revision is now accepted and ready to land.Dec 24 2019, 5:50 PM