From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id D5A8D3858C50 for ; Mon, 2 May 2022 19:24:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5A8D3858C50 Received: by mail-pg1-x52b.google.com with SMTP id k14so12421336pga.0 for ; Mon, 02 May 2022 12:24:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nqbT3hYVDdILBYbRTBgOGcuhAYYWXNWBbEXFOfz3JNY=; b=5I77LPDE/SyKAakEfg7ts5XeJk9HxuksCgLRnTC7weti8xRBNGEpBlZQNNgtaT3fai 19mWqWq3505myBpjhGqFSMxX7j0spEDHYUM89w1p8hMyZ8tKqNGd07Vq6DtfXlXQ4+Q6 d4k2c9p1v/MfrjqJ1xB2UlCOfOZ3CxFUneDe34CjL5SWAcP4B24ii+NfiC503tIbnaRz UGLvyxF+0h0sQ6Wkf4cGaqJUYng7dPGZIDWdNJrb7zjjX7m9PZUz+YhgFilLwzmcIAnW 1XS4jsmYx27Do2ahPFMev4E2ah0oqNNFXB6+33xivzUON05DzsnZBHPeWfKoZKypF5hq CwNg== X-Gm-Message-State: AOAM5300aPNgK5RlK+em6rivsHv5ympgFep2M1qnxvqfWn9/E12E5jgM 1lhz9XCGSyQTEZtTNvOWJ7vzEnQoO16wB6/pSuIcg+ilhBo= X-Google-Smtp-Source: ABdhPJwh8kJtx6p1wSCHnaLS85SmE+QBRlhrSjo5vUo8J/yVC1IC/3jS9PJVljXi9P5+ECTtyij9vecnyuvawNRBrIs= X-Received: by 2002:a63:af06:0:b0:378:3582:a49f with SMTP id w6-20020a63af06000000b003783582a49fmr10915851pge.125.1651519482901; Mon, 02 May 2022 12:24:42 -0700 (PDT) MIME-Version: 1.0 References: <621524cdf4abec91c12f4c6a88f9807078c0814b.1651518694.git.fweimer@redhat.com> In-Reply-To: <621524cdf4abec91c12f4c6a88f9807078c0814b.1651518694.git.fweimer@redhat.com> From: "H.J. Lu" Date: Mon, 2 May 2022 12:24:07 -0700 Message-ID: Subject: Re: [PATCH 4/5] i386: Honor I386_USE_SYSENTER for 6-argument Linux system calls To: Florian Weimer Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3025.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2022 19:24:45 -0000 On Mon, May 2, 2022 at 12:18 PM Florian Weimer via Libc-alpha wrote: > > Introduce an int-80h-based version of __libc_do_syscall and use > it if I386_USE_SYSENTER is defined as 0. > --- > sysdeps/unix/sysv/linux/i386/Makefile | 2 +- > .../sysv/linux/i386/libc-do-syscall-int80.S | 25 +++++++++++++++++++ > sysdeps/unix/sysv/linux/i386/sysdep.h | 13 ++++++++-- > 3 files changed, 37 insertions(+), 3 deletions(-) > create mode 100644 sysdeps/unix/sysv/linux/i386/libc-do-syscall-int80.S > > diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile > index fcab129fc1..598e27dcda 100644 > --- a/sysdeps/unix/sysv/linux/i386/Makefile > +++ b/sysdeps/unix/sysv/linux/i386/Makefile > @@ -13,7 +13,7 @@ install-bin += lddlibc4 > endif > > ifeq ($(subdir),io) > -sysdep_routines += libc-do-syscall > +sysdep_routines += libc-do-syscall libc-do-syscall-int80 > endif > > ifeq ($(subdir),stdlib) > diff --git a/sysdeps/unix/sysv/linux/i386/libc-do-syscall-int80.S b/sysdeps/unix/sysv/linux/i386/libc-do-syscall-int80.S > new file mode 100644 > index 0000000000..2c472f2557 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/i386/libc-do-syscall-int80.S > @@ -0,0 +1,25 @@ > +/* Out-of-line syscall stub for six-argument syscalls from C. For static PIE. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef SHARED > +# define I386_USE_SYSENTER 0 > +# include > + > +# define __libc_do_syscall __libc_do_syscall_int80 > +# include "libc-do-syscall.S" > +#endif > diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h > index 4558ab66cb..7085f7e19a 100644 > --- a/sysdeps/unix/sysv/linux/i386/sysdep.h > +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h > @@ -42,6 +42,15 @@ > # endif > #endif > > +#if !I386_USE_SYSENTER && IS_IN (libc) && !defined SHARED > +/* Inside static libc, we have two versions. For compilation units > + with !I386_USE_SYSENTER, the vDSO entry mechanism cannot be > + used. */ > +# define I386_DO_SYSCALL_STRING "__libc_do_syscall_int80" > +#else > +# define I386_DO_SYSCALL_STRING "__libc_do_syscall" > +#endif > + > #ifdef __ASSEMBLER__ > > /* Linux uses a negative return value to indicate syscall errors, > @@ -301,7 +310,7 @@ struct libc_do_syscall_args > }; \ > asm volatile ( \ > "movl %1, %%eax\n\t" \ > - "call __libc_do_syscall" \ > + "call " I386_DO_SYSCALL_STRING \ > : "=a" (resultvar) \ > : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \ > : "memory", "cc") > @@ -315,7 +324,7 @@ struct libc_do_syscall_args > }; \ > asm volatile ( \ > "movl %1, %%eax\n\t" \ > - "call __libc_do_syscall" \ > + "call " I386_DO_SYSCALL_STRING \ > : "=a" (resultvar) \ > : "a" (name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \ > : "memory", "cc") > -- > 2.35.1 > > LGTM. Reviewed-by: H.J. Lu Thanks. -- H.J.