linux-um archives
 help / color / mirror / Atom feed
From: Blaisorblade <blaisorblade@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Jeff Dike <jdike@addtoit.com>
Subject: Re: [uml-devel] [PATCH] Early x86_64 crash
Date: Fri, 30 Sep 2005 16:41:58 +0200	[thread overview]
Message-ID: <200509301641.59585.blaisorblade@yahoo.it> (raw)
In-Reply-To: <20050929161617.GA30460@ccure.user-mode-linux.org>

[-- Attachment #1: Type: text/plain, Size: 2076 bytes --]

On Thursday 29 September 2005 18:16, Jeff Dike wrote:
> If you are running UML/x86_64 and are seeing it crash before starting init,
> I'd like you to do the following:
I assume you've been able to reproduce this crash and see this patch fix it, 
right?

I'm going to take it for -bs3, meanwhile, as soon as you answer on the 
attachment (I'd like it at least to compile).
> 	- make sure that you have CONFIG_FRAME_POINTER disabled
> 	- enable it and see that UML boots
> 	- apply the patch below, disable CONFIG_FRAME_POINTER again, and
> see if UML still boots
> 	- report results back to me

> 				Jeff

> @@ -22,11 +32,14 @@
>
>  	__asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
Why there's no "%rax" in the register clobber list, here and at the end?
>  	__asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;"
> -		"syscall": : "g" (__NR_kill), "g" (SIGUSR1));
> -	/* Two popqs to restore the stack to the state just before entering
> -	 * the handler, one pops the return address, the other pops the frame
> -	 * pointer.
> +		"syscall": : "g" (__NR_kill), "g" (SIGUSR1) :
> +                "%rdi", "%rax", "%rsi");
Here you're correctly informing GCC that your asm uses these regs.
> +	/* sys_sigreturn expects that the stack pointer will be 8 bytes into
> +	 * the signal frame.  So, we use the ucontext pointer, which we know
> +	 * already, to get the signal frame pointer, and add 8 to that.
>  	 */
> -	__asm__("popq %%rax ; popq %%rax ; movq %0, %%rax ; syscall" : : "g"
> -		(__NR_rt_sigreturn));
> +        __asm__("movq %0, %%rsp": :
> +                "g" ((unsigned long) container_of(uc, struct rt_sigframe,
> +						  uc) + 8));
> +	__asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn));
>  }
I've attached the addon with additional clobber, and with fixed tabs (i.e. 
hardtabs). Not compiled it (no time to reboot right now).
-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

[-- Attachment #2: uml-early-x86-64-crash-fix --]
[-- Type: text/x-diff, Size: 1408 bytes --]

Index: linux-2.6.13/arch/um/sys-x86_64/stub_segv.c
===================================================================
--- linux-2.6.13.orig/arch/um/sys-x86_64/stub_segv.c
+++ linux-2.6.13/arch/um/sys-x86_64/stub_segv.c
@@ -25,20 +25,20 @@ stub_segv_handler(int sig)
 {
 	struct ucontext *uc;
 
-	__asm__("movq %%rdx, %0" : "=g" (uc) :);
+	__asm__("movq %%rdx, %0" : "=g" (uc) : );
         GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
                               &uc->uc_mcontext);
 
-	__asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
+	__asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid) : "%rax");
 	__asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;"
 		"syscall": : "g" (__NR_kill), "g" (SIGUSR1) :
-                "%rdi", "%rax", "%rsi");
+		"%rdi", "%rax", "%rsi");
 	/* sys_sigreturn expects that the stack pointer will be 8 bytes into
 	 * the signal frame.  So, we use the ucontext pointer, which we know
 	 * already, to get the signal frame pointer, and add 8 to that.
 	 */
-        __asm__("movq %0, %%rsp": :
-                "g" ((unsigned long) container_of(uc, struct rt_sigframe,
+	__asm__("movq %0, %%rsp": :
+		"g" ((unsigned long) container_of(uc, struct rt_sigframe,
 						  uc) + 8));
-	__asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn));
+	__asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn) : "%rax");
 }

  reply	other threads:[~2005-10-02 17:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-29 16:16 [uml-devel] [PATCH] Early x86_64 crash Jeff Dike
2005-09-30 14:41 ` Blaisorblade [this message]
2005-10-02  2:35   ` Jeff Dike
2005-10-02 15:23     ` Blaisorblade

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=200509301641.59585.blaisorblade@yahoo.it \
    --to=blaisorblade@yahoo.it \
    --cc=jdike@addtoit.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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