* [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 @ 2004-12-19 5:11 John Reiser 2004-12-19 10:03 ` Hetz Ben Hamo 0 siblings, 1 reply; 10+ messages in thread From: John Reiser @ 2004-12-19 5:11 UTC (permalink / raw) To: qemu-devel In order to run qemu-snapshot-2004-12-17_23.tar.bz2 on: Fedora Core 3 kernel-2.6.8-1.681_FC3 i686 gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) glibc-2.3.3 binutils-2.15.92.0.2-5 I had to use the extra file and patch below. Otherwise I got very early SIGSEGVs. -----__restore.S [append __restore.o to VL_OBJS in i386/Makefile] #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 ----- --- vl.c.orig 2004-12-12 14:20:04.000000000 -0800 +++ vl.c 2004-12-18 20:53:09.496799856 -0800 @@ -882,6 +882,9 @@ #endif /* !defined(_WIN32) */ +extern void __restore(void); +extern void __restore_rt(void); + static void init_timers(void) { rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME); @@ -913,7 +916,9 @@ sigfillset(&act.sa_mask); act.sa_flags = 0; #if defined (TARGET_I386) && defined(USE_CODE_COPY) - act.sa_flags |= SA_ONSTACK; +#define SA_RESTORER 0x04000000 + act.sa_flags |= SA_ONSTACK | SA_RESTORER; + act.sa_restorer = __restore; #endif act.sa_handler = host_alarm_handler; sigaction(SIGALRM, &act, NULL); @@ -3402,7 +3407,8 @@ sigfillset(&act.sa_mask); act.sa_flags = SA_SIGINFO; #if defined (TARGET_I386) && defined(USE_CODE_COPY) - act.sa_flags |= SA_ONSTACK; + act.sa_flags |= SA_ONSTACK | SA_RESTORER; + act.sa_restorer = __restore_rt; #endif act.sa_sigaction = host_segv_handler; sigaction(SIGSEGV, &act, NULL); -- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 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 0 siblings, 1 reply; 10+ messages in thread From: Hetz Ben Hamo @ 2004-12-19 10:03 UTC (permalink / raw) To: qemu-devel Could you please re-send your patch, diffed, as an attachment please? Thanks, Hetz On Sat, 18 Dec 2004 21:11:00 -0800, John Reiser <jreiser@bitwagon.com> wrote: > In order to run qemu-snapshot-2004-12-17_23.tar.bz2 on: > Fedora Core 3 kernel-2.6.8-1.681_FC3 i686 > gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) > glibc-2.3.3 > binutils-2.15.92.0.2-5 > I had to use the extra file and patch below. > Otherwise I got very early SIGSEGVs. > > -----__restore.S [append __restore.o to VL_OBJS in i386/Makefile] > #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 > ----- > > --- vl.c.orig 2004-12-12 14:20:04.000000000 -0800 > +++ vl.c 2004-12-18 20:53:09.496799856 -0800 > @@ -882,6 +882,9 @@ > > #endif /* !defined(_WIN32) */ > > +extern void __restore(void); > +extern void __restore_rt(void); > + > static void init_timers(void) > { > rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME); > @@ -913,7 +916,9 @@ > sigfillset(&act.sa_mask); > act.sa_flags = 0; > #if defined (TARGET_I386) && defined(USE_CODE_COPY) > - act.sa_flags |= SA_ONSTACK; > +#define SA_RESTORER 0x04000000 > + act.sa_flags |= SA_ONSTACK | SA_RESTORER; > + act.sa_restorer = __restore; > #endif > act.sa_handler = host_alarm_handler; > sigaction(SIGALRM, &act, NULL); > @@ -3402,7 +3407,8 @@ > sigfillset(&act.sa_mask); > act.sa_flags = SA_SIGINFO; > #if defined (TARGET_I386) && defined(USE_CODE_COPY) > - act.sa_flags |= SA_ONSTACK; > + act.sa_flags |= SA_ONSTACK | SA_RESTORER; > + act.sa_restorer = __restore_rt; > #endif > act.sa_sigaction = host_segv_handler; > sigaction(SIGSEGV, &act, NULL); > > -- > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 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 0 siblings, 2 replies; 10+ messages in thread From: John Reiser @ 2004-12-19 13:55 UTC (permalink / raw) To: Hetz Ben Hamo, qemu-devel [-- Attachment #1: Type: text/plain, Size: 340 bytes --] > Could you please re-send your patch, diffed, as an attachment please? The important part of the original post was output from "diff -Naur". Does gmail mangle message bodies, or was the request due to the other small manual adjustments (non-patch) noted in the original post? Anyway, a 100% patch is attached for use by "patch -p1". -- [-- Attachment #2: SA_RESTORER.patch --] [-- Type: text/plain, Size: 2039 bytes --] --- ./vl.c.orig 2004-12-12 14:20:04.000000000 -0800 +++ ./vl.c 2004-12-19 05:49:53.323570312 -0800 @@ -882,6 +882,9 @@ #endif /* !defined(_WIN32) */ +extern void __restore(void); +extern void __restore_rt(void); + static void init_timers(void) { rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME); @@ -913,7 +916,9 @@ sigfillset(&act.sa_mask); act.sa_flags = 0; #if defined (TARGET_I386) && defined(USE_CODE_COPY) - act.sa_flags |= SA_ONSTACK; +#define SA_RESTORER 0x04000000 + act.sa_flags |= SA_ONSTACK | SA_RESTORER; + act.sa_restorer = __restore; #endif act.sa_handler = host_alarm_handler; sigaction(SIGALRM, &act, NULL); @@ -3402,7 +3407,8 @@ sigfillset(&act.sa_mask); act.sa_flags = SA_SIGINFO; #if defined (TARGET_I386) && defined(USE_CODE_COPY) - act.sa_flags |= SA_ONSTACK; + act.sa_flags |= SA_ONSTACK | SA_RESTORER; + act.sa_restorer = __restore_rt; #endif act.sa_sigaction = host_segv_handler; sigaction(SIGSEGV, &act, NULL); @@ -3449,6 +3455,7 @@ exit(1); } else { printf("Waiting gdb connection on port %d\n", gdbstub_port); +sleep(5); } } else #endif --- ./Makefile.target.orig 2004-12-12 08:56:30.000000000 -0800 +++ ./Makefile.target 2004-12-19 05:48:08.201551288 -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 --- ./__restore.S.orig 2004-12-19 05:44:53.832099936 -0800 +++ ./__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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 2004-12-19 13:55 ` John Reiser @ 2004-12-19 14:35 ` John Reiser 2004-12-19 22:47 ` Fabrice Bellard 1 sibling, 0 replies; 10+ messages in thread From: John Reiser @ 2004-12-19 14:35 UTC (permalink / raw) To: qemu-devel This optional part of the patch to vl.c: ----- @@ -3449,6 +3455,7 @@ exit(1); } else { printf("Waiting gdb connection on port %d\n", gdbstub_port); +sleep(5); } } else #endif ----- resulted from my misunderstanding of what qemu actually does. I interpreted "Waiting" as a synchronizing rendezvous blocking wait, while it seems that qemu is merely "Listening" without blocking. The difference is important to me because I want to observe the very first emulated instruction at hardware boot. For the moment, I have put an infinite loop there, then advance the instruction pointer by hand once the gdb connection is established. -- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 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 1 sibling, 1 reply; 10+ messages in thread From: Fabrice Bellard @ 2004-12-19 22:47 UTC (permalink / raw) To: qemu-devel 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". Fabrice. John Reiser wrote: >> Could you please re-send your patch, diffed, as an attachment please? > > > The important part of the original post was output from "diff -Naur". > Does gmail mangle message bodies, or was the request due to the > other small manual adjustments (non-patch) noted in the original post? > Anyway, a 100% patch is attached for use by "patch -p1". > > > ------------------------------------------------------------------------ > > --- ./vl.c.orig 2004-12-12 14:20:04.000000000 -0800 > +++ ./vl.c 2004-12-19 05:49:53.323570312 -0800 > @@ -882,6 +882,9 @@ > > #endif /* !defined(_WIN32) */ > > +extern void __restore(void); > +extern void __restore_rt(void); > + > static void init_timers(void) > { > rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME); > @@ -913,7 +916,9 @@ > sigfillset(&act.sa_mask); > act.sa_flags = 0; > #if defined (TARGET_I386) && defined(USE_CODE_COPY) > - act.sa_flags |= SA_ONSTACK; > +#define SA_RESTORER 0x04000000 > + act.sa_flags |= SA_ONSTACK | SA_RESTORER; > + act.sa_restorer = __restore; > #endif > act.sa_handler = host_alarm_handler; > sigaction(SIGALRM, &act, NULL); > @@ -3402,7 +3407,8 @@ > sigfillset(&act.sa_mask); > act.sa_flags = SA_SIGINFO; > #if defined (TARGET_I386) && defined(USE_CODE_COPY) > - act.sa_flags |= SA_ONSTACK; > + act.sa_flags |= SA_ONSTACK | SA_RESTORER; > + act.sa_restorer = __restore_rt; > #endif > act.sa_sigaction = host_segv_handler; > sigaction(SIGSEGV, &act, NULL); > @@ -3449,6 +3455,7 @@ > exit(1); > } else { > printf("Waiting gdb connection on port %d\n", gdbstub_port); > +sleep(5); > } > } else > #endif > --- ./Makefile.target.orig 2004-12-12 08:56:30.000000000 -0800 > +++ ./Makefile.target 2004-12-19 05:48:08.201551288 -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 > --- ./__restore.S.orig 2004-12-19 05:44:53.832099936 -0800 > +++ ./__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-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 2004-12-19 22:47 ` Fabrice Bellard @ 2004-12-20 0:54 ` John Reiser 2004-12-20 15:13 ` Johannes Schindelin 0 siblings, 1 reply; 10+ messages in thread From: John Reiser @ 2004-12-20 0:54 UTC (permalink / raw) To: qemu-devel [-- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 2004-12-20 0:54 ` John Reiser @ 2004-12-20 15:13 ` Johannes Schindelin 2004-12-20 15:48 ` John Reiser 0 siblings, 1 reply; 10+ messages in thread From: Johannes Schindelin @ 2004-12-20 15:13 UTC (permalink / raw) To: qemu-devel Hi, silly question: why don't you use inline assembly to make those two functions? Ciao, Dscho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 2004-12-20 15:13 ` Johannes Schindelin @ 2004-12-20 15:48 ` John Reiser 2004-12-22 6:55 ` Darrin Ritter 0 siblings, 1 reply; 10+ messages in thread From: John Reiser @ 2004-12-20 15:48 UTC (permalink / raw) To: qemu-devel > silly question: why don't you use inline assembly to make those two > functions? > The calls are not execution-time critical (fewer than 10 calls). They are complexity, platform, and developer-time critical. More time will be spent by developers and future maintainers than the total machine cycles spent executing the code, over all the machines in the world, ever. So making the developer+maintainer tasks simple and quick is more important than cycle- or byte-efficiency. -- ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 2004-12-20 15:48 ` John Reiser @ 2004-12-22 6:55 ` Darrin Ritter 2004-12-22 15:05 ` John Reiser 0 siblings, 1 reply; 10+ messages in thread From: Darrin Ritter @ 2004-12-22 6:55 UTC (permalink / raw) To: qemu-devel where can I d/l the source code with this patch as I am having problems running qemu on FC3 DV John Reiser wrote: >> silly question: why don't you use inline assembly to make those two >> functions? >> > > The calls are not execution-time critical (fewer than 10 calls). > They are complexity, platform, and developer-time critical. > More time will be spent by developers and future maintainers > than the total machine cycles spent executing the code, > over all the machines in the world, ever. So making the > developer+maintainer tasks simple and quick is more important > than cycle- or byte-efficiency. > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] qemu on Fedora Core 3 (Linux 2.6.9+), glibc-2.3.3 2004-12-22 6:55 ` Darrin Ritter @ 2004-12-22 15:05 ` John Reiser 0 siblings, 0 replies; 10+ messages in thread From: John Reiser @ 2004-12-22 15:05 UTC (permalink / raw) To: qemu-devel > where can I d/l the source code with this patch as I am having problems > running qemu on FC3 From the qemu home page http://fabrice.bellard.free.fr/qemu/ follow the Link "Pending patches" to http://www.dad-answers.com/qemu/ and choose http://www.dad-answers.com/qemu/qemu-snapshot-2004-12-21_23.tar.bz2 The patch (your choice of 2) is in another message of this current thread of this mailing list. If necessary, see the archive at http://lists.gnu.org/archive/html/qemu-devel/2004-12/threads.html -- ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2004-12-22 15:28 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).