From patchwork Fri Jan 27 10:39:07 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: 92613 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp176268qgi; Fri, 27 Jan 2017 03:00:25 -0800 (PST) X-Received: by 10.55.18.207 with SMTP id 76mr7710569qks.261.1485514825381; Fri, 27 Jan 2017 03:00:25 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v2si3284029qkl.49.2017.01.27.03.00.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 27 Jan 2017 03:00:25 -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]:44343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX4GU-0005YB-QS for patch@linaro.org; Fri, 27 Jan 2017 06:00:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX3wP-0003Pd-Fj for qemu-devel@nongnu.org; Fri, 27 Jan 2017 05:39:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cX3wM-0003Xk-RH for qemu-devel@nongnu.org; Fri, 27 Jan 2017 05:39:37 -0500 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:36103) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cX3wM-0003XV-Ka for qemu-devel@nongnu.org; Fri, 27 Jan 2017 05:39:34 -0500 Received: by mail-wm0-x236.google.com with SMTP id c85so110614434wmi.1 for ; Fri, 27 Jan 2017 02:39:34 -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=zHeDdh7LS/qfaOBi0Wrx/3dwOaXRkrY7AoKsyWB2WWc=; b=CQ/rsZJzSNLBhpr/rE+FjmE78tu+Mdxpt3sK55uJSJOkthfIkUbTnm/8conaP9lpTZ bIonlZ4GLXw8Y7Z9lGK+ar9O/l4gOXX+2dj46FifUyRgQ6CHflAt34acHxY8gyUNBRS5 bXas6Y1mvOb110K8XCVzHkTvl9MZMizigm6TU= 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=zHeDdh7LS/qfaOBi0Wrx/3dwOaXRkrY7AoKsyWB2WWc=; b=Xqx0zvE7e/kjo8rOceMAGTV+oINL05hcTPbmmiAyYJ5X0H27RNF5J8deGKOJnNGsJH DAEYMxcsGEoaQmIhy8ChqdIdnJOHgO9VREKexLdbosVNuYL9YH+R770GoVc6sBiTPuJp +LuNUhQs/6ZETYHHHLG2n6EylOn0PWOsmvbB5bGviUIbOdkRMEJswAkV2cWpHKzUIg7T Qv1SUIEj/bFp5dRxiO9EsTbkPcQxhc+oHwsTZTKb/r/vsw5Gb2bPVH2t5o7ceeX/5D6C w3oH8aAAeLbqJesvmxxqUJ9UPvLHRXgJ07Wco4u2WigYMSu6j3435mFw8j34g0VzLc+r oB0Q== X-Gm-Message-State: AIkVDXJECy6G5i1DPZCta15kKuecrzCbJuRSXA8W0i7fYIBPxjXhBJwp4cUDLWRq6aY38y4I X-Received: by 10.28.23.66 with SMTP id 63mr2565876wmx.46.1485513573550; Fri, 27 Jan 2017 02:39:33 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l67sm3175689wmf.1.2017.01.27.02.39.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 02:39:29 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 467F63E3763; Fri, 27 Jan 2017 10:39:23 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com Date: Fri, 27 Jan 2017 10:39:07 +0000 Message-Id: <20170127103922.19658-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170127103922.19658-1-alex.bennee@linaro.org> References: <20170127103922.19658-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::236 Subject: [Qemu-devel] [PATCH v8 10/25] 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: peter.maydell@linaro.org, claudio.fontana@huawei.com, Peter Crosthwaite , jan.kiszka@siemens.com, mark.burton@greensocs.com, serge.fdrv@gmail.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , bamvor.zhangjian@linaro.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patch=linaro.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(-) -- 2.11.0 diff --git a/translate-all.c b/translate-all.c index 41b36f04c6..87e9d00d14 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);