From nobody Mon Feb 9 18:17:46 2026 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.zohomail.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 1500521235890590.8776457506409; Wed, 19 Jul 2017 20:27:15 -0700 (PDT) Received: from localhost ([::1]:35872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY27N-0001iR-Fn for importer@patchew.org; Wed, 19 Jul 2017 23:27:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dY1qO-00016d-Sj for qemu-devel@nongnu.org; Wed, 19 Jul 2017 23:09:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dY1qK-0005rl-MR for qemu-devel@nongnu.org; Wed, 19 Jul 2017 23:09:40 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:53141) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dY1qK-0005rN-Hv for qemu-devel@nongnu.org; Wed, 19 Jul 2017 23:09:36 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 163F120B60; Wed, 19 Jul 2017 23:09:36 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 19 Jul 2017 23:09:36 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id CB8E27E1FC; Wed, 19 Jul 2017 23:09:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=4RqHB0RIQFkzwFB Dx5XEefWF/+3hmBu3BYpSeaEGKtI=; b=g/ild8y5VU7qrHYNleggKN/ZE/DTKp3 hTdW46Nx2jnjHwpRwm/qy8n44rDF7TS0qysrZ7tFdDM2tn39E71NHZHOXfW38CSj 5PYswUZdmIeoKjl6IV+ZD/oXBiQhUg2FWkC2DyXsIUyMNy8jBnKNS7hhAde0OAyX 60fZj9g5beWU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=4RqHB0RIQFkzwFBDx5XEefWF/+3hmBu3BYpSeaEGKtI=; b=foEBgj1M H4g79FY+WJtXF/VqxNMvvQR55cBapcgKrS8IVnoFlk7AmSihOhszSUPXxElupWrQ y5qfLUDKdlZI5z6uwOKqIxu8vqOu6hcKTCT4f1/SnbTCskhzp55edNkWDPHOhS7l 3e5vuCH55oTPbEFvPe/+AGw+YiTRCj5vu5pEkuBl6x0e1rJVYzGwVUUOjUPJP2Ta gtjcZQs+dlwe++65n/HHXIrnM69naw0me+JYcPN/12McyhNjE1XG2bbaECZ0OXHO vEF3FtOPwqNZmCdpjK2/9+bjn1f2COcMjWqzHyh98B4I8q4m75pCVnUZrYN/W+cF nSrhTUzQgkj4vg== X-ME-Sender: X-Sasl-enc: 92pHy3XXoPaAHlxKKE1ItYbRtUP9JetTkbvaXY2bZn9p 1500520175 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 19 Jul 2017 23:09:11 -0400 Message-Id: <1500520169-23367-26-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500520169-23367-1-git-send-email-cota@braap.org> References: <1500520169-23367-1-git-send-email-cota@braap.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] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v3 25/43] translate-all: define and use DEBUG_TB_CHECK_GATE 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: Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This prevents bit rot by ensuring the debug code is compiled when building a user-mode target. Unfortunately the helpers are user-mode-only so we cannot fully get rid of the ifdef checks. Add a comment to explain this. Suggested-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 962e9b3..845585b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -82,6 +82,12 @@ #undef DEBUG_TB_CHECK #endif =20 +#ifdef DEBUG_TB_CHECK +#define DEBUG_TB_CHECK_GATE 1 +#else +#define DEBUG_TB_CHECK_GATE 0 +#endif + /* Access to the various translations structures need to be serialised via= locks * for consistency. This is automatic for SoftMMU based system * emulation due to its single threaded nature. In user-mode emulation @@ -950,7 +956,13 @@ void tb_flush(CPUState *cpu) } } =20 -#ifdef DEBUG_TB_CHECK +/* + * Formerly ifdef DEBUG_TB_CHECK. These debug functions are user-mode-only, + * so in order to prevent bit rot we compile them unconditionally in user-= mode, + * and let the optimizer get rid of them by wrapping their user-only calle= rs + * with if (DEBUG_TB_CHECK_GATE). + */ +#ifdef CONFIG_USER_ONLY =20 static void do_tb_invalidate_check(struct qht *ht, void *p, uint32_t hash, void *userp) @@ -994,7 +1006,7 @@ static void tb_page_check(void) qht_iter(&tcg_ctx.tb_ctx.htable, do_tb_page_check, NULL); } =20 -#endif +#endif /* CONFIG_USER_ONLY */ =20 static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock= *tb) { @@ -1238,8 +1250,10 @@ static void tb_link_page(TranslationBlock *tb, tb_pa= ge_addr_t phys_pc, tb->trace_vcpu_dstate); qht_insert(&tcg_ctx.tb_ctx.htable, tb, h); =20 -#ifdef DEBUG_TB_CHECK - tb_page_check(); +#ifdef CONFIG_USER_ONLY + if (DEBUG_TB_CHECK_GATE) { + tb_page_check(); + } #endif } =20 @@ -2209,8 +2223,10 @@ int page_unprotect(target_ulong address, uintptr_t p= c) /* and since the content will be modified, we must invalidate the corresponding translated code. */ current_tb_invalidated |=3D tb_invalidate_phys_page(addr, pc); -#ifdef DEBUG_TB_CHECK - tb_invalidate_check(addr); +#ifdef CONFIG_USER_ONLY + if (DEBUG_TB_CHECK_GATE) { + tb_invalidate_check(addr); + } #endif } mprotect((void *)g2h(host_start), qemu_host_page_size, --=20 2.7.4