qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: TeLeMan <geleman@gmail.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp
Date: Sat, 02 Jul 2011 09:50:51 +0200	[thread overview]
Message-ID: <4E0ECDDB.9030001@web.de> (raw)
In-Reply-To: <BANLkTimW27g3rE4a30vr1T10XccQEAi+sA@mail.gmail.com>

From: Jan Kiszka <jan.kiszka@siemens.com>

Recent compilers look deep into cpu_exec, find longjmp as a noreturn
function and decide to smash some stack variables as they won't be used
again. This may lead to env becoming invalid after return from setjmp,
causing crashes. Fix it by reloading env from cpu_single_env in that
case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 cpu-exec.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 20e3ec4..de0d716 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -587,6 +587,10 @@ int cpu_exec(CPUState *env)
                 /* reset soft MMU for next block (it can currently
                    only be set by a memory fault) */
             } /* for(;;) */
+        } else {
+            /* Reload env after longjmp - the compiler may have smashed all
+             * local variables as longjmp is marked 'noreturn'. */
+            env = cpu_single_env;
         }
     } /* for(;;) */
 

  reply	other threads:[~2011-07-02  7:50 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     ` Jan Kiszka [this message]
2011-07-02  9:08       ` [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp 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

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=4E0ECDDB.9030001@web.de \
    --to=jan.kiszka@web.de \
    --cc=blauwirbel@gmail.com \
    --cc=geleman@gmail.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 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).