qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	alistair.francis@xilinx.com
Subject: [Qemu-devel] [RFC PATCH] cpus: Don't kick un-inited cpus.
Date: Wed, 18 Mar 2015 05:53:52 -0700	[thread overview]
Message-ID: <1426683232-8847-1-git-send-email-peter.crosthwaite@xilinx.com> (raw)

following a464982499b2f637f6699e3d03e0a9d2e0b5288b, it's now possible for
there to be attempts to take the BQL before CPUs have been realized in
cases where a machine model inits peripherals before the first CPU.

BQL lock aquisition kicks the first_cpu, leading to a segfault if this
happens pre-realize. Guard the CPU kick routine to perform no action for
a CPU that doesn't exist or doesn't have a thread yet.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
 cpus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cpus.c b/cpus.c
index 1ce90a1..c90dfa8 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1046,6 +1046,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
 
 static void qemu_cpu_kick_thread(CPUState *cpu)
 {
+    if (!cpu || !cpu->thread) {
+        return;
+    }
+
 #ifndef _WIN32
     int err;
 
-- 
2.3.1.2.g90df61e.dirty

             reply	other threads:[~2015-03-18 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18 12:53 Peter Crosthwaite [this message]
2015-03-18 13:10 ` [Qemu-devel] [RFC PATCH] cpus: Don't kick un-inited cpus 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=1426683232-8847-1-git-send-email-peter.crosthwaite@xilinx.com \
    --to=peter.crosthwaite@xilinx.com \
    --cc=alistair.francis@xilinx.com \
    --cc=pbonzini@redhat.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).