git: 5d5616acec5b - stable/13 - linux: export AT_HWCAP and AT_HWCAP2 on aarch64

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Thu, 17 Feb 2022 13:46:24 UTC
The branch stable/13 has been updated by trasz:

URL: https://cgit.FreeBSD.org/src/commit/?id=5d5616acec5be93e64d353ce7212ee93c7fbeb20

commit 5d5616acec5be93e64d353ce7212ee93c7fbeb20
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-06-01 12:12:25 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 23:21:35 +0000

    linux: export AT_HWCAP and AT_HWCAP2 on aarch64
    
    The flag values seem to be the same between Linux and FreeBSD.
    Comparing to a Linux VM on the same hardware, we're missing
    HWCAP_EVTSTRM, HWCAP_CPUID, HWCAP_DCPOP, HWCAP_USCAT, HWCAP_PACA,
    and HWCAP_PACG.
    
    Reviewed By:    mhorne, emaste
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D30540
    
    (cherry picked from commit b501b2ae52f3ccb384584dcbb5dc4a4568cc0096)
---
 sys/arm64/linux/linux_sysvec.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index 0ffdf9cb424e..de8dd023f82d 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$");
 #include <compat/linux/linux_util.h>
 #include <compat/linux/linux_vdso.h>
 
+#include <machine/md_var.h>
+
 #ifdef VFP
 #include <machine/vfp.h>
 #endif
@@ -172,9 +174,7 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
 	issetugid = p->p_flag & P_SUGID ? 1 : 0;
 	AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR,
 	    imgp->proc->p_sysent->sv_shared_page_base);
-#if 0	/* LINUXTODO: implement arm64 LINUX_AT_HWCAP */
-	AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
-#endif
+	AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, *imgp->sysent->sv_hwcap);
 	AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
 	AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
 	AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
@@ -189,6 +189,7 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
 	AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
 	AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
 	AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
+	AUXARGS_ENTRY(pos, LINUX_AT_HWCAP2, *imgp->sysent->sv_hwcap2);
 	if (imgp->execpathp != 0)
 		AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
 	if (args->execfd != -1)
@@ -437,6 +438,8 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_schedtail	= linux_schedtail,
 	.sv_thread_detach = linux_thread_detach,
 	.sv_trap	= linux_vsyscall,
+	.sv_hwcap	= &elf_hwcap,
+	.sv_hwcap2	= &elf_hwcap2,
 	.sv_onexec	= linux_on_exec,
 	.sv_onexit	= linux_on_exit,
 	.sv_ontdexit	= linux_thread_dtor,