From patchwork Wed Aug 2 17:36:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 796726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-82621-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ZgUpl4G8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xN0jG5lvwz9sNV for ; Thu, 3 Aug 2017 03:36:18 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; q=dns; s=default; b=a9lRu+HAzupKIIC4 QNL4E1UAmJvW9upuCIBhX+9LKppax0BrZR8MBN40wQNVJg7FCK7z8pelqb0EMicI T50qOJKmZzfkRcNVKGLbJSDWeb64wA5tZcpriuJyrbuJ1ql+mAjqUDfPhtiYOE1X 06JMHk0Mclstnx5EmDI9V+QBAIo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; s=default; bh=mCNy7KxEzGM9UORtniw8Hc 9xVY8=; b=ZgUpl4G8gBxs7FIxaW+77csyy1qk4qKyLpv7mnYi8SA/hgfeR21wUU 5qWtERuDF7oSleiWNgK2m1sqGldZLoQrYiDHwVbYfHIT8DBTGhMJiGLyczwzKpOl 9NVv67TaeD/3NuvBHuE41VyNmYM9VZlTxF1O1vVbfgJxaC/gdo73Q= Received: (qmail 75940 invoked by alias); 2 Aug 2017 17:36:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 75916 invoked by uid 89); 2 Aug 2017 17:36:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2857 X-HELO: mga01.intel.com X-ExtLoop1: 1 Date: Wed, 2 Aug 2017 10:36:09 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] i386: Update I386_USE_SYSENTER for early PIC syscall Message-ID: <20170802173609.GA13699@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) Define I386_USE_SYSENTER to 0 or 1 so that special versions of syscalls with "int $0x80" can be provided for static PIE during self relocation. Also check PIC instead SHARED for PIC version of syscall macros. Any comments or objections? H.J. --- * sysdeps/unix/sysv/linux/i386/sysdep.h (I386_USE_SYSENTER): Define to I386_USE_SYSENTER to 0 or 1 if not defined. (ENTER_KERNEL): Check if I386_USE_SYSENTER is 1 and check PIC. (INTERNAL_SYSCALL_MAIN_INLINE): Likewise. (INTERNAL_SYSCALL_NCS): Likewise. (LOADARGS_1): Likewise. (LOADARGS_5): Likewise. (RESTOREARGS_1): Likewise. (RESTOREARGS_5): Likewise. --- sysdeps/unix/sysv/linux/i386/sysdep.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 449b23e49b..c455c9b1b4 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -34,11 +34,13 @@ #undef SYS_ify #define SYS_ify(syscall_name) __NR_##syscall_name -#if defined USE_DL_SYSINFO \ - && (IS_IN (libc) || IS_IN (libpthread)) -# define I386_USE_SYSENTER 1 -#else -# undef I386_USE_SYSENTER +#ifndef I386_USE_SYSENTER +# if defined USE_DL_SYSINFO \ + && (IS_IN (libc) || IS_IN (libpthread)) +# define I386_USE_SYSENTER 1 +# else +# define I386_USE_SYSENTER 0 +# endif #endif /* Since GCC 5 and above can properly spill %ebx with PIC when needed, @@ -110,8 +112,8 @@ /* The original calling convention for system calls on Linux/i386 is to use int $0x80. */ -#ifdef I386_USE_SYSENTER -# ifdef SHARED +#if I386_USE_SYSENTER +# ifdef PIC # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET # else # define ENTER_KERNEL call *_dl_sysinfo @@ -357,9 +359,9 @@ struct libc_do_syscall_args register unsigned int resultvar; \ INTERNAL_SYSCALL_MAIN_##nr (name, err, args); \ (int) resultvar; }) -#ifdef I386_USE_SYSENTER +#if I386_USE_SYSENTER # ifdef OPTIMIZE_FOR_GCC_5 -# ifdef SHARED +# ifdef PIC # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \ LOADREGS_##nr(args) \ asm volatile ( \ @@ -395,7 +397,7 @@ struct libc_do_syscall_args (int) resultvar; }) # endif # else /* GCC 5 */ -# ifdef SHARED +# ifdef PIC # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \ EXTRAVAR_##nr \ asm volatile ( \ @@ -494,7 +496,7 @@ struct libc_do_syscall_args #define LOADARGS_0 #ifdef __PIC__ -# if defined I386_USE_SYSENTER && defined SHARED +# if I386_USE_SYSENTER && defined PIC # define LOADARGS_1 \ "bpushl .L__X'%k3, %k3\n\t" # define LOADARGS_5 \ @@ -521,7 +523,7 @@ struct libc_do_syscall_args #define RESTOREARGS_0 #ifdef __PIC__ -# if defined I386_USE_SYSENTER && defined SHARED +# if I386_USE_SYSENTER && defined PIC # define RESTOREARGS_1 \ "bpopl .L__X'%k3, %k3\n\t" # define RESTOREARGS_5 \