From patchwork Wed Sep 11 21:04:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 34509 Received: (qmail 96093 invoked by alias); 11 Sep 2019 21:05:23 -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 95935 invoked by uid 89); 11 Sep 2019 21:05:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=cet, H*r:sk:mail-pf X-HELO: mail-pf1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=O+yIotQ42Ra4NKGYXBcYELer1gdy9/NUqb72jC5x3mc=; b=c+Ed04thsMPXFv9ydUmVgd9dFbFp5CmROu3oUiESiymvEfbIm4JVVdlqiYpVuVIWPW k3q0TuNSyWM8GGciKJ2e7N2lvoScBpXpvVCHCAFgCKbwfvfxf0on9DL9A63QYGfSn/VB LyAAmJMY1CjcOU/xGb7RJNAsE+gntZJZpS6gWv5qG22LftYhBGyuLPK6dAfgAW4TZLtr NmEuQ/CshJi6CmmoTCvq/Hc7m5VsuiBr3O702ZWGLYvc+IBYlq/RmBUfAOxo25CD1ct1 DJT9VUPCnGSgUr3lytjojelCGgNEAvcWzboCbUZCPjpNXHmFpKbO6kLndt4tAhkEPTO+ cPHQ== Return-Path: From: Isaku Yamahata To: libc-alpha@sourceware.org Cc: isaku.yamahata@intel.com, Isaku Yamahata Subject: [RFC PATCH 10/11] x86-64: make the number of nops after syscall configurable Date: Wed, 11 Sep 2019 14:04:08 -0700 Message-Id: In-Reply-To: References: In-Reply-To: References: This is tentative patch for convenience. This patch make it configurable how many nops are inserted after syscall instruction. Once the consensus on the number of nops is made, this patch can be removed. Signed-off-by: Isaku Yamahata --- configure.ac | 19 +++++++++++++++++++ sysdeps/unix/sysv/linux/x86_64/sysdep.h | 15 ++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index aa902787f0..150570dd54 100644 --- a/configure.ac +++ b/configure.ac @@ -480,6 +480,25 @@ AC_ARG_ENABLE([cet], [enable_cet=$enableval], [enable_cet=no]) +AC_ARG_ENABLE([libos-num-nops], + AC_HELP_STRING([--enable-libos-num-nops=NUM-NOPS], + [specify the number of nops for syscall, x86-64 only + only mealingful when libos support enabled.]), + [libos_num_nops=$enableval], + [libos_num_nops='']) +if test -n "$libos_num_nops"; then + case "$libos_num_nops" in + *[!0-9]*) + AC_MSG_ERROR([--enable-libos-num-nops requires a number]) + ;; + *) + ;; + esac + AC_DEFINE_UNQUOTED(ENALBE_LIBOS_NUM_NOPS, $libos_num_nops, [libos num nops]) + libos_nops=$(printf 'nops;%.0s' $(seq $libos_num_nops)) + AC_DEFINE_UNQUOTED(ENALBE_LIBOS_NOPS, "$libos_nops", [libos nops]) +fi + # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses # $machine, $vendor, and $os, and changes them whenever convenient. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index d958c1ca7a..8da5e4e154 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -26,11 +26,17 @@ /* Defines RTLD_PRIVATE_ERRNO. */ #include -#ifdef __ASSEMBLER__ +#ifdef ENABLE_LIBOS_NOPS +# define NOP_REPEAT ENABLE_LIBOS_NOPS +#else +# define NOP_REPEAT nop;nop;nop;nop;nop;nop;nop;nop;nop;nop +#endif + +# ifdef __ASSEMBLER__ .macro SYSCALL_INST 551: syscall - nop;nop;nop;nop;nop;nop;nop;nop;nop;nop + NOP_REPEAT 552: .pushsection .libos.instructions.syscall, "a" .balign 8 @@ -39,10 +45,13 @@ .popsection .endm #else +#define STRINGIFY(name) STRINGIFY_1(name) +#define STRINGIFY_1(name) #name #define SYSCALL_INST \ "551:\n\t" \ "syscall\n\t" \ - "nop;nop;nop;nop;nop;nop;nop;nop;nop;nop\n\t" \ + STRINGIFY(NOP_REPEAT) \ + "\n\t" \ "552:\n\t" \ ".pushsection .libos.instructions.syscall, \"a\"\n\t" \ ".balign 8\n\t" \