From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 4BAEE388B68F for ; Mon, 20 Feb 2023 10:27:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4BAEE388B68F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTtcW-0000r7-OU; Sun, 19 Feb 2023 19:01:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=juJ4tdAXVabenOuew7siCoJsr6cy6MshAKqTCCkPWdg=; b=HSKW8ffLpR7KH6BJQeW3 fLXMlHJ2b3EPshRvbtEshK5J79/+Qs+Nwo/KvOHSXbVp/rsbF330wZUqoYTFU9ctkzqeTK6F401eh 2VcK84kr2oDPKQJ/QJ4LV8aAwLSDOvtBo6PZ7TD8+ViL8vY4BkHjQ7O6ERuzIXodn0SAWePFhzmpJ qqwJMkbGrj9Cnjjk5duzArr3bXIIit8BLlbdvl0xIPMHoqeqDECyOSeg9yTHnVuPysuK6LGO6160v tBQ0yHgkDedPBG9oX/vYJnskeBQK1kLFEe18N7CR6MAG5/q7vOWLxzatH+Chy/dvphhbcOlm582lV 9Tnu+mowQf0Fmw==; Received: from lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr ([92.158.138.184] helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTtcI-0005Vf-DI; Sun, 19 Feb 2023 19:01:28 -0500 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pTtcF-0016TI-0k; Mon, 20 Feb 2023 01:01:11 +0100 Date: Mon, 20 Feb 2023 01:01:11 +0100 From: Samuel Thibault To: Sergey Bugaev Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org, =?utf-8?Q?Fl=C3=A1vio?= Cruz Subject: Re: [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64 Message-ID: <20230220000111.umchmzgk4vzgpayq@begin> Mail-Followup-To: Sergey Bugaev , bug-hurd@gnu.org, libc-alpha@sourceware.org, =?utf-8?Q?Fl=C3=A1vio?= Cruz References: <20230218203717.373211-1-bugaevc@gmail.com> <20230218203717.373211-8-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230218203717.373211-8-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Sergey Bugaev, le sam. 18 févr. 2023 23:37:15 +0300, a ecrit: > 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); That won't work on x86_64: there, arguments are passed mostly through registers, so &argc won't actually give you the address of arguments on the stack. This can probably be checked on linux x86_64 to make sure how arguments are passed. > } > > /* 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 > > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.