libsys: Add AT_HWCAP3 and AT_HWCAP4

This is needed to read these values.

Reviewed by:	brooks, imp, kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D51006
This commit is contained in:
Andrew Turner 2025-06-24 15:56:54 +01:00
parent 85007872d1
commit fa1c23da01
2 changed files with 33 additions and 3 deletions

View file

@ -22,7 +22,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 16, 2022
.Dd June 24, 2025
.Dt ELF_AUX_INFO 3
.Os
.Sh NAME
@ -59,6 +59,12 @@ CPU / hardware feature flags
.It AT_HWCAP2
CPU / hardware feature flags
.Dv (sizeof(u_long)).
.It AT_HWCAP3
CPU / hardware feature flags
.Dv (sizeof(u_long)).
.It AT_HWCAP4
CPU / hardware feature flags
.Dv (sizeof(u_long)).
.It AT_NCPUS
Number of CPUs
.Dv (sizeof(int)).

View file

@ -69,10 +69,10 @@ __init_elf_aux_vector(void)
static int aux_once;
static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags;
static int hwcap_present, hwcap2_present;
static int hwcap_present, hwcap2_present, hwcap3_present, hwcap4_present;
static char *canary, *pagesizes, *execpath;
static void *ps_strings, *timekeep;
static u_long hwcap, hwcap2;
static u_long hwcap, hwcap2, hwcap3, hwcap4;
static void *fxrng_seed_version;
static u_long usrstackbase, usrstacklim;
@ -123,6 +123,16 @@ init_aux(void)
hwcap2 = (u_long)(aux->a_un.a_val);
break;
case AT_HWCAP3:
hwcap3_present = 1;
hwcap3 = (u_long)(aux->a_un.a_val);
break;
case AT_HWCAP4:
hwcap4_present = 1;
hwcap4 = (u_long)(aux->a_un.a_val);
break;
case AT_PAGESIZES:
pagesizes = (char *)(aux->a_un.a_ptr);
break;
@ -318,6 +328,20 @@ _elf_aux_info(int aux, void *buf, int buflen)
} else
res = ENOENT;
break;
case AT_HWCAP3:
if (hwcap3_present && buflen == sizeof(u_long)) {
*(u_long *)buf = hwcap3;
res = 0;
} else
res = ENOENT;
break;
case AT_HWCAP4:
if (hwcap4_present && buflen == sizeof(u_long)) {
*(u_long *)buf = hwcap4;
res = 0;
} else
res = ENOENT;
break;
case AT_PAGESIZES:
if (pagesizes != NULL && pagesizes_len >= buflen) {
memcpy(buf, pagesizes, buflen);