abi-aa icon indicating copy to clipboard operation
abi-aa copied to clipboard

[FMV][AArch64] Document the interface for Function Multi-versioning.

Open labrinea opened this issue 6 months ago • 3 comments

Documents the Application Binary Interface requirements for Function Multi-versioning on System V platforms.

A global variable __aarch64_cpu_features that contains a description of the detected CPU features is used for selecting the best function version.

Initialization of the __aarch64_cpu_features is performed by the runtime. A runtime function __init_cpu_features_resolver must ensure that __aarch64_cpu_features is populated. This function must be provided by the runtime environment and be defined as DSO local.

labrinea avatar Jun 05 '25 15:06 labrinea

Would you be able to write a quick summary for the description, and add a line in the Change History?

smithp35 avatar Jun 06 '25 10:06 smithp35

ping

labrinea avatar Jun 17 '25 16:06 labrinea

Adding @jroelofs for visibility

labrinea avatar Jun 24 '25 15:06 labrinea

Use a form of FMV that doesn't use ifuncs. I guess that has to be some kind of additional code that runs every time the function is called.

Another option: do what we're doing on Darwin, and use hand-rolled lazy-init function pointer's to resolvers that replace themselves with the callee the first time they're called.

jroelofs avatar Jul 02 '25 17:07 jroelofs

Thanks for reviewing!

labrinea avatar Jul 03 '25 17:07 labrinea

After further digging we found that the __aarch64_cpu_features global is used by __builtin_cpu_supports and the runtime library for SME. These two rely on constructors which run after the resolvers have run, meaning RELRO cannot be used in conjunction with them. Shall I word all of this info with a note, or just remove the mention of RELRO entirely?

labrinea avatar Jul 17 '25 13:07 labrinea