From patchwork Thu Feb 9 17:08:52 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: 93755 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp114380qgi; Thu, 9 Feb 2017 09:37:39 -0800 (PST) X-Received: by 10.55.73.211 with SMTP id w202mr3886919qka.321.1486661859052; Thu, 09 Feb 2017 09:37:39 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o16si8494885qto.270.2017.02.09.09.37.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Feb 2017 09:37:39 -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]:39350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbsf2-0006me-RS for patch@linaro.org; Thu, 09 Feb 2017 12:37:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbsDW-0006N8-5s for qemu-devel@nongnu.org; Thu, 09 Feb 2017 12:09:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbsDS-0002Ty-3q for qemu-devel@nongnu.org; Thu, 09 Feb 2017 12:09:10 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:36361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbsDR-0002TK-RQ for qemu-devel@nongnu.org; Thu, 09 Feb 2017 12:09:06 -0500 Received: by mail-wm0-x231.google.com with SMTP id c85so237592388wmi.1 for ; Thu, 09 Feb 2017 09:09:05 -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=98HcdahgGwd2IWThoaPYm5A8cuS8vwnveVFO1pvuZZ8=; b=X5XD9dQM6YICQd4K9+EFH04Ob6g7O3r910FbPwjw8v9ZXUUac1WwZBZy0MEbV6nf8b IS3aeHMWu9mERA03/6KRK2Pi4GoRhWQqcb/7CyF2cmFq4Cn0z2jldH6/kymCeZtZS9Wd zBiNX9uFMVMXdbnOqYnT2nNREKu8B1wGNeGWk= 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=98HcdahgGwd2IWThoaPYm5A8cuS8vwnveVFO1pvuZZ8=; b=rE+EQI801vtHzFHMZSRAcR8KQ+4Z2CWqgJGqd0ufPE9B5eWEyv3RTdFx+b7T3r2XrT Nr+vLQylekS807UBQfyR4Wia+MqPEeLic6qMxuT0ArJqj1MEFBpBh8oepG3uacw1K9cy 9x4Px36tNZ7I3vl59/x+TZEpDhl/9Bq7t7iIrmkPfbVVTouQD5HnujZoAH5EvX7rUjJy o114OO8CEJoL3HTXXfeHocZDWciM4HrgKxGVLLR7AsOTpI9w0m2tnWAvr6/nfe+HIl8X lCFFQe00mf6ApB9O0U+0bYrozQDYNA+2vGothObqRXKvrW8XW1eboK44jvXkNyc61yN5 OL5g== X-Gm-Message-State: AMke39n7+bIPcWKVEEUvqI/xK7hAjXVLvWK/UQg9BJAw7usSjFVugFSniLrCdoK78/h75P+o X-Received: by 10.223.136.197 with SMTP id g5mr3717033wrg.56.1486660144902; Thu, 09 Feb 2017 09:09:04 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z67sm19451222wrb.49.2017.02.09.09.08.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 09:08:58 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B47583E2D63; Thu, 9 Feb 2017 17:09:05 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net Date: Thu, 9 Feb 2017 17:08:52 +0000 Message-Id: <20170209170904.5713-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170209170904.5713-1-alex.bennee@linaro.org> References: <20170209170904.5713-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:c09::231 Subject: [Qemu-devel] [PATCH v11 12/24] 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 25897edbd3..cb44544fcf 100644 --- a/cpus.c +++ b/cpus.c @@ -1347,6 +1347,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) { @@ -1457,6 +1462,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;