public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Sergey Bugaev <bugaevc@gmail.com>
To: bug-hurd@gnu.org, libc-alpha@sourceware.org
Cc: "Flávio Cruz" <flaviocruz@gmail.com>,
	"Sergey Bugaev" <bugaevc@gmail.com>
Subject: [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64
Date: Sat, 18 Feb 2023 23:37:15 +0300	[thread overview]
Message-ID: <20230218203717.373211-8-bugaevc@gmail.com> (raw)
In-Reply-To: <20230218203717.373211-1-bugaevc@gmail.com>

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 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


  parent reply	other threads:[~2023-02-18 20:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18 20:37 [RFC PATCH 0/9] More x86_64-gnu glibc work Sergey Bugaev
2023-02-18 20:37 ` [RFC PATCH 1/9] hurd: Move thread state manipulation into _hurd_tls_new () Sergey Bugaev
2023-02-19 23:32   ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 2/9] hurd: Use proper integer types Sergey Bugaev
2023-02-19 23:33   ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 3/9] hurd: Fix xattr function return type Sergey Bugaev
2023-02-19 23:34   ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 4/9] hurd: Make timer_t pointer-sized Sergey Bugaev
2023-02-19 23:35   ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 5/9] hurd: Simplify init-first.c a bit Sergey Bugaev
2023-02-19 23:45   ` Samuel Thibault
2023-02-18 20:37 ` [RFC PATCH 6/9] mach: Use PAGE_SIZE Sergey Bugaev
2023-02-19 23:47   ` Samuel Thibault
2023-02-18 20:37 ` Sergey Bugaev [this message]
2023-02-20  0:01   ` [RFC PATCH 7/9] hurd: Generalize init-first.c to support x86_64 Samuel Thibault
2023-02-20 16:16     ` Sergey Bugaev
2023-02-20 17:10       ` Sergey Bugaev
2023-02-20 17:31         ` Samuel Thibault
2023-02-20 17:27   ` Noah Goldstein
2023-02-18 20:37 ` [RFC PATCH 8/9 gnumach] Add i386_fsgs_base_state Sergey Bugaev
2023-02-18 20:37 ` [RFC PATCH 9/9] hurd, htl: Add some more x86_64-specific code Sergey Bugaev
2023-02-20  0:30   ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230218203717.373211-8-bugaevc@gmail.com \
    --to=bugaevc@gmail.com \
    --cc=bug-hurd@gnu.org \
    --cc=flaviocruz@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).