Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2022 19:32:08 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0cd177a3d394 - stable/13 - linux(4): Retire linux_kplatform.
Message-ID:  <202206171932.25HJW8ui008062@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

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

commit 0cd177a3d394177dd7d9245a190fbd71ddc3ccba
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-06-17 19:30:23 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:30:23 +0000

    linux(4): Retire linux_kplatform.
    
    Assuming we can't run on i486, i586 class cpu, retire linux_kplatform var
    and use hardcoded 'machine' value in linux_newuname().
    
    I have added linux_kplatform for consistency with linux_platform which is
    placed in to vdso to avoid excess copyout it on stack for AT_PLATFORM at
    exec time.
    
    This is the first stage of Linuxulator's vdso revision.
    
    Reviewed by:            trasz, imp
    Differential Revision:  https://reviews.freebsd.org/D30774
    MFC after:              2 weeks
    
    (cherry picked from commit c1da89fec254f9d079fc17a186e2665a32cc718d)
---
 sys/amd64/linux/linux_sysvec.c     |  4 ----
 sys/amd64/linux32/linux32_sysvec.c |  4 ----
 sys/arm64/linux/linux_sysvec.c     |  4 ----
 sys/compat/linux/linux_misc.c      |  6 ++++--
 sys/compat/linux/linux_misc.h      |  2 --
 sys/i386/linux/linux_locore.asm    |  8 ++++++++
 sys/i386/linux/linux_sysvec.c      | 37 ++-----------------------------------
 7 files changed, 14 insertions(+), 51 deletions(-)

diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index e6bbed4ba836..54870b0153c9 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -85,7 +85,6 @@ __FBSDID("$FreeBSD$");
 
 MODULE_VERSION(linux64, 1);
 
-const char *linux_kplatform;
 static int linux_szsigcode;
 static vm_object_t linux_shared_page_obj;
 static char *linux_shared_page_mapping;
@@ -789,9 +788,6 @@ linux_vdso_install(void *param)
 	bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
 	    linux_szsigcode);
 	elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
-
-	linux_kplatform = linux_shared_page_mapping +
-	    (linux_platform - (caddr_t)elf_linux_sysvec.sv_shared_page_base);
 }
 SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
     linux_vdso_install, NULL);
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index cce0c8261a84..2670f9ff7b83 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -90,7 +90,6 @@ __FBSDID("$FreeBSD$");
 
 MODULE_VERSION(linux, 1);
 
-const char *linux_kplatform;
 static int linux_szsigcode;
 static vm_object_t linux_shared_page_obj;
 static char *linux_shared_page_mapping;
@@ -950,9 +949,6 @@ linux_vdso_install(void *param)
 	bcopy(elf_linux_sysvec.sv_sigcode, linux_shared_page_mapping,
 	    linux_szsigcode);
 	elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
-
-	linux_kplatform = linux_shared_page_mapping +
-	    (linux_platform - (caddr_t)elf_linux_sysvec.sv_shared_page_base);
 }
 SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
     linux_vdso_install, NULL);
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index 1051cd755883..5a2edcefac2c 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -68,7 +68,6 @@ __FBSDID("$FreeBSD$");
 
 MODULE_VERSION(linux64elf, 1);
 
-const char *linux_kplatform;
 static int linux_szsigcode;
 static vm_object_t linux_shared_page_obj;
 static char *linux_shared_page_mapping;
@@ -458,9 +457,6 @@ linux_vdso_install(const void *param)
 	memcpy(linux_shared_page_mapping, elf_linux_sysvec.sv_sigcode,
 	    linux_szsigcode);
 	elf_linux_sysvec.sv_shared_page_obj = linux_shared_page_obj;
-
-	linux_kplatform = linux_shared_page_mapping +
-	    (linux_platform - (caddr_t)elf_linux_sysvec.sv_shared_page_base);
 }
 SYSINIT(elf_linux_vdso_init, SI_SUB_EXEC, SI_ORDER_ANY,
     linux_vdso_install, NULL);
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index a6e170f47435..117b36056760 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -721,8 +721,10 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
 	 * to remain "i686", though.
 	 */
 	strlcpy(utsname.machine, "x86_64", LINUX_MAX_UTSNAME);
-#else
-	strlcpy(utsname.machine, linux_kplatform, LINUX_MAX_UTSNAME);
+#elif defined(__aarch64__)
+	strlcpy(utsname.machine, "aarch64", LINUX_MAX_UTSNAME);
+#elif defined(__i386__)
+	strlcpy(utsname.machine, "i686", LINUX_MAX_UTSNAME);
 #endif
 
 	return (copyout(&utsname, args->buf, sizeof(utsname)));
diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h
index bd8b2f3f63b4..dc17ed430014 100644
--- a/sys/compat/linux/linux_misc.h
+++ b/sys/compat/linux/linux_misc.h
@@ -74,8 +74,6 @@
 
 #define	LINUX_PATH_MAX		4096
 
-extern const char *linux_kplatform;
-
 /*
  * Non-standard aux entry types used in Linux ELF binaries.
  */
diff --git a/sys/i386/linux/linux_locore.asm b/sys/i386/linux/linux_locore.asm
index 8c2499af872e..11427345f7ce 100644
--- a/sys/i386/linux/linux_locore.asm
+++ b/sys/i386/linux/linux_locore.asm
@@ -7,6 +7,14 @@
 
 #include "assym.inc"
 
+	.data
+
+	.globl linux_platform
+linux_platform:
+	.asciz "i686"
+
+	.text
+
 /*
  * To avoid excess stack frame the signal trampoline code emulates
  * the 'call' instruction.
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index ed7223f3681a..e01526d9b8b0 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -100,9 +100,6 @@ static bool	linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static void	linux_vdso_install(void *param);
 static void	linux_vdso_deinstall(void *param);
 
-static int linux_szplatform;
-const char *linux_kplatform;
-
 #define LINUX_T_UNKNOWN  255
 static int _bsd_to_linux_trapcode[] = {
 	LINUX_T_UNKNOWN,	/* 0 */
@@ -142,6 +139,7 @@ static int _bsd_to_linux_trapcode[] = {
      _bsd_to_linux_trapcode[(code)]: \
      LINUX_T_UNKNOWN)
 
+LINUX_VDSO_SYM_CHAR(linux_platform);
 LINUX_VDSO_SYM_INTPTR(linux_sigcode);
 LINUX_VDSO_SYM_INTPTR(linux_rt_sigcode);
 LINUX_VDSO_SYM_INTPTR(linux_vsyscall);
@@ -192,14 +190,12 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
 	struct proc *p;
 	Elf32_Auxargs *args;
 	Elf32_Auxinfo *argarray, *pos;
-	Elf32_Addr *uplatform;
 	struct ps_strings *arginfo;
 	int error, issetugid;
 
 	p = imgp->proc;
 	issetugid = imgp->proc->p_flag & P_SUGID ? 1 : 0;
 	arginfo = (struct ps_strings *)PROC_PS_STRINGS(p);
-	uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform);
 	args = (Elf32_Auxargs *)imgp->auxargs;
 	argarray = pos = malloc(LINUX_AT_COUNT * sizeof(*pos), M_TEMP,
 	    M_WAITOK | M_ZERO);
@@ -231,7 +227,7 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
 	AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
 	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_PLATFORM, PTROUT(uplatform));
+	AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
 	AUXARGS_ENTRY_PTR(pos, LINUX_AT_RANDOM, imgp->canary);
 	if (imgp->execpathp != 0)
 		AUXARGS_ENTRY_PTR(pos, LINUX_AT_EXECFN, imgp->execpathp);
@@ -281,13 +277,6 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 	arginfo = (struct ps_strings *)PROC_PS_STRINGS(p);
 	destp = (uintptr_t)arginfo;
 
-	/* Install LINUX_PLATFORM. */
-	destp -= linux_szplatform;
-	destp = rounddown2(destp, sizeof(void *));
-	error = copyout(linux_kplatform, (void *)destp, linux_szplatform);
-	if (error != 0)
-		return (error);
-
 	if (imgp->execpath != NULL && imgp->auxargs != NULL) {
 		execpath_len = strlen(imgp->execpath) + 1;
 		destp -= execpath_len;
@@ -815,25 +804,6 @@ linux_exec_setregs(struct thread *td, struct image_params *imgp,
 	pcb->pcb_initial_npxcw = __LINUX_NPXCW__;
 }
 
-static void
-linux_get_machine(const char **dst)
-{
-
-	switch (cpu_class) {
-	case CPUCLASS_686:
-		*dst = "i686";
-		break;
-	case CPUCLASS_586:
-		*dst = "i586";
-		break;
-	case CPUCLASS_486:
-		*dst = "i486";
-		break;
-	default:
-		*dst = "i386";
-	}
-}
-
 struct sysentvec linux_sysvec = {
 	.sv_size	= LINUX_SYS_MAXSYSCALL,
 	.sv_table	= linux_sysent,
@@ -1047,9 +1017,6 @@ linux_elf_modevent(module_t mod, int type, void *data)
 				linux_ioctl_register_handler(*lihp);
 			LIST_INIT(&futex_list);
 			mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
-			linux_get_machine(&linux_kplatform);
-			linux_szplatform = roundup(strlen(linux_kplatform) + 1,
-			    sizeof(char *));
 			linux_dev_shm_create();
 			linux_osd_jail_register();
 			stclohz = (stathz ? stathz : hz);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206171932.25HJW8ui008062>