All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] [PATCH] Early x86_64 crash
@ 2005-09-29 16:16 Jeff Dike
  2005-09-30 14:41 ` Blaisorblade
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Dike @ 2005-09-29 16:16 UTC (permalink / raw)
  To: user-mode-linux-devel

If you are running UML/x86_64 and are seeing it crash before starting init,
I'd like you to do the following:
	- 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

Index: test/arch/um/sys-x86_64/stub_segv.c
===================================================================
--- test.orig/arch/um/sys-x86_64/stub_segv.c	2005-09-29 12:19:07.000000000 -0400
+++ test/arch/um/sys-x86_64/stub_segv.c	2005-09-29 12:21:03.000000000 -0400
@@ -11,6 +11,16 @@
 #include "sysdep/sigcontext.h"
 #include "sysdep/faultinfo.h"
 
+/* Copied from sys-x86_64/signal.c - Can't find an equivalent definition
+ * in the libc headers anywhere.
+ */
+struct rt_sigframe
+{
+        char *pretcode;
+        struct ucontext uc;
+        struct siginfo info;
+};
+
 void __attribute__ ((__section__ (".__syscall_stub")))
 stub_segv_handler(int sig)
 {
@@ -22,11 +32,14 @@
 
 	__asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
 	__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");
+	/* 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));
 }


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH] Early x86_64 crash
  2005-09-29 16:16 [uml-devel] [PATCH] Early x86_64 crash Jeff Dike
@ 2005-09-30 14:41 ` Blaisorblade
  2005-10-02  2:35   ` Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: Blaisorblade @ 2005-09-30 14:41 UTC (permalink / raw)
  To: user-mode-linux-devel; +Cc: Jeff Dike

[-- 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");
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH] Early x86_64 crash
  2005-09-30 14:41 ` Blaisorblade
@ 2005-10-02  2:35   ` Jeff Dike
  2005-10-02 15:23     ` Blaisorblade
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Dike @ 2005-10-02  2:35 UTC (permalink / raw)
  To: Blaisorblade; +Cc: user-mode-linux-devel

On Fri, Sep 30, 2005 at 04:41:58PM +0200, Blaisorblade wrote:
> I assume you've been able to reproduce this crash and see this patch fix it, 
> right?

Yup.

> I've attached the addon with additional clobber, and with fixed tabs (i.e. 
> hardtabs). Not compiled it (no time to reboot right now).

Yeah, I'll fix the spacing in my copy.

				Jeff


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [uml-devel] [PATCH] Early x86_64 crash
  2005-10-02  2:35   ` Jeff Dike
@ 2005-10-02 15:23     ` Blaisorblade
  0 siblings, 0 replies; 4+ messages in thread
From: Blaisorblade @ 2005-10-02 15:23 UTC (permalink / raw)
  To: Jeff Dike; +Cc: user-mode-linux-devel

On Sunday 02 October 2005 04:35, Jeff Dike wrote:
> On Fri, Sep 30, 2005 at 04:41:58PM +0200, Blaisorblade wrote:
> > I assume you've been able to reproduce this crash and see this patch fix
> > it, right?

> Yup.

> > I've attached the addon with additional clobber, and with fixed tabs
> > (i.e. hardtabs). Not compiled it (no time to reboot right now).

> Yeah, I'll fix the spacing in my copy.

I'm assuming the additional clobbers are ok, and queuing the whole in -bs3.
-- 
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


		
___________________________________ 
Yahoo! Messenger: chiamate gratuite in tutto il mondo 
http://it.messenger.yahoo.com



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-02 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-29 16:16 [uml-devel] [PATCH] Early x86_64 crash Jeff Dike
2005-09-30 14:41 ` Blaisorblade
2005-10-02  2:35   ` Jeff Dike
2005-10-02 15:23     ` Blaisorblade

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.