Page MenuHomeFreeBSD

Add AT_HWCAP and AT_EHDRFLAGS on all platforms.
ClosedPublic

Authored by jhb on Sep 9 2017, 2:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 7 2024, 11:29 PM
Unknown Object (File)
Feb 27 2024, 5:59 AM
Unknown Object (File)
Feb 13 2024, 7:55 AM
Unknown Object (File)
Jan 3 2024, 12:26 PM
Unknown Object (File)
Dec 20 2023, 3:36 AM
Unknown Object (File)
Dec 4 2023, 3:38 AM
Unknown Object (File)
Nov 12 2023, 6:02 PM
Unknown Object (File)
Nov 10 2023, 10:03 AM

Details

Summary

AT_HWCAP is populated with the value of global elf32_hwcap and
elf64_hwcap values. Platform-specific code can adjust these
global variables to control the values passed in exec.

Test Plan

This is part of a series which I tested by using VFP registers with
gdb on armv7. powerpc could probably set elf*_hwcap easily as I think
we currently export sysctls with those values now.

I think moving AT_* to elf_common.h is still a useful followup.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 11523
Build 11877: arc lint + arc unit

Event Timeline

Looks good to me.

I think it's sensible to follow up with migration to a single elf.h, probably @jhibbits can first make powerpc's match the rest?

One common typo: "CPU featire flags" should be "CPU feature flags".

sys/kern/imgact_elf.c
140

Shouldn't this be per elf brand or per sysvec, I am not sure which one is more useful, perhaps sysvec is enough.

I believe that requiring that linux and native hwcap bits always match is not going to work, even ifit is now.

sys/kern/imgact_elf.c
140

The callback that uses it (elf32/64freebsd_fixup) is already per-sysvec. Non-FreeBSD ABIs have to use a separate sv_fixup callback to set their ABI-specific auxv values which won't use this variable (e.g. elf_linux_fixup in sys/amd64/linux32/linux32_sysvec.c)

kib added inline comments.
sys/kern/imgact_elf.c
140

Yes, I do not like that the variable is global instead of living in sysvecent.

This revision is now accepted and ready to land.Sep 10 2017, 8:34 AM
sys/kern/imgact_elf.c
140

Hmm, I could either store a pointer to a variable in sysvecent or the variable itself in the sysvecent. The latter would require exporting the entire sysvecent as an extern and probably makes it harder to share values across sysvecent if needed (e.g. I imagine on aarch64 the same hwcap might end up being shared for an eventual COMPAT_FREEBSD32), so perhaps the first is better?

sys/kern/imgact_elf.c
140

A pointer to a variable sounds fine.

On ARM platforms I expect we'll need more bits. Linux already has AT_HWCAP2, it might pay to include it from the start.

  • Replace elf32/64_hwcap with a sv_hwcap pointer in sysentvec.
  • Only provide AT_HWCAP if the pointer exists.
This revision now requires review to proceed.Sep 12 2017, 6:39 PM
jhb marked 2 inline comments as done.Sep 12 2017, 6:43 PM

Re: AT_HWCAP2, once elf.h is unified (which I will probably work on soon) it will be fairly easy to add.

One question is if 'u_long' is the right type for 'sv_hwcap'.

kib accepted this revision.EditedSep 13 2017, 9:42 AM
In D12290#255968, @jhb wrote:

One question is if 'u_long' is the right type for 'sv_hwcap'.

De-facto long becomes the way to express the 'native word size' of a machine. It is used more often than register_t, and I think that register_t is actually wrong e.g. on mips n32 for this purpose.

So the actual initialization of *sv_hwcap for native sysents will follow in a separate patch, I suppose ?

This revision is now accepted and ready to land.Sep 13 2017, 9:42 AM
In D12290#256189, @kib wrote:
In D12290#255968, @jhb wrote:

One question is if 'u_long' is the right type for 'sv_hwcap'.

De-facto long becomes the way to express the 'native word size' of a machine. It is used more often than register_t, and I think that register_t is actually wrong e.g. on mips n32 for this purpose.

So the actual initialization of *sv_hwcap for native sysents will follow in a separate patch, I suppose ?

You can see the other patches for arm in this series if you click on 'Stack' in the revision contents box (and I'd appreciate your review on any of the others if you wish). So far I've only implemented this for arm. ppc is probably trivial to add, and arm64 may very well use the same values as 32-bit arm, but I'll defer to Andrew on that. Also, the values I have supported for arm so far are fairly limited, but more can be added by others easily enough.

This revision was automatically updated to reflect the committed changes.