From patchwork Mon Feb 6 15:31:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 93450 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1759241qgi; Mon, 6 Feb 2017 07:43:15 -0800 (PST) X-Received: by 10.55.16.11 with SMTP id a11mr11277904qkh.3.1486395795071; Mon, 06 Feb 2017 07:43:15 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o99si751356qkh.54.2017.02.06.07.43.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 06 Feb 2017 07:43:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1calRi-0006PI-JM for patch@linaro.org; Mon, 06 Feb 2017 10:43:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1calGB-0005qF-I8 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 10:31:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1calG9-0008Vk-Mj for qemu-devel@nongnu.org; Mon, 06 Feb 2017 10:31:19 -0500 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:35731) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1calG9-0008VW-Hj for qemu-devel@nongnu.org; Mon, 06 Feb 2017 10:31:17 -0500 Received: by mail-wr0-x22d.google.com with SMTP id 89so23879212wrr.2 for ; Mon, 06 Feb 2017 07:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7BgUCFZT7wAW/7IhYEyUHTAm9rGX5g+bA7sbnKP7dMM=; b=YwwYjvrju3kExxD7FxBVfLSGLNUbFnlEoCv9xzyZ3yC/cGfyov29IwjKdTWFHIUCda 3Jb4+3Sqa//QedEO0Tc8cGeV8i0TMDgc3wgukrJo+Vda2Y2KVSi5yLSNalpYwcQoQJt9 3oSmfFhXgVzSpq6IQm+mdoHQvGVA8eCd8IybA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7BgUCFZT7wAW/7IhYEyUHTAm9rGX5g+bA7sbnKP7dMM=; b=XOtosOWISlwVnwZDTsa/kzdCl57Ei8t6RTYOyRwMx7s5iAPPZxx1uJknz2YvBDlX4w RVFiSl1xnLMw011/iwaZE2ZG1+Aw0qksIYOcRLJjDGcQB1eaSOhg3pZT1so6d/lgQQB8 wCGRLbFaUHc/SHAXasnhcOt0E6OC9R02X6CeH4BzOXT9oHPSw0JttCljh8iwyXmEKRlH hVgGn6mbN4ecirfOJ/JFHD72gs+onz0+1hasllERWz2wc0jiagUWNULkJnTG/0emFMF1 IZEaHx0SWfyiDXTN0r2OQlX4RFrg9pm5Jv09zJZU+As1A2scP/UjjbykwdWOfjVoMVw4 i8iQ== X-Gm-Message-State: AIkVDXIO7GVaSXOXoXSeDWdBbFQkiamGZmrO3/3VreOwqDnAra4j9z3glnjAdBlcm2XirG7R X-Received: by 10.223.152.2 with SMTP id v2mr10079942wrb.109.1486395076429; Mon, 06 Feb 2017 07:31:16 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q1sm13546531wmd.6.2017.02.06.07.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 07:31:13 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 87DC73E2A2C; Mon, 6 Feb 2017 15:31:14 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net Date: Mon, 6 Feb 2017 15:31:02 +0000 Message-Id: <20170206153113.27729-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170206153113.27729-1-alex.bennee@linaro.org> References: <20170206153113.27729-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PATCH v10 12/23] tcg: handle EXCP_ATOMIC exception for system emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@listserver.greensocs.com, nikunj@linux.vnet.ibm.com, Peter Crosthwaite , jan.kiszka@siemens.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, serge.fdrv@gmail.com, pbonzini@redhat.com, bobby.prani@gmail.com, =?utf-8?q?Alex_Benn=C3=A9e?= , bamvor.zhangjian@linaro.org, fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Pranith Kumar The patch enables handling atomic code in the guest. This should be preferably done in cpu_handle_exception(), but the current assumptions regarding when we can execute atomic sections cause a deadlock. Signed-off-by: Pranith Kumar [AJB: tweak title] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- cpus.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.11.0 diff --git a/cpus.c b/cpus.c index 1f0e2be18f..e1b82bcd49 100644 --- a/cpus.c +++ b/cpus.c @@ -1346,6 +1346,11 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) if (r == EXCP_DEBUG) { cpu_handle_guest_debug(cpu); break; + } else if (r == EXCP_ATOMIC) { + qemu_mutex_unlock_iothread(); + cpu_exec_step_atomic(cpu); + qemu_mutex_lock_iothread(); + break; } } else if (cpu->stop) { if (cpu->unplug) { @@ -1456,6 +1461,10 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) */ g_assert(cpu->halted); break; + case EXCP_ATOMIC: + qemu_mutex_unlock_iothread(); + cpu_exec_step_atomic(cpu); + qemu_mutex_lock_iothread(); default: /* Ignore everything else? */ break;