From patchwork Sat Mar 23 17:32:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1915218 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=YhCgDHH6; 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 4V25zJ5V3Gz1yXr for ; Sun, 24 Mar 2024 04:39:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5D0E3858C53 for ; Sat, 23 Mar 2024 17:39:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 6F7CA3858C50 for ; Sat, 23 Mar 2024 17:35:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F7CA3858C50 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 6F7CA3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711215329; cv=none; b=odu+wtHZkfuRHr5uvMVxnUaS6AxeD38AoAoK14D8jAoGOgEPiR05W4VPCs5MbvQRaiSB2r9HYkR4gc432C45rQqPjDr76AZT1L9oNrWftjZGAEcImscWlGRI0bb04QWtg63tStcud4x2CQu4DQaXzYQKzJ48Qj1TeqYijvZK3KA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711215329; c=relaxed/simple; bh=ryi1nroyizEOJRv0oSWQKNaIVo/huZWe3+NDU9jSanM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xij3CVN47cxVRQz0BNEJe3oLUjwCF6fK/vEFlb9bI+VUn8CRUoYLZVEnlqf5AactnR19o3WKNCgaLzU81mvn6DKzqO6JqJv6eNI93zW3+YKfhJLSjgo/Z4AVraGxh+TsYVtWu1WLkVnT6f3g+76idfCvoBRGFHARn9mB4esZVRg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-512b3b04995so1860548e87.3 for ; Sat, 23 Mar 2024 10:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711215324; x=1711820124; 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=kp8AD4ChmCphjUDvDGSSI6y4cCbMNxd375vMEKpv8b4=; b=YhCgDHH6eyHHeFBU9SIb/zXG8je892udElTd3bkN+4YmsgXJw8j9DDUXs7qjO4H2B7 BsRxw+5rDtIGiQ+ktaM2+rzuBWg8qOUqX9KKlxgkfZOM34y0SRWh9UPEuxnTMwkWu+WP IubEbRmQNgxGW+6qy2SD7yuHoKmg+MScSo0lJ3uOx6JPiXnUCAV3Og0FvOvocBQnRnO8 K1WQIh223FFgkRqwWNucjDvVVudL3wnQg/VlTGuEBgdxjAcv8ZjiDkEYfrDUOEp/AOc1 GxRVB3Vgz9W7CnTF7Zfwd/5tVCM3zOoAA9/97HfWbcnfktm2524MpF0u4pH4AKEhiwSx MaAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711215324; x=1711820124; 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=kp8AD4ChmCphjUDvDGSSI6y4cCbMNxd375vMEKpv8b4=; b=YIKtDXbTJxjwPwZ0+AS1FEvSZlku9wGkqkgA65ODxs83Xu97rlJ2irWDJHuveIbTb0 0OtEZ2voG/udIPfkr79b0Jhid03xYomD7w2a6Yx877idt7A3QYQ1NV7Frra+UlQ+QmKg 9Exra17AeY34muz6VVRtBBcp7aBH2htPsaSqQjWAjSjs8wtHMMlqUSg/4Q27Esf1LRaS MItBqD/UlFHvqNpf4vnLU55q6iISi93CZPrnDvvh4CltoUaO2xeLVhnMtzgk4jLwFBU8 SIWQvLmVEiMmpWfXA83wAkNrib1NnMgoWhELFffabBv2e0nFEZqlIUw676gsVjYXOHQ0 JWqg== X-Gm-Message-State: AOJu0YxF6g+dGhciUMtmxglRfeEC0APV13PjSWRlY0yvxTno6uB4Kp2d H8OVawNwDtWzTPru5Z2T+8+IdBGp0XaLofXh9e/0d6dbPENNtWTNbUJgdJ4Q X-Google-Smtp-Source: AGHT+IEINEEp6tSaOy0xZa9dg/SfCOXOppnZliRDrQFr0O58g9oXDbhb3EkS2U/LzJKQMmhUFOPGbg== X-Received: by 2002:ac2:5586:0:b0:513:d94a:670f with SMTP id v6-20020ac25586000000b00513d94a670fmr1550138lfg.31.1711215324566; Sat, 23 Mar 2024 10:35:24 -0700 (PDT) Received: from surface-pro-6.. (79-139-171-253.dynamic.spd-mgts.ru. [79.139.171.253]) by smtp.gmail.com with ESMTPSA id g20-20020ac25394000000b00513973dee6fsm361290lfh.150.2024.03.23.10.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 10:35:24 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Maxim Kuvyrkov , Luca Subject: [PATCH v2 13/20] hurd: Add a basic AArch64 port Date: Sat, 23 Mar 2024 20:32:54 +0300 Message-ID: <20240323173301.151066-14-bugaevc@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240323173301.151066-1-bugaevc@gmail.com> References: <20240323173301.151066-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.5 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_BARRACUDACENTRAL, 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 The following commits will add TLS, HTL, and the signal bits. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/aarch64/Implies | 3 ++ sysdeps/mach/hurd/aarch64/longjmp-ts.c | 49 ++++++++++++++++++++++ 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, 130 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..2fcb7493 --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/longjmp-ts.c @@ -0,0 +1,49 @@ +/* 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]; + + /* XXX: We're ignoring all the d[] (SIMD) registers. + Is that fine? */ + + ts->pc = PTR_DEMANGLE (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..b9e7c2cb --- /dev/null +++ b/sysdeps/mach/hurd/aarch64/shlib-versions @@ -0,0 +1,2 @@ +DEFAULT GLIBC_2.40 +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..e09865c4 --- /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 */