From patchwork Wed Feb 1 15:05:38 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: 93064 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2467919qgi; Wed, 1 Feb 2017 07:26:17 -0800 (PST) X-Received: by 10.200.38.50 with SMTP id u47mr3409854qtu.293.1485962777102; Wed, 01 Feb 2017 07:26:17 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i53si14657251qtf.137.2017.02.01.07.26.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 01 Feb 2017 07:26:17 -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]:51548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYwnY-0000i9-LM for patch@linaro.org; Wed, 01 Feb 2017 10:26:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYwU5-0007AK-5S for qemu-devel@nongnu.org; Wed, 01 Feb 2017 10:06:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYwTz-0008G2-Gl for qemu-devel@nongnu.org; Wed, 01 Feb 2017 10:06:09 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:36499) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYwTz-0008Fc-AX for qemu-devel@nongnu.org; Wed, 01 Feb 2017 10:06:03 -0500 Received: by mail-wm0-x230.google.com with SMTP id c85so43200796wmi.1 for ; Wed, 01 Feb 2017 07:06:03 -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=ExOydlABY3ILvwT5ZUDR2PgtuEqTBgxoK6weBVxrL+8=; b=heBXzvJu4fxHag19fXzzjluOszLL+S/y5qg/xlP+36vRorEju2xkWtiEakInUT8wIN G9a7HdcJZe7vjeV9POWIh+TCRjWx8Xy8esyTBxEKUn1FLZXbmrNoJXxpnBsOaE9CanrV EjTbfQkh5Hg5tLqKYLnv5dc2z3ktIYlYUjMqM= 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=ExOydlABY3ILvwT5ZUDR2PgtuEqTBgxoK6weBVxrL+8=; b=lQFEDje6yynr5it0OXqzrb0xoBD9hEvyCeH3Qu+dysgkrRMuEdzmeTMIdzWagJbHIG h5CU9crlcoknIagRX65zhHXjEWYezNKvm2waoYlr1bSGL9BQ0Ziahw4kFFCh6YXpW4eL uC211c6bQ9rqIhuohTjfWy+s1WvUl78NJjHHjkeB2M7toF3//0vBErljNvHBtQ0dHrga nFXr582F488VHXQ0DoWNIYm8ihujg8etkGwt4r4Ik9cWiff/f49DKxCvq+33H8gEK0el myCrBt/dHwFLcjnR1v2Pfz1blL7QAy+AJDnjFsSglLm7sIFx9VHWas3yzJaeTuVP0oQO ykTw== X-Gm-Message-State: AIkVDXLXS8OTE34H67m8QNjgpM0WHP+RZPpaQd4rwqCpoZZmoS1g88d8UG/Sxu2oJNdS3j+U X-Received: by 10.223.133.164 with SMTP id 33mr3156632wrt.39.1485961562332; Wed, 01 Feb 2017 07:06:02 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x39sm34576876wrb.3.2017.02.01.07.05.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 07:05:56 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 27FA03E0CA3; Wed, 1 Feb 2017 15:05:54 +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: Wed, 1 Feb 2017 15:05:38 +0000 Message-Id: <20170201150553.9381-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170201150553.9381-1-alex.bennee@linaro.org> References: <20170201150553.9381-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::230 Subject: [Qemu-devel] [PATCH v9 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, 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 868d06d35c..96a50187f2 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);