From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 248EC3858D20 for ; Mon, 20 Feb 2023 17:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 248EC3858D20 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-ed1-x536.google.com with SMTP id b12so7477460edd.4 for ; Mon, 20 Feb 2023 09:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OBUcDERp+2Jm/nSEtxoubh77w3d2V5aCS6y5jLbf1aQ=; b=pvaRpT4clPLycMaFJqTZ9huBXfFjMlzW0Eikhx0CaGv9gCOjY4WqUvDjUGpFXoWqQM yn+snItu3Ey+zkjY42HwpU71sdY9bT4Pe5aiBqcAoCvt3j0tRDXGXScUxD501YMwdwwD HU3YE39fkr3wg9JVsUPqWZJD4HBt5NS77bPTkqapRRbmyPx0XLddPuwQHeDX5FxsWnNz xhnZvvO/YleOb7XjKE2KSdylDwUJvRlG8id0HUsjxEySOj2+8pQJbYahnA3a9ZPQ4hIr zomkyXIpgF/fV2aRjrb5kTrUTzHNakPcYR66Cn3WqPJC6M7JuLxuChNxoxyX/MZt6EIQ IVIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OBUcDERp+2Jm/nSEtxoubh77w3d2V5aCS6y5jLbf1aQ=; b=s721PLD2PFq4WgqxYwH9gnaEv8QAaaD6S9JKkSHfBpjbyR2lofdoKIWWdVDRLgRuJu j16oKKhTITGtwsuqcMSQLTxqmQEqCqROOgPSLPk8xkwFE3qZBtICslE/0lNKXB2aPYx0 RdkR11MqWKxH380RE/oNRi9aucJJlqIt5MkMo7cQD6Ba4/nqjy7JoQHP/W/dl4kML0Fq odAm2K33SxzLm1LwZIXZedPxdJ3kWzcn28uYSsKZwG0XrX+tSme5a2CG1M7d5OInvIIX JAP3DddFPgHg59BZLe5TATl2PA8I+yaTDtrp93KnhG8wNyA5kJOYEYS1/jIIPqNQMQBu WqKw== X-Gm-Message-State: AO0yUKVpXyId56zQbRPUyhKq0Pb3ffHEazfv2Mwa2AUKnYyrFFxVeA1k PgqNNdZ2ER3geGKAxJfFYBxbJmO8r+DjrKM82uOdQZzv X-Google-Smtp-Source: AK7set8CsPxOCJT1dz0NKy14O1/cZRsKq5eGAsWn53Iac6sB9tvG2NYlJwWsOj1rr0NQvBzGBAV99DGXjxpr8rvzCQ0= X-Received: by 2002:a50:aa9e:0:b0:4ac:bb4e:c38c with SMTP id q30-20020a50aa9e000000b004acbb4ec38cmr596662edc.0.1676914049625; Mon, 20 Feb 2023 09:27:29 -0800 (PST) MIME-Version: 1.0 References: <20230218203717.373211-1-bugaevc@gmail.com> <20230218203717.373211-8-bugaevc@gmail.com> In-Reply-To: <20230218203717.373211-8-bugaevc@gmail.com> From: Noah Goldstein Date: Mon, 20 Feb 2023 11:27:18 -0600 Message-ID: Subject: Re: [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64 To: Sergey Bugaev Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org, =?UTF-8?B?RmzDoXZpbyBDcnV6?= Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.3 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: On Sat, Feb 18, 2023 at 2:40 PM Sergey Bugaev via Libc-alpha wrote: > > 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. */ Unless you are intentionally preserving flags, `xorl %%ebp, %%ebp` is better way to zero a register. > + "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 >