From owner-dev-commits-src-all@freebsd.org Mon Jun 21 17:00:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 52DD064BEBD; Mon, 21 Jun 2021 17:00:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G7wkw1ls1z4RQY; Mon, 21 Jun 2021 17:00:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 24A0120AAF; Mon, 21 Jun 2021 17:00:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15LH0OUT068603; Mon, 21 Jun 2021 17:00:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15LH0O9t068602; Mon, 21 Jun 2021 17:00:24 GMT (envelope-from git) Date: Mon, 21 Jun 2021 17:00:24 GMT Message-Id: <202106211700.15LH0O9t068602@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: c1da89fec254 - main - linux(4): Retire linux_kplatform. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c1da89fec254f9d079fc17a186e2665a32cc718d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2021 17:00:24 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c1da89fec254f9d079fc17a186e2665a32cc718d commit c1da89fec254f9d079fc17a186e2665a32cc718d Author: Dmitry Chagin AuthorDate: 2021-06-22 05:36:21 +0000 Commit: Dmitry Chagin CommitDate: 2021-06-22 05:36:21 +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 --- 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 ff18950548a5..32db8399ad42 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; @@ -791,9 +790,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 4b492c110556..d534d52392b6 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; @@ -955,9 +954,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 177f582ce11f..afcca9f7e948 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -65,7 +65,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; @@ -467,9 +466,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 1c1a8952bd79..65a5b0dd24d7 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 1a521716cec6..8b4cc201574f 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 c94f0824edca..13ebadacf3e3 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 *)p->p_sysent->sv_psstrings; - 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); @@ -286,13 +282,6 @@ linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base) arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings; 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 (execpath_len != 0) { destp -= execpath_len; destp = rounddown2(destp, sizeof(void *)); @@ -819,25 +808,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, @@ -1046,9 +1016,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);