Skip to content

Commit

Permalink
OS-5322 lxbrand use comm page for vdso
Browse files Browse the repository at this point in the history
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
  • Loading branch information
pfmooney committed May 20, 2016
1 parent d1b35f5 commit e6e2cd9
Show file tree
Hide file tree
Showing 17 changed files with 499 additions and 240 deletions.
1 change: 1 addition & 0 deletions manifest
Expand Up @@ -5078,6 +5078,7 @@ f usr/lib/brand/lx/lx_boot_zone_ubuntu 0755 root root
f usr/lib/brand/lx/lxinit 0755 root root
f usr/lib/brand/lx/lx_librtld_db.so.1 0755 root root
f usr/lib/brand/lx/lx_support 0755 root root
f usr/lib/brand/lx/lx_vdso.so.1 0755 root root
f usr/lib/brand/lx/platform.xml 0444 root root
d usr/lib/brand/shared 0755 root sys
f usr/lib/brand/shared/common.ksh 0444 root bin
Expand Down
11 changes: 3 additions & 8 deletions usr/src/common/brand/lx/lx_auxv.c
Expand Up @@ -37,14 +37,9 @@ lx_auxv_stol(const auxv_t *ap, auxv_t *oap, const lx_elf_data_t *edp)
oap->a_un.a_val = edp->ed_phnum;
break;
case AT_SUN_BRAND_LX_SYSINFO_EHDR:
if (edp->ed_vdso != 0) {
oap->a_type = AT_SYSINFO_EHDR;
oap->a_un.a_val = edp->ed_vdso;
return (0);
} else {
/* No vDSO for i386 */
return (1);
}
oap->a_type = AT_SYSINFO_EHDR;
oap->a_un.a_val = ap->a_un.a_val;
return (0);
case AT_SUN_BRAND_LX_CLKTCK:
oap->a_type = AT_CLKTCK;
oap->a_un.a_val = ap->a_un.a_val;
Expand Down
39 changes: 0 additions & 39 deletions usr/src/lib/brand/lx/lx_brand/common/lx_brand.c
Expand Up @@ -422,29 +422,6 @@ lx_close_fh(FILE *file)

extern int set_l10n_alternate_root(char *path);

#if defined(_LP64)
static void *
map_vdso()
{
int fd;
mmapobj_result_t mpp[10]; /* we know the size of our lib */
mmapobj_result_t *smpp = mpp;
uint_t mapnum = 10;

if ((fd = open("/native/usr/lib/brand/lx/amd64/lx_vdso.so.1",
O_RDONLY)) == -1)
lx_err_fatal("couldn't open lx_vdso.so.1");

if (mmapobj(fd, MMOBJ_INTERPRET, smpp, &mapnum, NULL) == -1)
lx_err_fatal("couldn't mmapobj lx_vdso.so.1");

(void) close(fd);

/* assume first segment is the base of the mapping */
return (smpp->mr_addr);
}
#endif

/*
* Initialize the thread specific data for this thread.
*/
Expand Down Expand Up @@ -592,12 +569,8 @@ lx_init(int argc, char *argv[], char *envp[])
lx_elf_data_t edp;
lx_brand_registration_t reg;
lx_tsd_t *lxtsd;
#if defined(_LP64)
void *vdso_hdr;
#endif

bzero(&reg, sizeof (reg));

stack_size = 2 * sysconf(_SC_PAGESIZE);

/*
Expand Down Expand Up @@ -686,18 +659,6 @@ lx_init(int argc, char *argv[], char *envp[])
if (lx_statfs_init() != 0)
lx_err_fatal("failed to setup the statfs translator");

#if defined(_LP64)
vdso_hdr = map_vdso();
edp.ed_vdso = (uintptr_t)vdso_hdr;
/*
* Notify the kernel of this mapping location to keep its
* representation of the auxv consistent with reality.
*/
(void) syscall(SYS_brand, B_NOTIFY_VDSO_LOC, (void *)vdso_hdr);
#else
edp.ed_vdso = 0;
#endif

/*
* Find the aux vector on the stack.
*/
Expand Down
8 changes: 3 additions & 5 deletions usr/src/lib/brand/lx/lx_vdso/Makefile
Expand Up @@ -10,17 +10,14 @@
#

#
# Copyright 2015 Joyent, Inc.
# Copyright 2016 Joyent, Inc.
#

include ../../../Makefile.lib

SUBDIRS = tools
SUBDIRS = tools $(MACH)
$(BUILD64)SUBDIRS += $(MACH64)

LINT_SUBDIRS =
$(BUILD64)LINT_SUBDIRS += $(MACH64)

all := TARGET= all
clean := TARGET= clean
clobber := TARGET= clobber
Expand All @@ -33,6 +30,7 @@ all install clean clobber: $(SUBDIRS)

