From nobody Tue Dec 16 11:03:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487935974292261.37468970167674; Fri, 24 Feb 2017 03:32:54 -0800 (PST) Received: from localhost ([::1]:36345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chE7I-00038f-SN for importer@patchew.org; Fri, 24 Feb 2017 06:32:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chDwB-0007Cu-0O for qemu-devel@nongnu.org; Fri, 24 Feb 2017 06:21:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chDwA-0000Gq-10 for qemu-devel@nongnu.org; Fri, 24 Feb 2017 06:21:22 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36537) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1chDw9-0000G4-Qk for qemu-devel@nongnu.org; Fri, 24 Feb 2017 06:21:21 -0500 Received: by mail-wm0-x232.google.com with SMTP id v77so11955487wmv.1 for ; Fri, 24 Feb 2017 03:21:21 -0800 (PST) Received: from zen.linaro.local (host5-81-235-77.range5-81.btcentralplus.com. [5.81.235.77]) by smtp.gmail.com with ESMTPSA id 99sm5836501wrm.18.2017.02.24.03.21.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 03:21:16 -0800 (PST) Received: from zen.home (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id ED11C3E07AA; Fri, 24 Feb 2017 11:21:09 +0000 (GMT) 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=MNWz8Ylr3APlk6hyDJGkyDb2HB9AnLTM7cS/6mzyIwA=; b=FDUESqEfYX70y7FJkKplaTSVSMDA0kpg/slV5V0uDaWPWZJfD4kWQc2RzYbflbHlbg FD0XSMpkG4L6oUo4fZbN6IP8P962X0vt0SbzSdYkEpHCqCGtd6c2kTUDM5qGTs5K/RO8 PutBTRf/vZ4BcdF0la1lE6R1FT6K00zDSZR20= 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=MNWz8Ylr3APlk6hyDJGkyDb2HB9AnLTM7cS/6mzyIwA=; b=km04q+KBWg9KsOaOf3MohcM6SRKh7p0VFGueuiyWGsz4Kpq3cVRYulXXPFfy1Yr8Zf R2ultlhk/niZyYIZqlv3mnqLnvpBAkCbU2+SmlxfVyCb1e00NOT7r/VB9iXsMQqNKKkR ZSTIfUKw5YCWT0EkhsWDYediJEMoxwJS2+tEag/XYZqaVui/PicR2veIahf2YE/cSIbT zMjbsdb1jy75Mqi7itCYTSCxNxBa78lnpY/grrLHselpt8SiUaPiPxnxLLGOW+JNsAy4 QT5vcDJwdiZCdLf3QsLJvRrSWutEa/ZXoMx+5Ph9pSLahlPV6mCpF8t6Naha12VSRTZ2 f8Tw== X-Gm-Message-State: AMke39lLT/aDrjD7mxJWrOOmkQvAyPmZXLMpvDQTEACzX3Nw+Sxmpe7QnJEa6wQI8cokAX/F X-Received: by 10.28.153.196 with SMTP id b187mr2090622wme.53.1487935280743; Fri, 24 Feb 2017 03:21:20 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 24 Feb 2017 11:20:55 +0000 Message-Id: <20170224112109.3147-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170224112109.3147-1-alex.bennee@linaro.org> References: <20170224112109.3147-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 Subject: [Qemu-devel] [PULL 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: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A9e Reviewed-by: Richard Henderson --- 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; =20 /* translation block context */ -#ifdef CONFIG_USER_ONLY __thread int have_tb_lock; -#endif =20 static void page_table_config_init(void) { @@ -159,40 +157,29 @@ static void page_table_config_init(void) assert(v_l2_levels >=3D 0); } =20 -#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 =20 void tb_lock(void) { -#ifdef CONFIG_USER_ONLY assert_tb_unlocked(); qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock); have_tb_lock++; -#endif } =20 void tb_unlock(void) { -#ifdef CONFIG_USER_ONLY assert_tb_locked(); have_tb_lock--; qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock); -#endif } =20 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 =3D 0; } -#endif } =20 static TranslationBlock *tb_find_pc(uintptr_t tc_ptr); --=20 2.11.0