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 6A1953858431 for ; Mon, 20 Feb 2023 10:25:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A1953858431 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 1pTtNH-0003s2-HU; Sun, 19 Feb 2023 18:45:43 -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=E2JFE7tSW5R/yLTKyfHqIa6f4uAuuFeUyKVwgjl1BV0=; b=WqHp/Syc95wSO83IWAR9 wkHJuot1rN54qzbPT3TAsLa7Vz8JVOpWnyW9IhryXHWJtelwgG5Ro0GXzLRN9KNm/DWXGZ8hbEBuq MSKT/KD3fWEIfeDsNXGfUU+8PyVmCm9r2z4hbBS2ZLgePAdpRvUs/nTNoBOSxB/i/y1HkS6t+QXkZ WBVnCXwjGdmMiLoDKnUKAr+GYhPi3C4fjljIXyVxbejCwAubcRb+7Q9ISZoE3cbeHjgeIjPpKd5qS DpWszFrxWGeAJ2afTBwCgjM7JRRFYhREcebgXSAjRq+1wRk/RuBMKEkKVwN8cNZgA/vfGggPKfFRx al/IJHkI55E5PA==; 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 1pTtMw-0002eh-Di; Sun, 19 Feb 2023 18:45:43 -0500 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pTtMv-0015oP-0E; Mon, 20 Feb 2023 00:45:21 +0100 Date: Mon, 20 Feb 2023 00:45:21 +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 5/9] hurd: Simplify init-first.c a bit Message-ID: <20230219234521.ljadxq26m57yyeyw@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-6-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-6-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: Applied, thanks! Sergey Bugaev, le sam. 18 févr. 2023 23:37:13 +0300, a ecrit: > And make it a bit more 64-bit ready. This is in preparation to moving this > file into x86/ > > Signed-off-by: Sergey Bugaev > --- > sysdeps/mach/hurd/i386/init-first.c | 23 +++++++---------------- > 1 file changed, 7 insertions(+), 16 deletions(-) > > diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c > index 94c94651..a558da16 100644 > --- a/sysdeps/mach/hurd/i386/init-first.c > +++ b/sysdeps/mach/hurd/i386/init-first.c > @@ -195,7 +195,7 @@ init (int *data) > /* Call `init1' (above) with the user code as the return address, and the > argument data immediately above that on the stack. */ > > - int usercode; > + void *usercode, **ret_address; > > void call_init1 (void); > > @@ -206,10 +206,11 @@ init (int *data) > recognize that this read operation may alias the following write > operation, and thus is free to reorder the two, clobbering the > original return address. */ > - usercode = *((int *) __builtin_frame_address (0) + 1); > + ret_address = (void **) __builtin_frame_address (0) + 1; > + usercode = *ret_address; > /* GCC 4.4.6 also wants us to force loading USERCODE already here. */ > asm volatile ("# %0" : : "X" (usercode)); > - *((void **) __builtin_frame_address (0) + 1) = &call_init1; > + *ret_address = &call_init1; > /* Force USERCODE into %eax and &init1 into %ecx, which are not > restored by function return. */ > asm volatile ("# a %0 c %1" : : "a" (usercode), "c" (&init1)); > @@ -223,19 +224,9 @@ init (int *data) > /* The return address of `init' above, was redirected to here, so at > this point our stack is unwound and callers' registers restored. > Only %ecx and %eax are call-clobbered and thus still have the > - values we set just above. Fetch from there the new stack pointer > - we will run on, and jmp to the run-time address of `init1'; when it > - returns, it will run the user code with the argument data at the > - top of the stack. */ > -asm ("switch_stacks:\n" > - " movl %eax, %esp\n" > - " jmp *%ecx"); > - > -/* As in the stack-switching case, at this point our stack is unwound > - and callers' registers restored, and only %ecx and %eax communicate > - values from the lines above. In this case 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. */ > + 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. */ > asm ("call_init1:\n" > " push %eax\n" > " jmp *%ecx\n"); > -- > 2.39.2 > > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.