git: b36eaf0f4ce8 - stable/13 - linux: fix architecture returned for uname on aarch64

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

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

commit b36eaf0f4ce85b40e65a03235439fd827544dcc4
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-05-28 23:01:55 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 23:21:20 +0000

    linux: fix architecture returned for uname on aarch64
    
    Previously it would return "arm64", which was breaking build
    for Linux kernel.  While here, reshuffle entries in the auxv
    vector to match real Linux.
    
    Reviewed By:    emaste
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D30500
    
    (cherry picked from commit aa462cab60c8957a97f612d36ac0a4dfa501bbbe)
---
 sys/arm64/linux/linux_locore.asm |  2 +-
 sys/arm64/linux/linux_sysvec.c   | 12 +++---------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/sys/arm64/linux/linux_locore.asm b/sys/arm64/linux/linux_locore.asm
index 0383e6770954..5f0729b363e8 100644
--- a/sys/arm64/linux/linux_locore.asm
+++ b/sys/arm64/linux/linux_locore.asm
@@ -40,7 +40,7 @@
 
 	.globl linux_platform
 linux_platform:
-	.asciz "arm64"
+	.asciz "aarch64"
 
 	.text
 
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index 6d05d7efa08c..0ffdf9cb424e 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -175,11 +175,11 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
 #if 0	/* LINUXTODO: implement arm64 LINUX_AT_HWCAP */
 	AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
 #endif
+	AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
 	AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
 	AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
 	AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
 	AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
-	AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
 	AUXARGS_ENTRY(pos, AT_BASE, args->base);
 	AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
 	AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
@@ -188,15 +188,14 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
 	AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
 	AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
 	AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
-#if 0	/* LINUXTODO: implement arm64 LINUX_AT_PLATFORM */
-	AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
-#endif
 	AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
 	if (imgp->execpathp != 0)
 		AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
 	if (args->execfd != -1)
 		AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
+	AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
 	AUXARGS_ENTRY(pos, AT_NULL, 0);
+
 	free(imgp->auxargs, M_TEMP);
 	imgp->auxargs = NULL;
 	KASSERT(pos - argarray <= LINUX_AT_COUNT, ("Too many auxargs"));
@@ -465,13 +464,8 @@ linux_vdso_install(const void *param)
 	    linux_szsigcode);
 	elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
 
-	printf("LINUXTODO: %s: fix linux_kplatform\n", __func__);
-#if 0
 	linux_kplatform = linux_shared_page_mapping +
 	    (linux_platform - (caddr_t)elf_linux_sysvec.sv_shared_page_base);
-#else
-	linux_kplatform = "arm64";
-#endif
 }
 SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
     linux_vdso_install, NULL);