From patchwork Tue Oct 10 19:29:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115459 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4120678qgn; Tue, 10 Oct 2017 12:38:18 -0700 (PDT) X-Received: by 10.55.71.143 with SMTP id u137mr13603210qka.166.1507664298657; Tue, 10 Oct 2017 12:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507664298; cv=none; d=google.com; s=arc-20160816; b=Yn1mxuplyxGhPLYFpGKa/M84SAZcoyJboyeEOUZ+ai/X+DIuCP9RRe0WX0HnoW4zF0 6SdzfzIu1HnqUASjDYZb3gskDbXFtjeYPacIzTU1DtrdmHtZ7lANdQo6osxsS60gUKlZ OUPyX2fOWhVV/cIgEcLZtBFIKyXQwECtogqXPda3SV2s+JisMV9nATAydgMzntWLR1DO HDiMv+S8n60RBLoZimlX6sq5xNzEVXmSglBNo9TGSFWybb3cqaLMsuARCIV2d7CJID2k 43iSB3RKCMwTU9LzMe9SpHPIf/uiJPxbxX3pbrRWNdFS+Tk049XCg3EVyM5GXGuSnZdG 3NNw== 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=sEX44l8LhyJd/7qrqd8x5TqVAfrTbLQhVA1NAfddvn5uf3auSIwmEZCN0ZlBPJcdHt 4npfjgibkMYxY0uN6DzdkqF0yFNqUekuDefmN/2W+1LPtpRBB3pbxtKtZRuHAALPWC8H 7F7iRPW/7L0LNxAppuTtKBGjHW2jarTO2wgai5K7u2m/SNfY0psPesfbbuyXfyOz4wBs Ndctw0f9RTq5tYBuoQAXs8nIxS8/7+B54WwUVpNCzCg6UPuDD6VvaUifXbiIWLr8zYfr Hdlbi2BBuqYe/KyNEaegu9O9GVWxRQQdcQCmXw9Wmz+vrnMq3iBSA4Xw5Iz1NkCVjNoY BCzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZubxkgOM; 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 a67si5364655qkf.101.2017.10.10.12.38.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Oct 2017 12:38:18 -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=ZubxkgOM; 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]:36827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20M4-0006FO-J8 for patch@linaro.org; Tue, 10 Oct 2017 15:38:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e20EX-0000l4-MU for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e20EW-00056M-MM for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:29 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:50211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e20EW-00055T-Gs for qemu-devel@nongnu.org; Tue, 10 Oct 2017 15:30:28 -0400 Received: by mail-pf0-x233.google.com with SMTP id m63so18277566pfk.7 for ; Tue, 10 Oct 2017 12:30:26 -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=ZubxkgOM/didEMd15wdAuZqihxXP/Ro7D8W2deBDlxIMTkMje6TavhQl/rfitvumtI q0VccLSGFVJyQ2P0DOHay+/xHh9gm1+iEkhPb10nPPXyVEtMlhdS5bUIgdrjMhwoL5ai uFw9CTlOZVpaOI2b8wvjYBgAHXjnfh9H7Q86Q= 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=Cdurf/Fey/N2VQcvznueLfO37HXeTom1zrxsFzOnIkYBycqYAGw8YcjFtHmmaT3rE2 qvcrLBgaAZrG4TdOvRLf1QT4wHH1MIU1q2KtlYTAMSeTgTXCu8rdoqZ/EQ0uy9/U7OoE vakG8JTiyUgcNOse4VBnYevp8ghg3a3/g0dypPkG5qib9oME9ma3ynB7C2QLajSdujCh b/YKD114DZifYsp7dyiGWVWghjCNDB/hZ3dfDGPK17Uha9xW7jyakZKYjHZGNe2dkQyr TyD5JB8aVi3TrQR9LfrJcB1W2SJ4ry/OOxkKFaETiwvRP7wonbaTExOSRLQQg6GOPxFN flZQ== X-Gm-Message-State: AMCzsaV/AHcN1Bye5OW80OmLJX2WODZeOPDOVJ6EiVjxixlNbAB/XdT8 D3k4AzcGk8sV5AduqWLJrkoFdcQNyKI= X-Google-Smtp-Source: AOwi7QC8JAFwamf2K4iLxzoFNpLZU1JjVmVAVdveUQSAtvh7vb4yvW5SINq7jxed+ZqaLXg5KJnqbA== X-Received: by 10.84.141.168 with SMTP id 37mr13622643plv.140.1507663825063; Tue, 10 Oct 2017 12:30:25 -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 r22sm19859788pfl.15.2017.10.10.12.30.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 12:30:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 12:29:57 -0700 Message-Id: <20171010193003.28857-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171010193003.28857-1-richard.henderson@linaro.org> References: <20171010193003.28857-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::233 Subject: [Qemu-devel] [PULL v2 14/20] 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,