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
This commit is contained in:
parent
e013e36939
commit
c1da89fec2
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
|
@ -74,8 +74,6 @@
|
||||
|
||||
#define LINUX_PATH_MAX 4096
|
||||
|
||||
extern const char *linux_kplatform;
|
||||
|
||||
/*
|
||||
* Non-standard aux entry types used in Linux ELF binaries.
|
||||
*/
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user