From patchwork Thu Feb 23 18:29:13 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: 731671 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vTjp86nqLz9s7R for ; Fri, 24 Feb 2017 05:44:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DG4oMXUb"; dkim-atps=neutral Received: from localhost ([::1]:60262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgyNi-0002ox-Bo for incoming@patchwork.ozlabs.org; Thu, 23 Feb 2017 13:44:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgy96-0004Gy-G8 for qemu-devel@nongnu.org; Thu, 23 Feb 2017 13:29:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgy95-0006SW-E5 for qemu-devel@nongnu.org; Thu, 23 Feb 2017 13:29:40 -0500 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:35823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cgy95-0006R9-8E for qemu-devel@nongnu.org; Thu, 23 Feb 2017 13:29:39 -0500 Received: by mail-wr0-x22c.google.com with SMTP id s27so27150051wrb.2 for ; Thu, 23 Feb 2017 10:29:39 -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=MNMMpZ7CLH2YhoCMoa2yqR3KUTAfrtWXrDKURceoQMU=; b=DG4oMXUbc17HHkEeYGbIHCrcMmMFIC+JmFnWfu5iwMl3EtGJBT+t7bLLvWbb+bFB6Z A042Sg/+hJzWwyWGlERMcYcwzCyMtW8MjiSvpqgwMRnVX8x9W2rSE2buZ/B3VlqD+PM/ cSw9F56DT72KPmoSEBlR8dvw24eHa1iA3HFN4= 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=MNMMpZ7CLH2YhoCMoa2yqR3KUTAfrtWXrDKURceoQMU=; b=Mmee9CyqXScYVivdybEAXMlN+cvOSnYPFDUaMYX4PpjjTvhqUEpLtWIVIX6Kbx8GAn m9IEYS01vShckWLE+hawLX5J1ehqaDQasKHOy7NtH7HKYWjcEQECocM7+FbmGHVN32ho Sx3Z2LenaJ/mRvIItGdqbGHoYp3yqgoCVdLmoN8kyy8vhIpsXJDbKk+onBXQI/MGUkw5 JvqsASO5qVBZZmnM/9egA6wZ5jvEAeJlQ71dBvL0TcasO2ezVWCXbaOVQKzi6dG8wTTx j/sTwUJyEadBK7bP65YrzYm8FX29Jl96xDM5iwXdpVwUcJNow+hBal8A5SqgsWSgoZux VT6w== X-Gm-Message-State: AMke39l7YuviRRmv8Gqyli0vOl1hgpzuhNgIKgMoR2iyJveHXtHU75mOtCo3E3R/A+M4yz6b X-Received: by 10.223.154.162 with SMTP id a31mr25678693wrc.145.1487874578143; Thu, 23 Feb 2017 10:29:38 -0800 (PST) Received: from zen.linaro.local (host109-151-49-69.range109-151.btcentralplus.com. [109.151.49.69]) by smtp.gmail.com with ESMTPSA id w16sm7848969wmd.4.2017.02.23.10.29.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Feb 2017 10:29:36 -0800 (PST) Received: from zen.home (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 08BB03E07AA; Thu, 23 Feb 2017 18:29:28 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: rth@twiddle.net, peter.maydell@linaro.org Date: Thu, 23 Feb 2017 18:29:13 +0000 Message-Id: <20170223182927.7166-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170223182927.7166-1-alex.bennee@linaro.org> References: <20170223182927.7166-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::22c Subject: [Qemu-devel] [PATCH v14 10/24] tcg: enable tb_lock() for SoftMMU 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=20Benn=C3=A9e?= , bamvor.zhangjian@linaro.org, fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" tb_lock() has long been used for linux-user mode to protect code generation. By enabling it now we prepare for MTTCG and ensure all code generation is serialised by this lock. The other major structure that needs protecting is the l1_map and its PageDesc structures. For the SoftMMU case we also use tb_lock() to protect these structures instead of linux-user mmap_lock() which as the name suggests serialises updates to the structure as a result of guest mmap operations. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v4 - split from main tcg: enable thread-per-vCPU patch v7 - fixed up with Pranith's tcg_debug_assert() changes --- translate-all.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/translate-all.c b/translate-all.c index f810259c41..9bac061c9b 100644 --- a/translate-all.c +++ b/translate-all.c @@ -75,7 +75,7 @@ * mmap_lock. */ #ifdef CONFIG_SOFTMMU -#define assert_memory_lock() do { /* nothing */ } while (0) +#define assert_memory_lock() tcg_debug_assert(have_tb_lock) #else #define assert_memory_lock() tcg_debug_assert(have_mmap_lock()) #endif @@ -135,9 +135,7 @@ TCGContext tcg_ctx; bool parallel_cpus; /* translation block context */ -#ifdef CONFIG_USER_ONLY __thread int have_tb_lock; -#endif static void page_table_config_init(void) { @@ -159,40 +157,29 @@ static void page_table_config_init(void) assert(v_l2_levels >= 0); } -#ifdef CONFIG_USER_ONLY #define assert_tb_locked() tcg_debug_assert(have_tb_lock) #define assert_tb_unlocked() tcg_debug_assert(!have_tb_lock) -#else -#define assert_tb_locked() do { /* nothing */ } while (0) -#define assert_tb_unlocked() do { /* nothing */ } while (0) -#endif void tb_lock(void) { -#ifdef CONFIG_USER_ONLY assert_tb_unlocked(); qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock); have_tb_lock++; -#endif } void tb_unlock(void) { -#ifdef CONFIG_USER_ONLY assert_tb_locked(); have_tb_lock--; qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock); -#endif } void tb_lock_reset(void) { -#ifdef CONFIG_USER_ONLY if (have_tb_lock) { qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock); have_tb_lock = 0; } -#endif } static TranslationBlock *tb_find_pc(uintptr_t tc_ptr);