diff --git a/Makefile b/Makefile index 4c823fa30..95964075e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,6 @@ # USE_LINUX_SPLICE : enable kernel 2.6 splicing. Automatic. # USE_LIBCRYPT : enable crypted passwords using -lcrypt # USE_CRYPT_H : set it if your system requires including crypt.h -# USE_VSYSCALL : enable vsyscall on Linux x86, bypassing libc # USE_GETADDRINFO : use getaddrinfo() to resolve IPv6 host names. # USE_OPENSSL : enable use of OpenSSL. Recommended, but see below. # USE_LUA : enable Lua support. @@ -289,7 +288,7 @@ use_opts = USE_EPOLL USE_KQUEUE USE_MY_EPOLL USE_MY_SPLICE USE_NETFILTER \ USE_PCRE USE_PCRE_JIT USE_PCRE2 USE_PCRE2_JIT USE_POLL \ USE_PRIVATE_CACHE USE_THREAD USE_PTHREAD_PSHARED USE_BACKTRACE \ USE_STATIC_PCRE USE_STATIC_PCRE2 USE_TPROXY USE_LINUX_TPROXY \ - USE_LINUX_SPLICE USE_LIBCRYPT USE_CRYPT_H USE_VSYSCALL \ + USE_LINUX_SPLICE USE_LIBCRYPT USE_CRYPT_H \ USE_GETADDRINFO USE_OPENSSL USE_LUA USE_FUTEX USE_ACCEPT4 \ USE_MY_ACCEPT4 USE_ZLIB USE_SLZ USE_CPU_AFFINITY USE_TFO USE_NS \ USE_DL USE_RT USE_DEVICEATLAS USE_51DEGREES USE_WURFL USE_SYSTEMD \ @@ -500,10 +499,6 @@ ifneq ($(USE_EVPORTS),) OPTIONS_OBJS += src/ev_evports.o endif -ifneq ($(USE_VSYSCALL),) -OPTIONS_OBJS += src/i386-linux-vsys.o -endif - ifneq ($(USE_DL),) OPTIONS_LDFLAGS += -ldl endif diff --git a/include/common/accept4.h b/include/common/accept4.h index 730421369..19e231dd5 100644 --- a/include/common/accept4.h +++ b/include/common/accept4.h @@ -42,10 +42,7 @@ #endif #if defined(USE_MY_ACCEPT4) || (!defined(SYS_ACCEPT4) && !defined(__NR_accept4)) -#if defined(USE_LINUX_VSYSCALL) && defined(__linux__) && defined(__i386__) -/* The syscall is redefined somewhere else */ -extern int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags); -#elif ACCEPT4_USE_SOCKETCALL +#if ACCEPT4_USE_SOCKETCALL static inline _syscall2(int, socketcall, int, call, unsigned long *, args); static int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) { @@ -59,7 +56,7 @@ static int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int fl } #else static inline _syscall4(int, accept4, int, sockfd, struct sockaddr *, addr, socklen_t *, addrlen, int, flags); -#endif /* VSYSCALL etc... */ +#endif /* ACCEPT4_USE_SOCKETCALL etc... */ #endif /* USE_MY_ACCEPT4 */ #endif /* __linux__ && USE_ACCEPT4 */ #endif /* _COMMON_ACCEPT4_H */ diff --git a/include/common/epoll.h b/include/common/epoll.h index f45aa4fa9..8601b851b 100644 --- a/include/common/epoll.h +++ b/include/common/epoll.h @@ -70,13 +70,6 @@ struct epoll_event { } data; }; -#if defined(USE_LINUX_VSYSCALL) && defined(__linux__) && defined(__i386__) -/* Those are our self-defined functions */ -extern int epoll_create(int size); -extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event * event); -extern int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout); -#else - /* We'll define a syscall, so for this we need __NR_splice. It should have * been provided by syscall.h. */ @@ -90,7 +83,6 @@ extern int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int static inline _syscall1 (int, epoll_create, int, size); static inline _syscall4 (int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event); static inline _syscall4 (int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout); -#endif /* VSYSCALL */ #endif /* USE_MY_EPOLL */ diff --git a/include/common/splice.h b/include/common/splice.h index 760b6ba0d..cd32effb8 100644 --- a/include/common/splice.h +++ b/include/common/splice.h @@ -49,11 +49,6 @@ #if defined(USE_MY_SPLICE) -#if defined(USE_LINUX_VSYSCALL) && defined(__linux__) && defined(__i386__) -/* The syscall is redefined somewhere else */ -extern int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, size_t len, unsigned long flags); -#else - /* We'll define a syscall, so for this we need __NR_splice. It should have * been provided by syscall.h. */ @@ -63,7 +58,6 @@ extern int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, size_t l #endif /* __NR_splice */ static inline _syscall6(int, splice, int, fdin, loff_t *, off_in, int, fdout, loff_t *, off_out, size_t, len, unsigned long, flags); -#endif /* VSYSCALL */ #else /* use the system's definition */ diff --git a/src/i386-linux-vsys.c b/src/i386-linux-vsys.c deleted file mode 100644 index 9d3033461..000000000 --- a/src/i386-linux-vsys.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Fast system call support for x86 on Linux - * - * Copyright 2010 Willy Tarreau - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Recent kernels support a faster syscall ABI on x86 using the VDSO page, but - * some libc that are built for CPUs earlier than i686 do not implement it. - * This code bypasses the libc when the VDSO is detected. It should only be - * used when it's sure that the libc really does not support the VDSO, but - * fixing the libc is preferred. Using the VDSO can improve the overall - * performance by about 10%. - */ - -#if defined(__linux__) && defined(__i386__) -/* Silently ignore other platforms to be friendly with distro packagers */ - -#include -#include - -void int80(void); /* declared in the assembler code */ -static void *vsyscall = &int80; /* initialize vsyscall to use int80 by default */ -static __attribute__((used)) unsigned int back_ebx; - -/* now we redefine some frequently used syscalls. Epoll_create is defined too - * in order to replace old disabled implementations. - */ -asm -( - "epoll_create: .GLOBL epoll_create\n" - " mov $0xfe, %eax\n" - " mov %ebx, back_ebx\n" - " mov 4(%esp), %ebx\n" - " jmp do_syscall\n" - - "epoll_ctl: .GLOBL epoll_ctl\n" - " push %esi\n" - " mov $0xff, %eax\n" - " mov %ebx, back_ebx\n" - " mov 20(%esp), %esi\n" - " mov 16(%esp), %edx\n" - " mov 12(%esp), %ecx\n" - " mov 8(%esp), %ebx\n" - " call do_syscall\n" - " pop %esi\n" - " ret\n" - - "epoll_wait: .GLOBL epoll_wait\n" - " push %esi\n" - " mov $0x100, %eax\n" - " mov %ebx, back_ebx\n" - " mov 20(%esp), %esi\n" - " mov 16(%esp), %edx\n" - " mov 12(%esp), %ecx\n" - " mov 8(%esp), %ebx\n" - " call do_syscall\n" - " pop %esi\n" - " ret\n" - - "splice: .GLOBL splice\n" - " push %ebp\n" - " push %edi\n" - " push %esi\n" - " mov $0x139, %eax\n" - " mov %ebx, back_ebx\n" - " mov 36(%esp), %ebp\n" - " mov 32(%esp), %edi\n" - " mov 28(%esp), %esi\n" - " mov 24(%esp), %edx\n" - " mov 20(%esp), %ecx\n" - " mov 16(%esp), %ebx\n" - " call do_syscall\n" - " pop %esi\n" - " pop %edi\n" - " pop %ebp\n" - " ret\n" - - "close: .GLOBL close\n" - " mov $0x06, %eax\n" - " mov %ebx, back_ebx\n" - " mov 4(%esp), %ebx\n" - " jmp do_syscall\n" - - "gettimeofday: .GLOBL gettimeofday\n" - " mov $0x4e, %eax\n" - " mov %ebx, back_ebx\n" - " mov 8(%esp), %ecx\n" - " mov 4(%esp), %ebx\n" - " jmp do_syscall\n" - - "fcntl: .GLOBL fcntl\n" - " mov $0xdd, %eax\n" - " mov %ebx, back_ebx\n" - " mov 12(%esp), %edx\n" - " mov 8(%esp), %ecx\n" - " mov 4(%esp), %ebx\n" - " jmp do_syscall\n" - - "socket: .GLOBL socket\n" - " mov $0x01, %eax\n" - " jmp socketcall\n" - - "bind: .GLOBL bind\n" - " mov $0x02, %eax\n" - " jmp socketcall\n" - - "connect: .GLOBL connect\n" - " mov $0x03, %eax\n" - " jmp socketcall\n" - - "listen: .GLOBL listen\n" - " mov $0x04, %eax\n" - " jmp socketcall\n" - - "accept: .GLOBL accept\n" - " mov $0x05, %eax\n" - " jmp socketcall\n" - - "accept4: .GLOBL accept4\n" - " mov $0x12, %eax\n" - " jmp socketcall\n" - - "getsockname: .GLOBL getsockname\n" - " mov $0x06, %eax\n" - " jmp socketcall\n" - - "send: .GLOBL send\n" - " mov $0x09, %eax\n" - " jmp socketcall\n" - - "recv: .GLOBL recv\n" - " mov $0x0a, %eax\n" - " jmp socketcall\n" - - "shutdown: .GLOBL shutdown\n" - " mov $0x0d, %eax\n" - " jmp socketcall\n" - - "setsockopt: .GLOBL setsockopt\n" - " mov $0x0e, %eax\n" - " jmp socketcall\n" - - "getsockopt: .GLOBL getsockopt\n" - " mov $0x0f, %eax\n" - " jmp socketcall\n" - - "socketcall:\n" - " mov %ebx, back_ebx\n" - " mov %eax, %ebx\n" - " mov $0x66, %eax\n" - " lea 4(%esp), %ecx\n" - /* fall through */ - - "do_syscall:\n" - " call *vsyscall\n" // always valid, may be int80 or vsyscall - " mov back_ebx, %ebx\n" - " cmpl $0xfffff000, %eax\n" // consider -4096..-1 for errno - " jae 0f\n" - " ret\n" - "0:\n" // error handling - " neg %eax\n" // get errno value - " push %eax\n" // save it - " call __errno_location\n" - " popl (%eax)\n" // store the pushed errno into the proper location - " mov $-1, %eax\n" // and return -1 - " ret\n" - - "int80:\n" // default compatible calling convention - " int $0x80\n" - " ret\n" -); - -__attribute__((constructor)) -static void __i386_linux_vsyscall_init(void) -{ - /* We can get the pointer by resolving the __kernel_vsyscall symbol - * from the "linux-gate.so.1" virtual shared object, but this requires - * libdl. Or we can also know that the vsyscall pointer is always - * located at 0xFFFFE018 when /proc/sys/abi/vsyscall32 contains the - * default value 2. So we can use that once we've checked that we can - * access it without faulting. The dlsym method will also work when - * vsyscall32 = 1, which randomizes the VDSO address. - */ -#ifdef USE_VSYSCALL_DLSYM - void *handle = dlopen("linux-gate.so.1", RTLD_NOW); - if (handle) { - void *ptr; - - ptr = dlsym(handle, "__kernel_vsyscall_kml"); - if (!ptr) - ptr = dlsym(handle, "__kernel_vsyscall"); - if (ptr) - vsyscall = ptr; - dlclose(handle); - } -#else - /* Heuristic: trying to mprotect() the VDSO area will only succeed if - * it is mapped. - */ - if (mprotect((void *)0xffffe000, 4096, PROT_READ|PROT_EXEC) == 0) { - unsigned long ptr = *(unsigned long *)0xFFFFE018; /* VDSO is mapped */ - if ((ptr & 0xFFFFE000) == 0xFFFFE000) - vsyscall = (void *)ptr; - } -#endif -} - -#endif /* defined(__linux__) && defined(__i386__) */