From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 83D393858D38 for ; Sat, 18 Feb 2023 20:37:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83D393858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x233.google.com with SMTP id j3so1396485lji.7 for ; Sat, 18 Feb 2023 12:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=tr3GiOLSPHhnoS46QIfw1VZNQ/rESRBBVBRMhvWQec0=; b=fE+jYWH1g7zMFbSIxYBxU2hqFoOzQOl5u2VyaMp/fe/D6iLQWO9M17+1oSBoOgInr+ SG41NKN9y5Qg5ud6xWUmc6THZckzY8+W2BmKmguTb2EX25wiQaNlifEBAMpRWj0mvM0A UURat8Xg+5oXtjWJ9orJXVEt+59u2xHgLQTt0Ne1J3FcUhnkrhKZPNZOdIcmdZZ5QkHD 6gojQpK1gGNCbP5tx33YE9TNaFZkKTv0R/nuD9xh0IgUT3GYAaVqBZmxWBXmRdiq8nxn Mj4tcOg8DSxVuUoRIl1NMvjUo/EhtnJJmuFA4rAxPImaOX7FlDCyI52uGo3H1jMe5ub6 N0Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=tr3GiOLSPHhnoS46QIfw1VZNQ/rESRBBVBRMhvWQec0=; b=p+yomVv407ESV3dkg0XouyELBWR6129BSYRc/itA2Uu7iAgPwrTg8nTpjjHBryF6Jq Lfny4buUf4+KkJ35zoCtT9LsW5mfcq4JWX6q03R3K6+iBQi2bMhd1wIAo/MtLp1szOEO 8A/l7cke49rVkOOhzURUN/FyxD6sjMQv+TSYsDVuSu14BS5RdZaauurzoRk9np2mc6Gn EYZ5px0HJOyiD2Y/MdXDTM/23HHCARbcf5HpKcYoI7wUbju8WGH3NNDtQnKh28RPxaWn st6NwguOZ0f8nGHEj6PDgou0Twue8uNVA+fMf9z86raPrFHPxjDpjcr3NPl8St3YoN6p mLZQ== X-Gm-Message-State: AO0yUKWtrkmtyl4tkXG2RwN3RHGtAG16PxuPmOGpmHEotNu5eiJgCzdj haILaUGYMUS1keXMlztPruLFpqpzQ2ik5A== X-Google-Smtp-Source: AK7set9TBGDDiNG+iIFj98nnw7yEnqGVocCYy4uejD7C5tVtFo9ilVKDRr1zSkuoOiwI8U82CxoCzw== X-Received: by 2002:a2e:b5d8:0:b0:290:6a6f:48d1 with SMTP id g24-20020a2eb5d8000000b002906a6f48d1mr1503402ljn.43.1676752662073; Sat, 18 Feb 2023 12:37:42 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e4a7:ca9:e8d7:4ead]) by smtp.gmail.com with ESMTPSA id u15-20020a05651c130f00b002934febffe4sm1004049lja.128.2023.02.18.12.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:37:41 -0800 (PST) From: Sergey Bugaev To: bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: =?UTF-8?q?Fl=C3=A1vio=20Cruz?= , Sergey Bugaev Subject: [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64 Date: Sat, 18 Feb 2023 23:37:15 +0300 Message-Id: <20230218203717.373211-8-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com> References: <20230218203717.373211-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_NUMSUBJECT,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 List-Id: Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/{i386 => x86}/init-first.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) rename sysdeps/mach/hurd/{i386 => x86}/init-first.c (96%) diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/x86/init-first.c similarity index 96% rename from sysdeps/mach/hurd/i386/init-first.c rename to sysdeps/mach/hurd/x86/init-first.c index a558da16..75ac1ff2 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/x86/init-first.c @@ -227,10 +227,15 @@ init (int *data) values we set just above. We have stashed in %eax the user code return address. Push it on the top of the stack so it acts as init1's return address, and then jump there. */ +#ifdef __x86_64__ +asm ("call_init1:\n" + " push %rax\n" + " jmp *%rcx\n"); +#else asm ("call_init1:\n" " push %eax\n" " jmp *%ecx\n"); - +#endif /* Do the first essential initializations that must precede all else. */ static inline void @@ -242,7 +247,7 @@ first_init (void) #ifndef SHARED /* In the static case, we need to set up TLS early so that the stack protection guard can be read at gs:0x14 by the gcc-generated snippets. */ - _hurd_tls_init(&__init1_tcbhead); + _hurd_tls_init (&__init1_tcbhead); asm ("movw %%gs,%w0" : "=m" (__init1_desc)); #endif @@ -300,7 +305,7 @@ _hurd_stack_setup (void) { /* If we use ``__builtin_frame_address (0) + 2'' here, GCC gets confused. */ - init ((int *) &argc); + init (&argc); } /* Push the user return address after the argument data, and then @@ -308,9 +313,15 @@ _hurd_stack_setup (void) caller had called `doinit1' with the argument data already on the stack. */ *--data = caller; +# ifdef __x86_64__ + asm volatile ("movq %0, %%rsp\n" /* Switch to new outermost stack. */ + "movq $0, %%rbp\n" /* Clear outermost frame pointer. */ + "jmp *%1" : : "r" (data), "r" (&doinit1)); +# else asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ "jmp *%1" : : "r" (data), "r" (&doinit1)); +# endif /* NOTREACHED */ } -- 2.39.2