From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CgC8b-0007EE-Ts for qemu-devel@nongnu.org; Sun, 19 Dec 2004 20:15:02 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CgC8b-0007Dr-1H for qemu-devel@nongnu.org; Sun, 19 Dec 2004 20:15:01 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CgC8a-0007Dk-Eg for qemu-devel@nongnu.org; Sun, 19 Dec 2004 20:15:00 -0500 Received: from [216.99.193.136] (helo=jade.spiritone.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CgBpL-0003fW-C9 for qemu-devel@nongnu.org; Sun, 19 Dec 2004 19:55:07 -0500 Received: from [192.168.0.2] (216-99-213-225.dsl.aracnet.com [216.99.213.225]) (authenticated bits=0) by jade.spiritone.com (8.12.8/8.12.8) with ESMTP id iBK0t5MD017259 for ; Sun, 19 Dec 2004 16:55:05 -0800 Message-ID: <41C622B0.8040903@BitWagon.com> Date: Sun, 19 Dec 2004 16:54:08 -0800 From: John Reiser MIME-Version: 1.0 Subject: Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 References: <41C50D64.7070209@BitWagon.com> <41e41e7a04121902033c7a42ee@mail.gmail.com> <41C58841.4060008@BitWagon.com> <41C604F0.30601@bellard.org> In-Reply-To: <41C604F0.30601@bellard.org> Content-Type: multipart/mixed; boundary="------------030702060000010608020603" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------030702060000010608020603 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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? -- --------------030702060000010608020603 Content-Type: text/plain; name="SA_RESTORER-osdep.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="SA_RESTORER-osdep.patch" --- 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 + +__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 --------------030702060000010608020603--