| Message ID | 20240801-rseq-abi-v11-split-v12-0-0e87479dddc0@efficios.com (mailing list archive) |
|---|---|
| Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5105385DDF1 for <patchwork@sourceware.org>; Mon, 5 Aug 2024 20:49:31 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id B45A9385840F for <libc-alpha@sourceware.org>; Mon, 5 Aug 2024 20:48:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B45A9385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B45A9385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722890940; cv=none; b=wM3feI61QUMCaee7LDsMivF/oEYdf8wbjNS00ZVph/AL5PuAzgo05vo26WMeN4c9eEBrNTzbIC4ycPBhjL98ov2RLPkvJP+7VaeS4WMwGv1EEa+d0kNKGCx49t/cs59fznQ3JjmNU47Y/2NRkkvUlDYZQUlcQGuegV0WlVUn/60= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722890940; c=relaxed/simple; bh=BesBlwMRLY3wYPuXEGS8HWYpA5HFiovDzFWGHLzMGqE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iyf4whZ/EVb8fuaWa18/xyZPTQhdq4HSU4M2JSZu8MwSOHFIGmFYIbLNyig6mB19JoQcd4075OaUrFQWggrbfYMeZeUovg0X94IqJgn3e9Zzqsw4PS1kuH3NdefDmz+BJPi3qMsS+R/B5QFhVrdKkr7HzfpH8/EE1tOtFJ2R8LE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722890936; bh=BesBlwMRLY3wYPuXEGS8HWYpA5HFiovDzFWGHLzMGqE=; h=From:To:Cc:Subject:Date:From; b=uUNS0pMiFR77cwY2sV40jdkaZD3WC2roU9atGpGR/yA1yu7nE2XO9NlTdgQp/5T3q 0KnTdgNoVUKGTulGvQnfVmqYiYMsXbDLQZDAGJAuJpOMOhw5KAIuxLhb0LfR9WCMWf zgQXMB+W73Oy/PS+r01hhKI16BakcEULbPJB4hauQ0S0RIsdb2v/258S3xrVI2EPf3 mkMvTJqaQeQvs+NZ1qghtt7twM6Gnc9Wwl+X/Zhu/3X7YgAHLqejpm8rOybPPI7mIy vod4GRDp9qNbjrqPSBoNZtYn7s1uqsgvEnKgncA4YR3NTgl9Kd73C1Xj6uA4WLg33G N6DSe9KzE1/Vg== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Wd7p01klbz1GY6; Mon, 5 Aug 2024 16:48:56 -0400 (EDT) From: Michael Jeanson <mjeanson@efficios.com> To: libc-alpha@sourceware.org Cc: Michael Jeanson <mjeanson@efficios.com>, Florian Weimer <fweimer@redhat.com>, Carlos O'Donell <carlos@redhat.com>, DJ Delorie <dj@redhat.com>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Subject: [PATCH v12 00/17] Add rseq extensible ABI support Date: Mon, 5 Aug 2024 16:48:22 -0400 Message-Id: <20240801-rseq-abi-v11-split-v12-0-0e87479dddc0@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
Add rseq extensible ABI support
|
|
Message
Michael Jeanson
Aug. 5, 2024, 8:48 p.m. UTC
Introduced in Linux v6.3 the rseq extensible ABI [1] will allow adding
rseq features past the initial 32 bytes of the original ABI.
While the rseq features in the latest kernel still fit within the
original ABI size, there are currently only 4 bytes left. It would thus
be a good time to add support for the extensible ABI so that when new
features are added, they are immediately available to GNU libc users.
We use the ELF auxiliary vector to query the kernel for the size and
alignment of the rseq area, if this fails we default to the original
fixed size and alignment of '32' which the kernel will accept as a
compatibility mode with the original ABI.
This makes the size of the rseq area variable and thus requires to
relocate it out of 'struct pthread'. We chose to move it after (in block
allocation order) the last TLS block inside the static TLS block
allocation. It required a fairly small modification to the TLS block
allocator and did not interfere with the main executable TLS block which
must always be the first block relative to the thread pointer.
[1] https://lore.kernel.org/all/20221122203932.231377-4-mathieu.desnoyers@efficios.com/
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: DJ Delorie <dj@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
Changes since v11:
- Removed _dl_rseq_feature_size, use __rseq_size instead
- Replace GLRO(dl_rseq_align) with a hidden global variable _rseq_align
- __rseq_size is now set directly in _dl_parse_auxv, set it to 0 when
the main thread registration fails or is disabled by tunable
Changes since v10:
- Split the patchset in smaller patches
- Rebased on 'Make __rseq_size useful for feature detection'
- Remove 'rseq' from the generic TLS code, add 'extra TLS'
- Add thread_pointer.h for all Linux architectures
- Fix build on the Hurd
Changes since v8:
- Fix copyright year in sysdeps/generic/dl-rseq.h
- Clarify the the tcb math comments
- Add a comment to clarify what enforces the aligment requirements of a
pointer calculated from the rseq_offset
- Remove nonsensical test in tst-rseq-disable
- Add comments to clarify why the rseq size is 0 when registration fails
or is disabled
- Add comments to explain why whe allocate and rseq area block even when
the registration is disabled by tunable
- Rename 'rseq_size' -> 'rseq_alloc_size' and 'dl_tls_rseq_size' ->
'dl_tls_rseq_alloc_size' to clarify the distinction between the
allocated rseq size and the size reported to application code in
'__rseq_size'
Changes since v6:
- Fix tst-rseq for feature size over 32 bytes
- Rebased on 'nptl: fix potential merge of __rseq_* relro symbols'
Changes since v5:
- Fix TLS_DTV_AT_TP rseq offset with statically linked executables
Changes since RFC v4:
- Move dynamic linker defines to a header file
- Fix alignment when tls block align is smaller than rseq align with
statically linked executables
- Add statically linked rseq tests
- Revert: Set __rseq_size even when the registration fails
- Use minimum size when rseq is disabled by tunable
Changes since RFC v3:
- Fix RSEQ_SETMEM for rseq disabled
- Replace sys/auxv.h usage with dl-parse_auxv.h
- Fix offset for TLS_TCB_AT_TP with statically linked executables
- Zero the rseq area before registration
Changes since RFC v2:
- Set __rseq_size even when the registration fails
- Adjust rseq tests to the new ABI
- Added support for statically linked executables
Changes since RFC v1:
- Insert the rseq area after the last TLS block
- Add proper support for TLS_TCB_AT_TP variant
---
Michael Jeanson (17):
nptl: Add rseq auxvals
Add generic 'extra TLS'
Add Linux 'extra TLS'
nptl: Add <thread_pointer.h> for RISC-V
nptl: Add <thread_pointer.h> for LoongArch
nptl: Add <thread_pointer.h> for sparc
nptl: Add <thread_pointer.h> for m68k
nptl: Add <thread_pointer.h> for or1k
nptl: Add <thread_pointer.h> for nios2
nptl: Add <thread_pointer.h> for microblaze
nptl: Add <thread_pointer.h> for hppa
nptl: Add <thread_pointer.h> for csky
nptl: add RSEQ_SIG for RISC-V
nptl: Introduce RSEQ_GETMEM_VOLATILE and RSEQ_SETMEM
nptl: Move the rseq area to the 'extra TLS' block
nptl: Remove the rseq area from 'struct pthread'
Linux: Update internal copy of '<sys/rseq.h>'
csu/libc-tls.c | 59 ++++++++++++++---
elf/dl-tls.c | 59 +++++++++++++++++
nptl/descr.h | 20 +-----
nptl/pthread_create.c | 2 +-
sysdeps/csky/nptl/thread_pointer.h | 30 +++++++++
sysdeps/generic/dl-extra_tls.h | 45 +++++++++++++
sysdeps/hppa/nptl/thread_pointer.h | 30 +++++++++
sysdeps/i386/nptl/tcb-access.h | 61 +++++++++++++++++
sysdeps/loongarch/nptl/thread_pointer.h | 34 ++++++++++
sysdeps/m68k/nptl/thread_pointer.h | 30 +++++++++
sysdeps/microblaze/nptl/thread_pointer.h | 30 +++++++++
sysdeps/nios2/nptl/thread_pointer.h | 30 +++++++++
sysdeps/nptl/dl-tls_init_tp.c | 22 +++---
sysdeps/nptl/tcb-access.h | 5 ++
sysdeps/or1k/nptl/thread_pointer.h | 30 +++++++++
sysdeps/riscv/nptl/thread_pointer.h | 34 ++++++++++
sysdeps/sparc/nptl/thread_pointer.h | 30 +++++++++
sysdeps/unix/sysv/linux/Makefile | 10 +++
sysdeps/unix/sysv/linux/dl-extra_tls.h | 76 +++++++++++++++++++++
sysdeps/unix/sysv/linux/dl-parse_auxv.h | 5 ++
sysdeps/unix/sysv/linux/riscv/bits/rseq.h | 44 ++++++++++++
sysdeps/unix/sysv/linux/rseq-internal.h | 81 ++++++++++++++++++++---
sysdeps/unix/sysv/linux/sched_getcpu.c | 3 +-
sysdeps/unix/sysv/linux/sys/rseq.h | 11 +++
sysdeps/unix/sysv/linux/tst-rseq-disable-static.c | 1 +
sysdeps/unix/sysv/linux/tst-rseq-disable.c | 60 ++++++++++++++---
sysdeps/unix/sysv/linux/tst-rseq-nptl-static.c | 1 +
sysdeps/unix/sysv/linux/tst-rseq-static.c | 1 +
sysdeps/unix/sysv/linux/tst-rseq.c | 81 ++++++++++++++++++-----
sysdeps/unix/sysv/linux/tst-rseq.h | 7 +-
sysdeps/x86_64/nptl/tcb-access.h | 61 +++++++++++++++++
31 files changed, 919 insertions(+), 74 deletions(-)
---
base-commit: 060c2618c804aee86f3b787c851c2760c0391a68
change-id: 20240801-rseq-abi-v11-split-ae0d0f1d39e3