From patchwork Tue Oct 10 00:55:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115325 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3175509qgn; Mon, 9 Oct 2017 18:09:26 -0700 (PDT) X-Received: by 10.200.15.40 with SMTP id e37mr12109974qtk.159.1507597766232; Mon, 09 Oct 2017 18:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507597766; cv=none; d=google.com; s=arc-20160816; b=wlSizD3i8vzQZgZNXCoDf64fyl+cXI3FBIb1qRkTrV4Fh4MHBVCZCoyAlhKqFik0wS HoleyjnGjLc9+q6TErXbw9Yic8qZqk7AFEQ3tSZyMXsBgnE3XE9ZT/bEyzINl+nO8R5D IYYe/ls2m+wKG6WqQrDPUGjlPCL267Wo4gB/s2A5K72Ct6XKLEb68qxBI//cRegP04qO 4TlAyg/v4143OlejPi9YpoUlHMzn1i+s2qgjfQxmyUJ2sVgwpfShWk4SkGW/u5X5jlsY r2SMP/0kk5QzjLXF9I4SLdxYaw0es41k4NCQsneWwcKxVgk9Ci0pWJ4pxarecvAV7UKl lEVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=BlqfHrkOPjLzLqDyXBqDW01UXizdoh9zUOpMpGA3NFk=; b=NuDHiSWA4zYeoR08Csm6YhyHX+VzSov7Ruo63Z/8o2FiRtjxN6Oe8iPffFPokFW2OZ MbUBLn3iaOMF1JB/iUxIGjxr9oV9pKneQlirUQgvzLLTb/88ZUfPVz46HFcoXA8639l9 x8M+0jQ235sPMkzDfK86t3/0ON1GmeNd1FtJ6dezwmst7I84gWl/aNeC8LO+UicpbePA KMtJ+6ybL9/CWrfSlhU5PUARTg4ZdLUk890NUsvdjKR2onfTEgmj/+EhPzotebHP/JiF 1ZfZu/wMofAUqVnmaKJmotWceFJ/y3nIPdh1M2pyZop9J16HHKHvLe8DzPKgMXrXJKfv 3Gfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fzdaXHJ7; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z48si3218153qtj.203.2017.10.09.18.09.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 09 Oct 2017 18:09:26 -0700 (PDT) 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 header.s=google header.b=fzdaXHJ7; 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]:60540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1j2y-0003o7-5F for patch@linaro.org; Mon, 09 Oct 2017 21:09:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1iqQ-0002Oi-C9 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1iqM-0004WM-NR for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:25 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:53905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1iqM-0004Vt-Hf for qemu-devel@nongnu.org; Mon, 09 Oct 2017 20:56:22 -0400 Received: by mail-pf0-x22f.google.com with SMTP id n73so8794306pfg.10 for ; Mon, 09 Oct 2017 17:56:22 -0700 (PDT) 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=BlqfHrkOPjLzLqDyXBqDW01UXizdoh9zUOpMpGA3NFk=; b=fzdaXHJ7h6JggUSh3mrKhmMOD/zifn3H4DfWBKl4Fj/MdIDvNiHPVoo2rY2W8aATXs Y9zjCadomyufXbPgVs6FjCg8BXmiB/aPTJWbI0V4NkPtPVlxVzxYDhqFhxKipjAxB1Ta kPEY6cTjoN0xC7HpNyIn5KAAmJKxkMZdnSmO4= 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=BlqfHrkOPjLzLqDyXBqDW01UXizdoh9zUOpMpGA3NFk=; b=hUlGhtKZ0HdWxKeGt4OORPaJ20a/SSCWp0EmmoxRvX04+4y30pFkxjsAAQo6bzKoHZ MOomDPgKraSt93y+5BDHEUoEbC6HAglBlmf2EL2CYN2nBU27YSR+cFdAEFUCJenHIIJl a1TEa25J5/1inBVEZXOZKZ8ErgMUZ9y592L0MmxmnTbl2X+1rY5bykZ0kztAZkK/Kn1g rhuE9YIfhoCxjX7S8Z4mNzkdASUMfO/S+jOqn4B0bpRnCcCgKgohPQb7idWTB2p8meSC vVnDLug06nDu5KRbkovHeJZNy8Ye1EnTGBrl+efGpbFNl0D1wHtF+YeS4o2d60NLOWzW qDsw== X-Gm-Message-State: AMCzsaWhIeTK+FbUBEY9ncknYw2tkIAlL6o9ZQq8AuLGRYG7i2W8lCwQ Zod/DUJQsHleVU8PRP+Ntr2bLgytevg= X-Google-Smtp-Source: AOwi7QA+QRTRemwpfS0Y8/okSk8nZgIMDZ3PJYuq70vuyjSHnR5yo1WW69JAnKoqG2tbO2P/g0NzOA== X-Received: by 10.98.30.66 with SMTP id e63mr11701437pfe.176.1507596981173; Mon, 09 Oct 2017 17:56:21 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id n19sm17121368pfj.52.2017.10.09.17.56.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2017 17:56:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 17:55:51 -0700 Message-Id: <20171010005600.28735-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010005600.28735-1-richard.henderson@linaro.org> References: <20171010005600.28735-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22f Subject: [Qemu-devel] [PULL 14/23] 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: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" 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ée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) -- 2.13.6 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 6b853b329c..26efad302d 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -82,6 +82,12 @@ #undef DEBUG_TB_CHECK #endif +#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) } } -#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 callers + * with if (DEBUG_TB_CHECK_GATE). + */ +#ifdef CONFIG_USER_ONLY 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); } -#endif +#endif /* CONFIG_USER_ONLY */ static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb) { @@ -1236,8 +1248,10 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate); qht_insert(&tcg_ctx.tb_ctx.htable, tb, h); -#ifdef DEBUG_TB_CHECK - tb_page_check(); +#ifdef CONFIG_USER_ONLY + if (DEBUG_TB_CHECK_GATE) { + tb_page_check(); + } #endif } @@ -2223,8 +2237,10 @@ int page_unprotect(target_ulong address, uintptr_t pc) /* and since the content will be modified, we must invalidate the corresponding translated code. */ current_tb_invalidated |= 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,