From patchwork Tue Jul 23 00:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1963499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=XwDA6aBs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WSdmN10Yfz1yYm for ; Tue, 23 Jul 2024 10:48:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0BE53860750 for ; Tue, 23 Jul 2024 00:48:01 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id B10CE385F025 for ; Tue, 23 Jul 2024 00:47:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B10CE385F025 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B10CE385F025 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::72d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721695652; cv=none; b=blk6mWPFpumKd+5VL9Ag79+MCRZ/NJ7Zk24hpCGwVEgloSFNPcHDGpSecWrxrrbk/91Dm46Wf36cGxLjYUsUZoRBmQLSWsHkcQF4MpwO1eJo+jA4QdXKPHDAEFA97up5exVgSMtnMGMAIoMsCxl6z3M75KEDU6qisETAD+18xOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721695652; c=relaxed/simple; bh=SI1DSG/RnkODVMd09/es6tMchONOYq8CpO/6zUmXA8E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Onl5JrOK1i6xe75OZ5mye7bZIGq9uibSlvy418Tfb3NLwQY1/V6/drqtjo8oP6FGiXd5u+jg9P5CaaTDm8Yo8PJw3Ww3lrLlSfmr9lvA+nYFG3/aV7WjKPJRkINbgLV3HLCWJXKptjFUwL6MokV72Nm1mw04W9B1gCYGomgMTPA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-79f18509e76so281854885a.1 for ; Mon, 22 Jul 2024 17:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721695649; x=1722300449; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kVjCG0MN955H8UkoWaD8H1yG+o5cQIuvGbZ4KX3AG5Q=; b=XwDA6aBsWinQffhYFqFHY2lINH1PI5ECGvIXFj2RKiP6UW/hOhorinvLdPzn/bMiMR HJv1PVlLm9MSv3koK67htqG5ogBxyDoPW4AOXgah2ZsBUeh02xR4M8xO5Vgq+2onWdvc VItR/3Dd8b8N5hDQZZlgFjduKCRsAfePl+9k79B49GHGYBqtAbJavVtfSt53wfpYCpts IfARmYM98Tqu1cxp48pSPOHgFIkQSpwzE8LJ5qA1wYCeCENC54E9j54VXNK5h20gCIGw 2T/QBJQBE6hpYY2x29R2GnYW4fDTjDd/HwCLSRVaK6EJhZdTkTTUkc/Hw9KfiCawrQPz 1ndQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721695649; x=1722300449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kVjCG0MN955H8UkoWaD8H1yG+o5cQIuvGbZ4KX3AG5Q=; b=DpWmv2qtgUyS99oRNaQ8PlzaiVztEQm46xjqIGlO5W6qJ7ciLrSNFf/h9b5EIykA9g J+te6Fmkcz8ZjFOJb91gQ+YtjSVe+egIfHWjsGP3bbRmIPFGgAxdn8BliOblJ/s4T0PK RoQEQJSG2SAv7hB6UW0WrqBfutPY4SnYKC6Aao320G7Ta0TVsxqW4Pq+G/cPV+i3scCN WvNi9mKQ9yWLAS9zx/0hflCNUFeObXvtwAHxxq8PmPn6v85ufwGue9zyhOvGO5vgDnCH s+TZX39fV6ss/X8uY5Y9lHZwRGPJA9/Cm+U6q4jToKOHBxe5SSfRYrd4zd2VZEwZB3OC 8ZFQ== X-Gm-Message-State: AOJu0YyPeNd3GxGAkBLXuxVGY7hNm2l6iY2fFa6yD+lmRoaUIUZQbT3p q0fB80vSTHnaXLESdQvLAZde8vQGZQC2kFm99ixaC5JfVwlyqjFHsgUOqCDKq5WRJg== X-Google-Smtp-Source: AGHT+IH3XLxgKmGjx1fmmkoNyCKILcMVChUf6cSA6NHTnB8FDvSRGeOVVqSAppiuB68BH/hOOR32rQ== X-Received: by 2002:a05:620a:450e:b0:79d:536f:7b3a with SMTP id af79cd13be357-7a1a666a557mr1194160985a.56.1721695648710; Mon, 22 Jul 2024 17:47:28 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.58.142.192]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a198fab08esm419415985a.23.2024.07.22.17.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 17:47:28 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 095C9C01A5; Mon, 22 Jul 2024 17:47:23 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com Subject: [PATCH v3 1/2] x86-64: Remove sysdeps/x86_64/x32/dl-machine.h Date: Mon, 22 Jul 2024 17:47:21 -0700 Message-ID: <20240723004722.2337170-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723004722.2337170-1-hjl.tools@gmail.com> References: <20240723004722.2337170-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3021.0 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Remove sysdeps/x86_64/x32/dl-machine.h by folding x32 ARCH_LA_PLTENTER, ARCH_LA_PLTEXIT and RTLD_START into sysdeps/x86_64/dl-machine.h. There are no regressions on x86-64 nor x32. There are no changes in x86-64 _dl_start_user. On x32, _dl_start_user changes are <_dl_start_user>: mov %eax,%r12d + mov %esp,%r13d mov (%rsp),%edx mov %edx,%esi - mov %esp,%r13d and $0xfffffff0,%esp mov 0x0(%rip),%edi # <_dl_start_user+0x14> lea 0x8(%r13,%rdx,4),%ecx Signed-off-by: H.J. Lu Reviewed-by: Noah Goldstein --- sysdeps/x86_64/dl-machine.h | 27 +++++++----- sysdeps/x86_64/x32/dl-machine.h | 76 --------------------------------- 2 files changed, 16 insertions(+), 87 deletions(-) delete mode 100644 sysdeps/x86_64/x32/dl-machine.h diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index a6de3793e4..4f12955875 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -139,37 +139,37 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], .globl _start\n\ .globl _dl_start_user\n\ _start:\n\ - movq %rsp, %rdi\n\ + mov %" RSP_LP ", %" RDI_LP "\n\ call _dl_start\n\ _dl_start_user:\n\ # Save the user entry point address in %r12.\n\ - movq %rax, %r12\n\ + mov %" RAX_LP ", %" R12_LP "\n\ # Save %rsp value in %r13.\n\ - movq %rsp, %r13\n\ + mov %" RSP_LP ", % " R13_LP "\n\ "\ RTLD_START_ENABLE_X86_FEATURES \ "\ # Read the original argument count.\n\ - movq (%rsp), %rdx\n\ + mov (%rsp), %" RDX_LP "\n\ # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ # argc -> rsi\n\ - movq %rdx, %rsi\n\ + mov %" RDX_LP ", %" RSI_LP "\n\ # And align stack for the _dl_init call. \n\ - andq $-16, %rsp\n\ + and $-16, %" RSP_LP "\n\ # _dl_loaded -> rdi\n\ - movq _rtld_local(%rip), %rdi\n\ + mov _rtld_local(%rip), %" RDI_LP "\n\ # env -> rcx\n\ - leaq 16(%r13,%rdx,8), %rcx\n\ + lea 2*" LP_SIZE "(%r13,%rdx," LP_SIZE "), %" RCX_LP "\n\ # argv -> rdx\n\ - leaq 8(%r13), %rdx\n\ + lea " LP_SIZE "(%r13), %" RDX_LP "\n\ # Clear %rbp to mark outermost frame obviously even for constructors.\n\ xorl %ebp, %ebp\n\ # Call the function to run the initializers.\n\ call _dl_init\n\ # Pass our finalizer function to the user in %rdx, as per ELF ABI.\n\ - leaq _dl_fini(%rip), %rdx\n\ + lea _dl_fini(%rip), %" RDX_LP "\n\ # And make sure %rsp points to argc stored on the stack.\n\ - movq %r13, %rsp\n\ + mov %" R13_LP ", %" RSP_LP "\n\ # Jump to the user's entry point.\n\ jmp *%r12\n\ .previous\n\ @@ -234,8 +234,13 @@ elf_machine_plt_value (struct link_map *map, const ElfW(Rela) *reloc, /* Names of the architecture-specific auditing callback functions. */ +#ifdef __LP64__ #define ARCH_LA_PLTENTER x86_64_gnu_pltenter #define ARCH_LA_PLTEXIT x86_64_gnu_pltexit +#else +#define ARCH_LA_PLTENTER x32_gnu_pltenter +#define ARCH_LA_PLTEXIT x32_gnu_pltexit +#endif #endif /* !dl_machine_h */ diff --git a/sysdeps/x86_64/x32/dl-machine.h b/sysdeps/x86_64/x32/dl-machine.h deleted file mode 100644 index c35cee9261..0000000000 --- a/sysdeps/x86_64/x32/dl-machine.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Machine-dependent ELF dynamic relocation inline functions. x32 version. - Copyright (C) 2012-2024 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 - . */ - -/* Must allow to be included more than once. - See #ifdef RESOLVE_MAP in sysdeps/x86_64/dl-machine.h. */ -#include - -#ifndef _X32_DL_MACHINE_H -#define _X32_DL_MACHINE_H - -#undef ARCH_LA_PLTENTER -#undef ARCH_LA_PLTEXIT -#undef RTLD_START - -/* Names of the architecture-specific auditing callback functions. */ -#define ARCH_LA_PLTENTER x32_gnu_pltenter -#define ARCH_LA_PLTEXIT x32_gnu_pltexit - -/* Initial entry point code for the dynamic linker. - The C function `_dl_start' is the real entry point; - its return value is the user program's entry point. */ -#define RTLD_START asm ("\n\ -.text\n\ - .p2align 4\n\ -.globl _start\n\ -.globl _dl_start_user\n\ -_start:\n\ - movl %esp, %edi\n\ - call _dl_start\n\ -_dl_start_user:\n\ - # Save the user entry point address in %r12.\n\ - movl %eax, %r12d\n\ - # Read the original argument count.\n\ - movl (%rsp), %edx\n\ - # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ - # argc -> rsi\n\ - movl %edx, %esi\n\ - # Save %rsp value in %r13.\n\ - movl %esp, %r13d\n\ - # And align stack for the _dl_init call.\n\ - and $-16, %esp\n\ - # _dl_loaded -> rdi\n\ - movl _rtld_local(%rip), %edi\n\ - # env -> rcx\n\ - lea 8(%r13,%rdx,4), %ecx\n\ - # argv -> rdx\n\ - lea 4(%r13), %edx\n\ - # Clear %rbp to mark outermost frame obviously even for constructors.\n\ - xorl %ebp, %ebp\n\ - # Call the function to run the initializers.\n\ - call _dl_init\n\ - # Pass our finalizer function to the user in %rdx, as per ELF ABI.\n\ - lea _dl_fini(%rip), %edx\n\ - # And make sure %rsp points to argc stored on the stack.\n\ - movl %r13d, %esp\n\ - # Jump to the user's entry point.\n\ - jmp *%r12\n\ -.previous\n\ -"); - -#endif /* !_X32_DL_MACHINE_H */ From patchwork Tue Jul 23 00:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1963500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Hs5OFoRG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WSdmk2MLmz1yYm for ; Tue, 23 Jul 2024 10:48:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77ABE386103E for ; Tue, 23 Jul 2024 00:48:20 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by sourceware.org (Postfix) with ESMTPS id 604953860776 for ; Tue, 23 Jul 2024 00:47:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 604953860776 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 604953860776 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::f29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721695651; cv=none; b=U+q4fIRge4DtQXS3L4eZHqNAYOnW/TFQsPUiUuwifdMgfwi/1OgmQQIJt0fsicqNOr8gFsbfs+cmxRAMhjrKnjByp29N3IYSbIbrS+B4zxEBESRv/4o8YgQqdepwqzhQ06tVai+r2xVUcjhefkwXppDZU8hXL8Ea272BYVI/FtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721695651; c=relaxed/simple; bh=Ce30f58KNSkjwxFxMrkUEwDCu6FmbE1WR9+ORAKsvo8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NNNMPHb9GPaopkexUtrbf1HzihZI5zCeOwJeSubAqeOcw6SMlwHxjz4/Cm/DtV9aPvM0jzx0sVTMjAdnqxY1uvlebSTewXpobFIf6IwlExzqj1DiYyqfy7aba0SfpVw6myhcSyyAx7CHM02lYCE4eQY9kSPzAa6UiclK/eQlfRY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-6b797fb1c4aso38501326d6.2 for ; Mon, 22 Jul 2024 17:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721695648; x=1722300448; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CM/I9rjzdvPVk8LARLU+XCnVXbpKkFfboyDfD+w8mB0=; b=Hs5OFoRGfIKwIF1DgUchoRrkNkATQz9DlyjjmDeNam7ZwldxYvbe61Qn8GcNe5a2Yh d9n0XQdiEdSKwaUCr4l4ZQBgAeQO/7LQATK9TPxgmNLWGuB4l1Gc3cOugSIpRXO9DCji CcDYIOPgoI7cLaUkhqWGHVA0yjEqCdLSXSH+ztsT+9fIdKnQ5CrG196VRzGUx8tAEW2N akx0zM8u9n25ONjtCWPYv84/2u1okkgABJCadBgvELTXtjYmnX2u0VsoTSwmqR9tnqs7 Itxc33y9W+r3yFEzo6jvd2hBMMpPajQKyAFdbgu9QLNIFmPnY1puU8xwNrQHKBNyhSgN KEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721695648; x=1722300448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CM/I9rjzdvPVk8LARLU+XCnVXbpKkFfboyDfD+w8mB0=; b=KqRWIe5RQ1HfDrTXc7MievdQFYAB0TRG8mmUpYCabWyfvYMvWE63YxyuqOVsCR5lJx 1CDGb0oQa0WdBzOwjFnG5BgxHI1At5lBG6fgx+CE1vZXVPw/PZZgM0QE8JTZfypjAQiu f3E8ymRJhZX0PhUIzN+w2ObB5S88XEj17WRt7OcePRVDsXt4kTUcY9fx8pA0mfsGialZ CSt9pj4qYoOEansnv0U+4xFCUpKwtIJepkv0NY4oJGywrjPkgiyo/l6CcG/QkMLAzihG J8OYTjWH2ejD4fszXw/ghwvIoYX6AwFx9E/FjPhvg6yITVgSSjkBywigpBbNLIeZE+xx BLdw== X-Gm-Message-State: AOJu0Yy/0NHB0/7xFDoWcLdm/dKBy9vl1bJH0Mh4/qXgtDSBd6KGpJk8 eYrg6gZjaI4FECgm6vMvDvnesIuDjQlhhBb+lemTZRw/lck+b5vg X-Google-Smtp-Source: AGHT+IG+k5Z1nSQk5ptf77tSNVNb6NMLyyBEghlTkxm6ptfnOSY3bUu0DdG+bOK13Ktl6O4qEd9HrQ== X-Received: by 2002:a05:6214:c46:b0:6b2:b4d2:984d with SMTP id 6a1803df08f44-6b94f0124a9mr118481756d6.15.1721695648398; Mon, 22 Jul 2024 17:47:28 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.58.142.192]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b7ac7bd5d6sm40736506d6.22.2024.07.22.17.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 17:47:27 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 1415AC01C2; Mon, 22 Jul 2024 17:47:23 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com Subject: [PATCH v3 2/2] x32/cet: Support shadow stack during startup for Linux 6.10 Date: Mon, 22 Jul 2024 17:47:22 -0700 Message-ID: <20240723004722.2337170-3-hjl.tools@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723004722.2337170-1-hjl.tools@gmail.com> References: <20240723004722.2337170-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3020.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Use RXX_LP in RTLD_START_ENABLE_X86_FEATURES. Support shadow stack during startup for Linux 6.10: commit 2883f01ec37dd8668e7222dfdb5980c86fdfe277 Author: H.J. Lu Date: Fri Mar 15 07:04:33 2024 -0700 x86/shstk: Enable shadow stacks for x32 1. Add shadow stack support to x32 signal. 2. Use the 64-bit map_shadow_stack syscall for x32. 3. Set up shadow stack for x32. Add the map_shadow_stack system call to and regenerate arch-syscall.h. Tested on Intel Tiger Lake with CET enabled x32. There are no regressions with CET enabled x86-64. There are no changes in CET enabled x86-64 _dl_start_user. Signed-off-by: H.J. Lu Reviewed-by: Noah Goldstein --- sysdeps/unix/sysv/linux/x86_64/dl-cet.h | 6 +++--- sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h | 1 + sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/x86_64/dl-cet.h b/sysdeps/unix/sysv/linux/x86_64/dl-cet.h index 1fe3133406..b4f7e6c9cd 100644 --- a/sysdeps/unix/sysv/linux/x86_64/dl-cet.h +++ b/sysdeps/unix/sysv/linux/x86_64/dl-cet.h @@ -92,9 +92,9 @@ dl_cet_ibt_enabled (void) # Pass GL(dl_x86_feature_1) to _dl_cet_setup_features.\n\ movl %edx, %edi\n\ # Align stack for the _dl_cet_setup_features call.\n\ - andq $-16, %rsp\n\ + and $-16, %" RSP_LP "\n\ call _dl_cet_setup_features\n\ # Restore %rax and %rsp from %r12 and %r13.\n\ - movq %r12, %rax\n\ - movq %r13, %rsp\n\ + mov %" R12_LP ", %" RAX_LP "\n\ + mov %" R13_LP ", %" RSP_LP "\n\ " diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h b/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h index 3040a47d72..df3e22236d 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h +++ b/sysdeps/unix/sysv/linux/x86_64/x32/arch-syscall.h @@ -155,6 +155,7 @@ #define __NR_lsm_set_self_attr 1073742284 #define __NR_lstat 1073741830 #define __NR_madvise 1073741852 +#define __NR_map_shadow_stack 1073742277 #define __NR_mbind 1073742061 #define __NR_membarrier 1073742148 #define __NR_memfd_create 1073742143 diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h b/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h index 98124169e6..47fa8af4ce 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h +++ b/sysdeps/unix/sysv/linux/x86_64/x32/fixup-asm-unistd.h @@ -15,6 +15,10 @@ License along with the GNU C Library; if not, see . */ +#ifndef __NR_map_shadow_stack +# define __NR_map_shadow_stack 1073742277 +#endif + /* X32 uses the same 64-bit syscall interface for set_thread_area. */ #ifndef __NR_set_thread_area # define __NR_set_thread_area 1073742029