qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] coroutine-ucontext broken for x86-32
@ 2012-05-08 19:35 Jan Kiszka
  2012-05-09  7:32 ` Michael Tokarev
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jan Kiszka @ 2012-05-08 19:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Anthony Liguori, Michael Tokarev

Hi,

I hunted down a fairly subtle corruption of the VCPU thread signal mask
in KVM mode when using the ucontext version of coroutines:

coroutine_new calls getcontext, makecontext, swapcontext. Those
functions get/set also the signal mask of the caller. Unfortunately,
they only use the sigprocmask syscall on i386, not the rt_sigprocmask
version. So they do not properly save/restore the blocked RT signals,
namely our SIG_IPI - it becomes unblocke this way. And this will sooner
or later make the kernel actually deliver a SIG_IPI to our
dummy_handler, and we miss a wakeup, which means losing control over
VCPU thread - qemu hangs.

I was able to reproduce the issue very reliably with virtio-block
enabled, 32-bit qemu userspace on a 64-bit host, using a 32-bit WinXP
guest.

Simple workaround:

diff --git a/main-loop.h b/main-loop.h
index c06b8bc..dce1cd9 100644
--- a/main-loop.h
+++ b/main-loop.h
@@ -25,11 +25,7 @@
 #ifndef QEMU_MAIN_LOOP_H
 #define QEMU_MAIN_LOOP_H 1
 
-#ifdef SIGRTMIN
-#define SIG_IPI (SIGRTMIN+4)
-#else
 #define SIG_IPI SIGUSR1
-#endif
 
 /**
  * qemu_init_main_loop: Set up the process so that it can run the main loop.


But maybe someone has a better idea, ie. something that addresses the
issue at the root. Otherwise we would have to erect large warning signs:
"Do not use RT signals! Coroutines will break them for you."

Michael, maybe this also relates to the issue you saw. I'm not able to
reproduce any VAPIC problems after make Windows bootable by switching
to SIGUSR1.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

end of thread, other threads:[~2012-05-09 18:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-08 19:35 [Qemu-devel] coroutine-ucontext broken for x86-32 Jan Kiszka
2012-05-09  7:32 ` Michael Tokarev
2012-05-09 11:12   ` Jan Kiszka
2012-05-09 10:11 ` Kevin Wolf
2012-05-09 10:55   ` Jan Kiszka
2012-05-09 11:15   ` Peter Maydell
2012-05-09 11:38     ` Jan Kiszka
2012-05-09 17:17       ` Anthony Liguori
2012-05-09 17:25         ` Jan Kiszka
2012-05-09 17:31           ` Anthony Liguori
2012-05-09 18:21             ` Jan Kiszka
2012-05-09 14:37     ` Avi Kivity
2012-05-09 18:05 ` Michael Tokarev

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).