From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C5F821F451 for ; Wed, 3 Jan 2024 17:19:18 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=mdy24mxg; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0796E385B50E for ; Wed, 3 Jan 2024 17:19:18 +0000 (GMT) Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id F37D1385801E for ; Wed, 3 Jan 2024 17:15:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F37D1385801E 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 F37D1385801E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704302125; cv=none; b=LgBImH4cnflf3URfb9HD6G7FYWJxbjVsSDmCSlhPGw4Zq9IuErgWgHJtoZ5mUdA/OhvFuXfWJq7BYncfDzFJIBtJJJ9IzM2xPumXzWc1TALxEyOyQZIUoWNDDOgv9Qv5DgCbpmSUhoKH3rPp7ToBlmxDlS6KYh8YBhkFwoQOUKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704302125; c=relaxed/simple; bh=ueCg0AsqsrRevxVqB9O6diCpkyBc1Zw3qqBGS2/+I8o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PKT3iSTPZEl0irA6/GFm4WvtmgsEDLcapZ8+6VN12wPfNMZLT75now3fNaOh1dpyyLbBiClN9q3M/BqWQfGD4NDYG6/zUodmHD8CW144vksCTpf3B2juQcBM/pHKYCgT6p60relbh3mM3QaB5SenB7RdZgk97+jmiY8eaBbDh6g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50e80d14404so621298e87.1 for ; Wed, 03 Jan 2024 09:15:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704302120; x=1704906920; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4T9p8qd0DXcQFvFZ4tMsY/vUkeDpWvhb5Z/8c2VXREE=; b=mdy24mxgPPg+5QsjZe4NKKkE0k5k828uLxUxmYovw179KamI1DBAqOjE8XL7y0cjOY LAMHDBRMlAIe0POwj61lz+2/gZm9NTfhAWzXyO+ehAFTws8DROGd3iC7jBcGK7+/1h0F IpCRO1SZj7XXIKsI5RG+j1/cCaLgyhTAUmNw1ok5GC5s8ROVFtX6GVWzzPqYkowXaAmF kVL4YUoZw4xW1r3ZyuQAE/e5tbp/L/zCV+fKvQcAgYHAOCtXnx5nNqK+ydu2TRHlRxap kuDQNbWuGO3HXNQkvvYqdOVNCU1Mrj3/RHskoURwozylOHGQjUEwZhQwYAgBsA9H4cHL yovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704302120; x=1704906920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4T9p8qd0DXcQFvFZ4tMsY/vUkeDpWvhb5Z/8c2VXREE=; b=jeMA8ee7V9OTpJiiKSsnlFDUMQwscajBMXk/QSlenrqXLBS40a6QINFLgt15iw3svC CReSiGD5X02Srp6349Zw57RCyU8P0scOI5MfC+A9b1RXqAgnqrfNAq0tvFKP/L0lxD/J yG+HkF5ieRdz/HSsGd2JrqKdbJgAMVYGjNzmyLxo6QiXdMNfozN3f7cEAiBwFRutlmC6 yRfDWMRQFEvh++d2B85tfpguGlE4R1YMXlxq60G687figXbB9OT9fEgZpEzI5yYcN8KT OEz3lrmN2w5SOvE+d5hgRjtgC8CHMoVg7k2ydRUdOmqAcCk/FTKatKL8p4XXIvIg3qpH f5kw== X-Gm-Message-State: AOJu0YziYjQl4TkdMdDOgHsDl2xiimyuJEVuKdS+Weyz6I9Q2edvTig/ R5Yu6S3ZuEm8E68le6AAX3X4TK3Bcc8= X-Google-Smtp-Source: AGHT+IEe3DPs+FvxzruKdXZMjuAuoH/2H3lKvl+CY//6q5dutjP3eot4fPtImvF21FQ4CRmiKrsvKw== X-Received: by 2002:a05:6512:39c9:b0:50e:a9df:80d3 with SMTP id k9-20020a05651239c900b0050ea9df80d3mr334442lfu.6.1704302119613; Wed, 03 Jan 2024 09:15:19 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:b32f:ebdc:fd0:376b:8006]) by smtp.gmail.com with ESMTPSA id y23-20020a196417000000b0050e6d84d177sm3546068lfb.279.2024.01.03.09.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:15:19 -0800 (PST) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [RFC PATCH 16/23] hurd: Add a basic AArch64 port Date: Wed, 3 Jan 2024 20:14:49 +0300 Message-ID: <20240103171502.1358371-17-bugaevc@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103171502.1358371-1-bugaevc@gmail.com> References: <20240103171502.1358371-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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+e=80x24.org@sourceware.org The following commits will add TLS, HTL, and the signal bits. Signed-off-by: Sergey Bugaev --- We're using GLIBC_2.39 as the baseline shlib version. static-start.S reproduces the same GOT pre-filling trick as on x86_64; I have verified that this does not prevent real implementations from being installed later. sysdeps/mach/hurd/aarch64/Implies | 3 ++ sysdeps/mach/hurd/aarch64/longjmp-ts.c | 50 +++++++++++++++++++++++ sysdeps/mach/hurd/aarch64/shlib-versions | 2 + sysdeps/mach/hurd/aarch64/static-start.S | 52 ++++++++++++++++++++++++ sysdeps/mach/hurd/aarch64/vm_param.h | 24 +++++++++++ 5 files changed, 131 insertions(+) create mode 100644 sysdeps/mach/hurd/aarch64/Implies create mode 100644 sysdeps/mach/hurd/aarch64/longjmp-ts.c create mode 100644 sysdeps/mach/hurd/aarch64/shlib-versions create mode 100644 sysdeps/mach/hurd/aarch64/static-start.S create mode 100644 sysdeps/mach/hurd/aarch64/vm_param.h diff --git a/sysdeps/mach/hurd/aarch64/Implies b/sysdeps/mach/hurd/aarch64/Implies new file mode 100644 index 00000000..02af165f --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/Implies @@ -0,0 +1,3 @@ +mach/hurd/htl +aarch64/htl +mach/hurd/aarch64/htl diff --git a/sysdeps/mach/hurd/aarch64/longjmp-ts.c b/sysdeps/mach/hurd/aarch64/longjmp-ts.c new file mode 100644 index 00000000..17507662 --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/longjmp-ts.c @@ -0,0 +1,50 @@ +/* Perform a `longjmp' on a Mach thread_state. aarch64 version. + Copyright (C) 1991-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 + . */ + +#include +#include +#include + + +/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */ + +void +_hurd_longjmp_thread_state (void *state, jmp_buf env, int val) +{ + struct aarch64_thread_state *ts = state; + + ts->x[19] = env[0].__jmpbuf[JB_X19]; + ts->x[20] = env[0].__jmpbuf[JB_X20]; + ts->x[21] = env[0].__jmpbuf[JB_X21]; + ts->x[22] = env[0].__jmpbuf[JB_X22]; + ts->x[23] = env[0].__jmpbuf[JB_X23]; + ts->x[24] = env[0].__jmpbuf[JB_X24]; + ts->x[25] = env[0].__jmpbuf[JB_X25]; + ts->x[26] = env[0].__jmpbuf[JB_X26]; + ts->x[27] = env[0].__jmpbuf[JB_X27]; + ts->x[28] = env[0].__jmpbuf[JB_X28]; + ts->x[29] = env[0].__jmpbuf[JB_X29]; + ts->x[30] = env[0].__jmpbuf[JB_LR]; + + /* XXX: We're ignoring all the d[] (SIMD) registers. + Is that fine? */ + + ts->pc = env[0].__jmpbuf[JB_LR]; + ts->sp = _jmpbuf_sp (env[0].__jmpbuf); + ts->x[0] = val ?: 1; +} diff --git a/sysdeps/mach/hurd/aarch64/shlib-versions b/sysdeps/mach/hurd/aarch64/shlib-versions new file mode 100644 index 00000000..8c238d6b --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/shlib-versions @@ -0,0 +1,2 @@ +DEFAULT GLIBC_2.39 +ld=ld-aarch64.so.1 diff --git a/sysdeps/mach/hurd/aarch64/static-start.S b/sysdeps/mach/hurd/aarch64/static-start.S new file mode 100644 index 00000000..7a1c19c0 --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/static-start.S @@ -0,0 +1,52 @@ +/* Startup code for statically linked Hurd/aarch64 binaries. + Copyright (C) 1998-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 + . */ + +#include + +/* This is the actual entry point for statically linked aarch64-gnu executables, + the very first code to run in a process. */ + + .text +ENTRY(_start) + /* Set up the initial stack frame. */ + cfi_undefined (x30) + mov x29, #0 + mov x30, #0 + + /* Pre-fill GOT entries for select ifunc routines that may get + called during _hurd_stack_setup () with baseline implementations. */ + adrp x1, __memcpy_generic + add x1, x1, #:lo12:__memcpy_generic + adrp x0, :got:memcpy + str x1, [x0, :got_lo12:memcpy] + + adrp x1, __strlen_generic + add x1, x1, #:lo12:__strlen_generic + adrp x0, :got:strlen + str x1, [x0, :got_lo12:strlen] + + mov x0, sp + bl _hurd_stack_setup + + /* Jump to the regular entry point. */ + mov x0, #0 + b _start1 +END(_start) + +#define _start _start1 +#include diff --git a/sysdeps/mach/hurd/aarch64/vm_param.h b/sysdeps/mach/hurd/aarch64/vm_param.h new file mode 100644 index 00000000..304a2f2b --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/vm_param.h @@ -0,0 +1,24 @@ +/* Copyright (C) 2020-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 + . */ + +#ifndef _AARCH64_VM_PARAM_H +#define _AARCH64_VM_PARAM_H + +/* Arbitrary start of the brk. This is after usual binary and library mappings. */ +#define BRK_START 0x200000000000 + +#endif /* aarch64/vm_param.h */ -- 2.43.0