qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3


From: John Reiser
Subject: Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3
Date: Sun, 19 Dec 2004 16:54:08 -0800
User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

Fabrice Bellard wrote:
Can you move the restorer patch in osdep.c:qemu_sigaction() ? I see no reason to do it in vl.c. Moreover, you should do it only for "qemu-fast".

The attached patch moves the changes out of vl.c and into osdep.c.
But the easiest and clearest code requires removing the 'const' attribute
for the new struct qemu_sigaction *.  This is OK because the only callers
are internal, and use temporary struct qemu_sigaction anyway.  To insist
on keeping the 'const' requires qemu_sigaction to perform a copy before
making the modifications for SA_RESTORER and .sa_restorer, and to pass
a pointer to the copy as the argument to the syscall.  If you want
that, then just copy the implementation out of glibc-2.3.

It seems to me that the restorer actions must apply to all qemu_sigaction
for Linux 2.6.x.  If restricted to qemu-fast only, then only qemu-fast
will work correctly; the other cases will get SIGSEGV upon return from
the corresponding signal handlers.  Why should qemu-fast be a special case?

--
--- qemu-snapshot-2004-12-17_23/Makefile.target.orig    2004-12-12 
08:56:30.000000000 -0800
+++ qemu-snapshot-2004-12-17_23/Makefile.target 2004-12-19 05:48:08.000000000 
-0800
@@ -264,7 +264,7 @@
 endif
 
 # must use static linking to avoid leaving stuff in virtual address space
-VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o 
+VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o  __restore.o
 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
 
 SOUND_HW = sb16.o
--- qemu-snapshot-2004-12-17_23/__restore.S.orig        2004-12-19 
05:44:53.000000000 -0800
+++ qemu-snapshot-2004-12-17_23/__restore.S     2004-12-18 20:34:14.000000000 
-0800
@@ -0,0 +1,10 @@
+#include <asm/unistd.h>
+
+__restore: .globl __restore
+       pop %eax
+       movl $ __NR_sigreturn,%eax
+       int $0x80
+
+__restore_rt: .globl __restore_rt
+       movl $ __NR_rt_sigreturn,%eax
+       int $0x80
--- qemu-snapshot-2004-12-17_23/osdep.c.orig    2004-08-03 15:09:30.000000000 
-0700
+++ qemu-snapshot-2004-12-17_23/osdep.c 2004-12-19 15:44:08.000000000 -0800
@@ -153,9 +153,25 @@
     QEMU_SYSCALL4(rt_sigaction, signum, act, oldact, sigsetsize);
 }
 
-int qemu_sigaction(int signum, const struct qemu_sigaction *act, 
+int qemu_sigaction(int signum, struct qemu_sigaction *act, 
                    struct qemu_sigaction *oldact)
 {
+#define SA_RESTORER   0x04000000
+    if (!(act->sa_flags & SA_RESTORER)) {
+        /* Required for Linux 2.6.x "no-exec stack": kernel does not
+         * push trampoline instructions for handler return,
+         * so user-mode code must supply the correct .sa_restorer.
+         */
+        extern void __restore(void);
+        extern void __restore_rt(void);
+        act->sa_flags |= SA_RESTORER;
+        if (act->sa_flags & SA_SIGINFO) {
+            act->sa_restorer = __restore_rt;
+        }
+        else {
+            act->sa_restorer = __restore;
+        }
+    }
     return kernel_sigaction(signum, act, oldact, 8);
 }
 
--- qemu-snapshot-2004-12-17_23/osdep.h.orig    2004-08-03 15:09:30.000000000 
-0700
+++ qemu-snapshot-2004-12-17_23/osdep.h 2004-12-19 15:43:54.000000000 -0800
@@ -35,7 +35,7 @@
     sigset_t sa_mask;          /* mask last for extensibility */
 };
 
-int qemu_sigaction(int signum, const struct qemu_sigaction *act, 
+int qemu_sigaction(int signum, struct qemu_sigaction *act, 
                    struct qemu_sigaction *oldact);
 
 #undef sigaction

reply via email to

[Prev in Thread] Current Thread [Next in Thread]