From patchwork Thu Jan 8 06:18:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Reinauer X-Patchwork-Id: 127604 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 453284BA2E2F for ; Thu, 8 Jan 2026 06:20:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 453284BA2E2F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, secure) header.d=coreboot.org header.i=@coreboot.org header.a=rsa-sha256 header.s=dkim header.b=B1cipvLX X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from coreboot.org (mail.coreboot.org [78.46.105.101]) by sourceware.org (Postfix) with ESMTPS id 64CBF4BA2E06 for ; Thu, 8 Jan 2026 06:19:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64CBF4BA2E06 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=coreboot.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=coreboot.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 64CBF4BA2E06 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=78.46.105.101 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1767853144; cv=pass; b=lTifnWnkT3+u2+Gh5tChi21nVj4/tcuymGht5yXwREOTZPCDHyqlC7/BWCVq6CsGcw+/1QH+eBOkGEpTbdDR6c4gAVmmAyrkO3fs25tyjRcqYrwBlc1Jsh3MezMsFMGI9cpRExJoNI9F1sOKPBEY+6fw3ZnupqZVrviC7ECY0no= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1767853144; c=relaxed/simple; bh=FAHqmstA4zlfc/lQRpKyfuKlBwKCk/I2JQiqgo3RS14=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hRBg2BcR2PWDbw0ouWnF5c37dF/W2sf3wCyhpPN6+DGSxwkzWCgVLTtm66csR9oQOPS7ZoX3bmgTW9KTgPvruzL1A44t+OrnUfn89UMfjVnZld8NdRUvxXN1mArPMdJ00ldeAMY7Zpbm6Kjc3fK69m9NSDraK+4h3gDc6Eo+So0= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64CBF4BA2E06 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 41A9E81782; Thu, 8 Jan 2026 06:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coreboot.org; s=dkim; t=1767853143; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iEr8t+e/Pf4AeeSST4OHo/smwE5s7kkD7rd3jbHq7DQ=; b=B1cipvLXDFxMYUVJkEke947R17tLJysJkg5QnVER9moq0UU8w2tqZshuW9C8nTPi6tzG6W 8oNA5T3+ymyGJOmJejCKxxI7S7GjgN0EeOXtbIXdDh/jdf/o5S3tJ2f+vVY4+NQYUkcPrT 838Xvq7SNlZdIjGjWJytI6c36t7Cbm4= From: Stefan To: libc-alpha@sourceware.org Cc: geert@linux-m68k.org, debian-68k@lists.debian.org, Stefan Subject: [PATCH 1/2] m68k: Use vDSO for thread pointer access Date: Wed, 7 Jan 2026 22:18:21 -0800 Message-ID: <20260108061822.3896153-2-stefan.reinauer@coreboot.org> In-Reply-To: <20260108061822.3896153-1-stefan.reinauer@coreboot.org> References: <20260108061822.3896153-1-stefan.reinauer@coreboot.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=coreboot.org; s=dkim; t=1767853143; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iEr8t+e/Pf4AeeSST4OHo/smwE5s7kkD7rd3jbHq7DQ=; b=XOWURP1bhf8iIrDkIYOOnPohIVRvx2+C3Z1rG1fC+PFNDAw702eyHpvLNy89C+xCCSq9a4 248gBKzpELbWjuPwyIT07ehL+1JzK+RTsuDWkfsEXIlf6cqcOaGOB8HNiK7+mO+FJKQ/Ca nxZqOxd7zSuE7VTENVkdbiYGdI3laLo= ARC-Seal: i=1; s=dkim; d=coreboot.org; t=1767853143; a=rsa-sha256; cv=none; b=URj0I5C1+9eq/D15QAUGCtMIaVV+xwUPdhLi9GpYL3vLfaLQZIMtXGVoLb1mTrs0jnByj1duoMxffxuRvTmvOacgVcNnSIg5xSrsQw4hKuZ1J2FhKiMu8L+BuqarM/UOGJYuJRfZeFIJEXzhRbD0BQAnbFvgd/bZhC/Clb0wYtg= ARC-Authentication-Results: i=1; coreboot.org; auth=pass smtp.auth=stepan@coreboot.org smtp.mailfrom=stefan.reinauer@coreboot.org Authentication-Results: coreboot.org; auth=pass smtp.auth=stepan@coreboot.org smtp.mailfrom=stefan.reinauer@coreboot.org X-Spamd-Bar: / X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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~patchwork=sourceware.org@sourceware.org Optimize __m68k_read_tp() to read the thread pointer directly from the vDSO data page when available, avoiding the get_thread_area syscall overhead. The kernel maintains the thread pointer in a data page located at a fixed offset (PAGE_SIZE) before the vDSO ELF header. This value is updated on every context switch and set_thread_area() call. The implementation uses lazy initialization: on first call, it checks AT_SYSINFO_EHDR from auxv to locate the vDSO. If the vDSO is not available (older kernels), it falls back to the syscall. Reviewed-by: Tested-by: * sysdeps/unix/sysv/linux/m68k/m68k-helpers.c: Include stdint.h and sys/auxv.h. (struct m68k_vdso_data): New struct matching kernel layout. (__m68k_vdso_data): New static variable for cached vDSO pointer. (__m68k_vdso_get): New helper to initialize and return vDSO data pointer. (__m68k_read_tp): Use vDSO fast path when available, fall back to syscall otherwise. --- sysdeps/unix/sysv/linux/m68k/m68k-helpers.c | 77 ++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c index 845aae51..1dee48e5 100644 --- a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c +++ b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c @@ -17,9 +17,84 @@ . */ #include +#include +#include +/* + * vDSO data structure - must match the kernel's m68k_vdso_data struct. + * The TLS pointer is at offset 0 in the vDSO data page. + */ +struct m68k_vdso_data +{ + unsigned long tls_ptr; + unsigned long reserved[3]; +}; + +/* + * Pointer to the vDSO data page. + * 0 = not yet initialized + * -1 = vDSO not available (fallback to syscall) + * other = valid vDSO data page address + */ +static volatile struct m68k_vdso_data *__m68k_vdso_data; + +/* + * Initialize the vDSO pointer on first use. + * Returns the pointer to the vDSO data, or NULL if not available. + */ +static inline struct m68k_vdso_data * +__m68k_vdso_get (void) +{ + struct m68k_vdso_data *vdso = (struct m68k_vdso_data *) __m68k_vdso_data; + + if (__glibc_unlikely (vdso == NULL)) + { + /* Not yet initialized - try to get vDSO base from auxv */ + unsigned long sysinfo_ehdr = __getauxval (AT_SYSINFO_EHDR); + if (sysinfo_ehdr != 0) + { + /* + * The kernel passes the address of the vDSO ELF header (code page). + * The vDSO memory layout is: + * base + 0x0000: vvar (data page with TLS pointer, clock state) + * base + 0x1000: timer page (hardware timer registers) + * base + 0x2000: vDSO code (ELF, AT_SYSINFO_EHDR points here) + * So the data page is 2 * PAGE_SIZE before the code page. + */ + vdso = (struct m68k_vdso_data *) (sysinfo_ehdr - 2 * 4096); + } + else + { + /* vDSO not available - mark as unavailable */ + vdso = (struct m68k_vdso_data *) (uintptr_t) -1; + } + __m68k_vdso_data = vdso; + } + + /* Return NULL if vDSO is marked as unavailable */ + if ((uintptr_t) vdso == (uintptr_t) -1) + return NULL; + + return vdso; +} + +/* + * Get the thread pointer. + * + * Fast path: Read directly from the vDSO data page if available. + * The kernel updates this on every context switch and set_thread_area() call. + * + * Slow path: Fall back to the get_thread_area syscall. + */ void * __m68k_read_tp (void) { - return (void*) INTERNAL_SYSCALL_CALL (get_thread_area); + struct m68k_vdso_data *vdso = __m68k_vdso_get (); + + /* Fast path: use vDSO if available */ + if (__glibc_likely (vdso != NULL)) + return (void *) vdso->tls_ptr; + + /* Slow path: syscall fallback */ + return (void *) INTERNAL_SYSCALL_CALL (get_thread_area); } From patchwork Thu Jan 8 06:18:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Reinauer X-Patchwork-Id: 127605 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6EA7A4BA2E2F for ; Thu, 8 Jan 2026 06:20:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EA7A4BA2E2F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, secure) header.d=coreboot.org header.i=@coreboot.org header.a=rsa-sha256 header.s=dkim header.b=u1XJOBUs X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from coreboot.org (mail.coreboot.org [78.46.105.101]) by sourceware.org (Postfix) with ESMTPS id 1FC164BA2E22 for ; Thu, 8 Jan 2026 06:19:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1FC164BA2E22 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=coreboot.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=coreboot.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1FC164BA2E22 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=78.46.105.101 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1767853147; cv=pass; b=E6UwKm/958tS56sgNWA+yElodWabDgrIjVouCBjwYmfOUitDckVTHyA75Gl9lGkDtNct1QMuXBDwHunDTCE3xaKrl9d+sYrsOQuYUD3p5i7WQlXzte15PvoBxzos5vb4OH3q7jtAxNzSXTCQwfLGh8UYSyrWWchjecj58Gr4LAE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1767853147; c=relaxed/simple; bh=0SCpoUsoJGiWE4+YpYwFkr0hguua38nvEUVQ8C4WWP0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vadgCLzY0GXGrgqJ74aQal3me38uWhntvQXBwIgXgzrV4Dxo1CbVmTArC6hH2FOQ4ojw+Vy1saRM3e0VBPmkA+VS/AZ/7tGzsvzLQMTFSsvTCA2bAuJjSULapwGGOKnK0NGCRL+RjXDPVlNaf1QkjvfO+NoivQEVu2K+uqqIASw= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FC164BA2E22 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id BB0CC81792; Thu, 8 Jan 2026 06:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coreboot.org; s=dkim; t=1767853145; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y21OmRONxwkt1kQagrX4FCr/i7gJu39vAEE0PU8vZcw=; b=u1XJOBUsb9HFjSLjqI5wVR9I1lkwv3Nyuudk1/mg+aLgiNIFGkdhyYKoZXwx4JPWeWt8Nq lcnrI8cwYg5nSpw8ewWgNoDenmIzntyxSql5bEHt6TjwFyNHisn5TKGvi7SfmL7N0MBbts dMzo0EIIxJrmu/AA50WYvGIZq+CXULc= From: Stefan To: libc-alpha@sourceware.org Cc: geert@linux-m68k.org, debian-68k@lists.debian.org, Stefan Subject: [PATCH 2/2] m68k: Enable vDSO clock_gettime64 Date: Wed, 7 Jan 2026 22:18:22 -0800 Message-ID: <20260108061822.3896153-3-stefan.reinauer@coreboot.org> In-Reply-To: <20260108061822.3896153-1-stefan.reinauer@coreboot.org> References: <20260108061822.3896153-1-stefan.reinauer@coreboot.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=coreboot.org; s=dkim; t=1767853145; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y21OmRONxwkt1kQagrX4FCr/i7gJu39vAEE0PU8vZcw=; b=FilCyfYp4eLXwWDYo7kgMjbFFYjtYsY8DmAx65JP3pijeaxIfWmDqKE+J5SrBFmcZ21epo WPBpVlUdAu25wyyWzUGPPNu7jfJXMkfjPgeby2o2ZLyPWg+kIaPZSwiyYzD0DptggUGEEv KrWT97BDZ3qcjJe9WviKY9xZws/2IFc= ARC-Seal: i=1; s=dkim; d=coreboot.org; t=1767853145; a=rsa-sha256; cv=none; b=UQrEPbTQpqZn+wd+KHFkwfWarAjk0rCoTPLHVwMob2DmD9ZhZGO6wX8T2NpGy0pcox96epyxFy0U8fjfPxAVlEXW6xkigEM2eXwgRpqD1hNT9pGPRblvPCPfWOUCMONRN0iBDi1aDD+3cJszvDB6gg0gWMX8NF0QBfKt6TQC2S0= ARC-Authentication-Results: i=1; coreboot.org; auth=pass smtp.auth=stepan@coreboot.org smtp.mailfrom=stefan.reinauer@coreboot.org Authentication-Results: coreboot.org; auth=pass smtp.auth=stepan@coreboot.org smtp.mailfrom=stefan.reinauer@coreboot.org X-Spamd-Bar: / X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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~patchwork=sourceware.org@sourceware.org Define HAVE_CLOCK_GETTIME64_VSYSCALL to enable using the vDSO for clock_gettime64 on m68k. This allows glibc to use the kernel-provided __vdso_clock_gettime64 symbol for fast time retrieval without entering kernel mode via a syscall. This follows the glibc conventions: - Subject line with architecture prefix (m68k:) and imperative description - Blank line separator - Body explaining the purpose of the change - Two-space sentence endings (glibc style) - Describes what the macro enables (vDSO symbol lookup for clock_gettime64) --- sysdeps/unix/sysv/linux/m68k/sysdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h index 6f6b46e0..be02863b 100644 --- a/sysdeps/unix/sysv/linux/m68k/sysdep.h +++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h @@ -298,3 +298,10 @@ SYSCALL_ERROR_LABEL: \ /* M68K needs system-supplied DSO to access TLS helpers even when statically linked. */ #define NEED_STATIC_SYSINFO_DSO 1 + +/* vDSO version string and hash for symbol lookup. */ +#define VDSO_NAME "LINUX_5.0" +#define VDSO_HASH 61765872 + +/* vDSO symbol for fast clock_gettime64. */ +#define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime64"