All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Blue Swirl <blauwirbel@gmail.com>, TeLeMan <geleman@gmail.com>,
	Jan Kiszka <jan.kiszka@web.de>,
	qemu-devel <qemu-devel@nongnu.org>,
	David Gilbert <david.gilbert@linaro.org>
Subject: Re: [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp
Date: Thu, 11 Aug 2011 16:32:40 +0200	[thread overview]
Message-ID: <4E43E808.4090100@redhat.com> (raw)
In-Reply-To: <CAFEAcA_Mq_fF7rKA89LByKG5_Qk3MFAJa_XeNk_SPpKwSS=ySw@mail.gmail.com>

On 08/11/2011 04:24 PM, Peter Maydell wrote:
>> I cannot think off-hand of a reason why thread-local cpu_single_env should
>> not work for iothread under Unix, BTW.  Since cpu_single_env is only
>> set/used by a thread at a time (under the global lock), its users cannot
>> distinguish between a thread-local variable and a global.
>
> Thanks for the clarification. As you say, as long as we don't ever
> try to access it from another thread we're fine...

Yes, and the current usage of the lock should be enough of a guarantee.

>> The only problem would be Windows, which runs cpu_signal in a thread
>> different than the CPU thread.  But that can be fixed easily in
>> qemu_cpu_kick_thread.
>
> ...and we just need to fix this.

Untested (uncompiled) patch follows:

diff --git a/cpus.c b/cpus.c
index 6bf4e3f..04e52fe 100644
--- a/cpus.c
+++ b/cpus.c
@@ -179,10 +179,10 @@ static void cpu_handle_guest_debug(CPUState *env)
  }

  #ifdef CONFIG_IOTHREAD
-static void cpu_signal(int sig)
+static inline void do_cpu_kick(CPUState *env)
  {
-    if (cpu_single_env) {
-        cpu_exit(cpu_single_env);
+    if (env) {
+        cpu_exit(env);
      }
      exit_request = 1;
  }
@@ -476,6 +476,13 @@ static void qemu_kvm_init_cpu_signals(CPUState *env)
      }
  }

+#ifdef CONFIG_IOTHREAD
+static void cpu_signal(int sig)
+{
+    do_cpu_kick(cpu_single_env);
+}
+#endif
+
  static void qemu_tcg_init_cpu_signals(void)
  {
  #ifdef CONFIG_IOTHREAD
@@ -858,7 +865,7 @@ static void qemu_cpu_kick_thread(CPUState *env)
  #else /* _WIN32 */
      if (!qemu_cpu_is_self(env)) {
          SuspendThread(env->thread->thread);
-        cpu_signal(0);
+        do_cpu_kick(env);
          ResumeThread(env->thread->thread);
      }
  #endif

      reply	other threads:[~2011-08-11 14:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 16:47 [Qemu-devel] "cpu-exec.c: avoid AREG0 use" breaks x86 emulation on x86-64 Jan Kiszka
2011-06-30 21:17 ` Stefan Weil
2011-07-01  1:44 ` TeLeMan
2011-07-01 20:15   ` Blue Swirl
2011-07-02  7:50     ` [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp Jan Kiszka
2011-07-02  9:08       ` Blue Swirl
2011-07-02  9:43         ` Jan Kiszka
2011-07-03 14:09           ` Paolo Bonzini
2011-07-12 20:56       ` Blue Swirl
2011-08-11 11:30       ` Peter Maydell
2011-08-11 12:16         ` Paolo Bonzini
2011-08-11 12:40           ` Peter Maydell
2011-08-11 13:13             ` Paolo Bonzini
2011-08-11 13:31               ` Peter Maydell
2011-08-11 14:10                 ` Paolo Bonzini
2011-08-11 14:12                   ` David Gilbert
2011-08-11 14:24                   ` Peter Maydell
2011-08-11 14:32                     ` Paolo Bonzini [this message]

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=4E43E808.4090100@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=david.gilbert@linaro.org \
    --cc=geleman@gmail.com \
    --cc=jan.kiszka@web.de \
    --cc=peter.maydell@linaro.org \
    --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.