aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2021-06-22 05:36:21 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2021-06-22 05:36:21 +0000
commitc1da89fec254f9d079fc17a186e2665a32cc718d (patch)
tree8c8207002b06ef1bd0e769718aeaa0a931addda8 /sys
parente013e36939ac87b53195370fb5e29f29c1a4b5c6 (diff)
downloadsrc-c1da89fec254f9d079fc17a186e2665a32cc718d.tar.gz
src-c1da89fec254f9d079fc17a186e2665a32cc718d.zip
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
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/linux/linux_sysvec.c4
-rw-r--r--sys/amd64/linux32/linux32_sysvec.c4
-rw-r--r--sys/arm64/linux/linux_sysvec.c4
-rw-r--r--sys/compat/linux/linux_misc.c6
-rw-r--r--sys/compat/linux/linux_misc.h2
-rw-r--r--sys/i386/linux/linux_locore.asm8
-rw-r--r--sys/i386/linux/linux_sysvec.c37
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);