From: John Reiser <jreiser@BitWagon.com>
To: qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <41C622B0.8040903@BitWagon.com> (raw)
In-Reply-To: <41C604F0.30601@bellard.org>
[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]
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?
--
[-- Attachment #2: SA_RESTORER-osdep.patch --]
[-- Type: text/plain, Size: 2411 bytes --]
--- 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
next prev parent reply other threads:[~2004-12-20 1:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-19 5:11 [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 John Reiser
2004-12-19 10:03 ` Hetz Ben Hamo
2004-12-19 13:55 ` John Reiser
2004-12-19 14:35 ` John Reiser
2004-12-19 22:47 ` Fabrice Bellard
2004-12-20 0:54 ` John Reiser [this message]
2004-12-20 15:13 ` Johannes Schindelin
2004-12-20 15:48 ` John Reiser
2004-12-22 6:55 ` Darrin Ritter
2004-12-22 15:05 ` John Reiser
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=41C622B0.8040903@BitWagon.com \
--to=jreiser@bitwagon.com \
--cc=qemu-devel@nongnu.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 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.