From patchwork Wed Nov 2 16:40:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9409493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4DC860721 for ; Wed, 2 Nov 2016 16:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97ECC2A471 for ; Wed, 2 Nov 2016 16:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CCF32A475; Wed, 2 Nov 2016 16:41:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3847B2A471 for ; Wed, 2 Nov 2016 16:41:03 +0000 (UTC) Received: from localhost ([::1]:56353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1yb0-0005H9-Hw for patchwork-qemu-devel@patchwork.kernel.org; Wed, 02 Nov 2016 12:41:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1yaG-0004vU-Qb for qemu-devel@nongnu.org; Wed, 02 Nov 2016 12:40:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1yaB-00035D-Tk for qemu-devel@nongnu.org; Wed, 02 Nov 2016 12:40:16 -0400 Received: from mail-yw0-x244.google.com ([2607:f8b0:4002:c05::244]:36636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1yaB-00034t-MV for qemu-devel@nongnu.org; Wed, 02 Nov 2016 12:40:11 -0400 Received: by mail-yw0-x244.google.com with SMTP id r204so701226ywb.3 for ; Wed, 02 Nov 2016 09:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6nvyBScHki7gCfxrM106CV+tn/FOuHtsC412BlDoWPo=; b=O+5+shB+MDNdCnw1qyJUFQ+aXrFQrBIRXPJgrB3dhE4/v2I0PAkVUvVKY017CmOgyr xRh4ZFiADLXNgAuIWeKf/YeulF5XWFyIoVmaLqgDP1Xw7XZuxHr8YTQZyiKodGyxI+PW OB/xIlwadjSNSUUhv1LsUQv8wo9/B6yBo5rfVc+/1xqLjxZ5oj186TnORvIMtsbPgLmc Q9/qWnhjyeAC5Mh+wU+KFTfEfIiEZdR7nPqVCyPT62oAoFRHGtOiVz3NXyL4w/KserOt x9yHqvaTvLsGs//1MIYKSaxI+8m6whZBY6nGnvKlEjAakbsC54oGzPrtXGgaO+o9vxMK PLYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6nvyBScHki7gCfxrM106CV+tn/FOuHtsC412BlDoWPo=; b=dA4UtQcH8wkgc6uQK3RRocHARXLB4Xs25jjYg2L/OTZ/c9r/jwpLcWK4+CPFKyv9eJ egr53+eKDGvuZQGsrEzyfAJSjzILBZfIUNcxBPhXd054GhG71687iwNKDXnutdeE0XSL pNtmGLC6Nlb9gJnNffsgPwzRLJuCgunG0H2WogNNNZvAqnlXYcM48tGyPjQkEpfaUvF4 S+X5AGCsojY6CVAWyfmgrE/1/5jaAYLcvMTpG+Ty5AWzX+fyv3Gdhs0EFgoAcmR4jyLs Ti8Tuck78+zmuy28pdN+s/XqpJaklV+RwGDsIQeWLcWKsvINuo9p6uH4wuLT0jYW7qn3 OkOA== X-Gm-Message-State: ABUngvfWoYmSx4jnfDpyvX3hirKw6vxPUJ212Aw8IlVx/m+qNx96o8nZCDRW6+dnPsu0FA== X-Received: by 10.13.195.1 with SMTP id f1mr3713300ywd.354.1478104810299; Wed, 02 Nov 2016 09:40:10 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id u12sm832048ywf.37.2016.11.02.09.40.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Nov 2016 09:40:09 -0700 (PDT) From: Pranith Kumar To: qemu-devel@nongnu.org, alex.bennee@linaro.org Date: Wed, 2 Nov 2016 12:40:08 -0400 Message-Id: <20161102164008.28401-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161102142559.23395-1-bobby.prani@gmail.com> References: <20161102142559.23395-1-bobby.prani@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::244 Subject: [Qemu-devel] [PATCH v2] mttcg: Handle EXCP_ATOMIC exception 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: pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- cpus.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpus.c b/cpus.c index 8f98060..299ce7e 100644 --- a/cpus.c +++ b/cpus.c @@ -1315,6 +1315,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) { @@ -1385,6 +1390,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;