lint: $(LINT_SUBDIRS)

$(MACH): tools
$(MACH64): tools

$(SUBDIRS): FRC
Expand Down
25 changes: 16 additions & 9 deletions usr/src/lib/brand/lx/lx_vdso/Makefile.com
Expand Up @@ -10,14 +10,16 @@
#

#
# Copyright 2015 Joyent, Inc.
# Copyright 2016 Joyent, Inc.
#

LIBRARY = lx_vdso.a
VERS = .1

COBJS = lx_vdso.o
OBJECTS = $(COBJS)
include $(SRC)/lib/commpage/Makefile.shared.com

COBJS = vdso_main.o vdso_subr.o
OBJECTS = $(COBJS) $(COMMPAGE_OBJS)

include ../../../../Makefile.lib
include ../../Makefile.lx
Expand All @@ -31,14 +33,15 @@ LIBNAME = lx_vdso
MAPFILES = ../common/mapfile-vers
MAPOPTS = $(MAPFILES:%=-M%)

ASOBJS = lx_vdso.o
OBJECTS = $(ASOBJS)

ASSRCS = $(ASOBJS:%o=$(ISASRCDIR)/%s)
SRCS = $(ASSRCS)
ASOBJS = vdso_subr.o
COBJS = vdso_main.o
OBJECTS = $(ASOBJS) $(COBJS) $(COMMPAGE_OBJS)

SRCDIR = ../common
UTSBASE = ../../../../../uts

ASSRCS = $(ASOBJS:%.o=$(ISASRCDIR)/%.s)
CSRCS = $(COBJS:%.o=$(SRCDIR)/%.c)
SRCS = $(ASSRCS) $(CSRCS)

LIBS = $(DYNLIB)
DYNFLAGS += $(DYNFLAGS_$(CLASS))
Expand Down Expand Up @@ -72,7 +75,11 @@ all: $(LIBS)
lint: $(LINTLIB) lintcheck

include ../../../../Makefile.targ
include $(SRC)/lib/commpage/Makefile.shared.targ

pics/%.o: $(ISASRCDIR)/%.s
$(COMPILE.s) -o $@ $<
$(POST_PROCESS_O)

pics/vdso_main.o := CPPFLAGS += $(COMMPAGE_CPPFLAGS)
pics/vdso_subr.o := ASFLAGS += -I$(SRC)/uts/common/brand/lx
7 changes: 6 additions & 1 deletion usr/src/lib/brand/lx/lx_vdso/amd64/Makefile
Expand Up @@ -10,14 +10,19 @@
#

#
# Copyright 2014 Joyent, Inc. All rights reserved.
# Copyright 2016 Joyent, Inc.
#

ISASRCDIR=.
TARGET_ARCH=$(MACH64)

include ../Makefile.com
include $(SRC)/lib/Makefile.lib.64

ASFLAGS += -D__$(MACH64)

SONAME = linux-vdso.so.1

#
# You might ask, why aren't we overriding BUILD.SO in Makefile.com.
# That's a sad story. The answer is that Makefile.lib.64 includes
Expand Down
132 changes: 0 additions & 132 deletions usr/src/lib/brand/lx/lx_vdso/amd64/lx_vdso.s

This file was deleted.

68 changes: 68 additions & 0 deletions usr/src/lib/brand/lx/lx_vdso/amd64/vdso_subr.s
@@ -0,0 +1,68 @@
/*
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*
*/

/*
* Copyright 2016 Joyent, Inc.
*/


#include <sys/asm_linkage.h>
#include <sys/lx_syscalls.h>


#if defined(lint)

comm_page_t *
__vdso_find_commpage()
{}

long
__vdso_sys_clock_gettime(uint_t clock_id, timespec_t *tp)
{}

int
__vdso_sys_gettimeofday(timespec_t *tp, struct lx_timezone *tz)
{}

time_t
__vdso_sys_time(timespec_t *tp)
{}

#else /* lint */

ENTRY_NP(__vdso_find_commpage)
leaq 0x0(%rip), %rax
andq $LX_VDSO_ADDR_MASK, %rax
addq $LX_VDSO_SIZE, %rax
ret
SET_SIZE(__vdso_find_commpage)

ENTRY_NP(__vdso_sys_clock_gettime)
movl $LX_SYS_clock_gettime, %eax
syscall
ret
SET_SIZE(__vdso_sys_clock_gettime)

ENTRY_NP(__vdso_sys_gettimeofday)
movl $LX_SYS_gettimeofday, %eax
syscall
ret
SET_SIZE(__vdso_sys_gettimeofday)

ENTRY_NP(__vdso_sys_time)
movl $LX_SYS_time, %eax
syscall
ret
SET_SIZE(__vdso_sys_time)

#endif /* lint */

0 comments on commit e6e2cd9

Please sign in to comment.