From patchwork Sun May 2 23:18:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 430485 Delivered-To: patch@linaro.org Received: by 2002:a17:907:764d:0:0:0:0 with SMTP id kj13csp1231057ejc; Sun, 2 May 2021 16:38:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmBJDJqjqZUHi/aSmCspkUATAu4ymNMHjm6pa0Ni9R0X+LAmvVcP4N8JC+CQLgNnQj3xxO X-Received: by 2002:a05:6602:1641:: with SMTP id y1mr12480900iow.54.1619998698885; Sun, 02 May 2021 16:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619998698; cv=none; d=google.com; s=arc-20160816; b=GgfdD9gaoChtwqUqknh4R5PR5alT/q9VaoEZxXojKe14Wv0lq/Xy76gt+Ya4uV28gc Ible31DCX/jChFgLRqUCI43cGV3aLiU36EbnxL9xJKpFB0K7bGUsJj20/FlWgu/6HFv+ PJqrbvkTzmUIVnBzpMo4D4AZWzKPdl1Sob8M1UmD1R8d4rg8r9XlQLy1Lz6A0j8389vo onhwTVLAdw9Mls3aDHZB1LeI4JXmC8y2QGiT+dmtnPqZtY9o0gCTp/rmpqBSDnCnhTP9 hjV1nFFyK1bXvqgK7BzFTcA18t/qYUp3YZLQBqOxW9hOx0cCCRobbxtqSXsuvwOPGksy 25Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=3+qvAys+bC4iB3oxnM72GbfzF+QWmjj72t2D1jOredk=; b=L+eW8xmBjkI4hhcdr6OgeebN3XOgxblc2lEbPqDC7wKQaM/eXpHjX2LCma2dNQ06eE RMydwJ1PnIzoZFu7kQMzucRPI6Lh486YTNzFyrwA4/BNo05o85x3lvt4/Ipbwxavt+ya tDUroiyzw4bjHKnrUURr6BSYjhhAo70t7zLwuSHp8M6BIvTDRdB2Ah6B/2xfPjgQW22M 98Jfaf373vrDezUDajAtS695G6qAywzTX8ievDG5DSEgnxmD0ujLL68d4kxy0UlAqEm8 HMlZ5lkIdGB3w4NBRvOzSuIoTaV4pjNtD6/0tJlvKrefYW4GC6nGPihyc1a1vaPvb2ts /MgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CY2E5kuv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c188si5819466iof.9.2021.05.02.16.38.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 May 2021 16:38:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CY2E5kuv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldLfG-0007ye-7u for patch@linaro.org; Sun, 02 May 2021 19:38:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldLMg-0008ME-FU for qemu-devel@nongnu.org; Sun, 02 May 2021 19:19:06 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:37501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldLMc-0002xR-3m for qemu-devel@nongnu.org; Sun, 02 May 2021 19:19:03 -0400 Received: by mail-pj1-x102d.google.com with SMTP id k3-20020a17090ad083b0290155b934a295so4722326pju.2 for ; Sun, 02 May 2021 16:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3+qvAys+bC4iB3oxnM72GbfzF+QWmjj72t2D1jOredk=; b=CY2E5kuv59LbsNiJJrF75ZkCRfFbMPUDod9g3cXTvJRKW/9vNLZLmhinuWeHrjW96q IGSCRlDP12yxLu5VDpJoVTVCSbemuLPxSqHNRx7wUo3SueOToOVFw6oX6T1bIwqky85e oKz+BXHJ7qX4IWkC0C3kI6RAfY0hsa405JvzCLT98O0nGni8ePrwdSp+bYjFKUNEZC0K GRfl6bWhDpaMDAzy8ZjJC6pmsiwlESRQ/EAQfRAB6M86fZfCGcRyr0oMCH5W4qe7hWbx t/M2enqCnaCpo92lpyA+2R+/ohepN1s4Aq/8MHsdFRZNGlZ86SHDxMBo8yvKQs/cnZpT F8yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3+qvAys+bC4iB3oxnM72GbfzF+QWmjj72t2D1jOredk=; b=kf1iJzH7gWbpIYeXzeesswbiA6Gxac/diAATDdSspFE0ndBxL4TYDogGc95TFLx/Gs 7ZUNVNAq3iDpb4dYcPv4NrGDcwZs8ymMNyshHxcs50nld7NSXhGRPC7zEL8wNVhAWrRM 3xsK1ZS/tDgV4kKWVRaGw9dOnUVuqCMO/Vu146kCOQ7E/t1xw1wKI5fNhrmUWbtQTN2a d7jmvC/GgKMF7VLdcqWLcRt0B7o+b2WrN2rvcCCsnxFiuFZVv0A1AMInWtPOhfWEYOzU TDpAE53URbiyVr9k/6s7+QSoJ59zBcfkcNOtfNge3dvPge6dNz4/cAbA3cf7Wk6c8t1X 051w== X-Gm-Message-State: AOAM533DmMzJyDnQP4b7M90/tIhtYSGfIFNgPQ7gMLEIuR1Aw2BJaR5z wAhmRsIEtbSCeCnAEacLvxkFd6ASk+jgOA== X-Received: by 2002:a17:90a:7063:: with SMTP id f90mr18815835pjk.95.1619997540677; Sun, 02 May 2021 16:19:00 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm7146236pfa.68.2021.05.02.16.19.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 May 2021 16:19:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/28] tcg: Move in_code_gen_buffer and tests to region.c Date: Sun, 2 May 2021 16:18:36 -0700 Message-Id: <20210502231844.1977630-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210502231844.1977630-1-richard.henderson@linaro.org> References: <20210502231844.1977630-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Shortly, the full code_gen_buffer will only be visible to region.c, so move in_code_gen_buffer out-of-line. Move the debugging versions of tcg_splitwx_to_{rx,rw} to region.c as well, so that the compiler gets to see the implementation of in_code_gen_buffer. This leaves exactly one use of in_code_gen_buffer outside of region.c, in cpu_restore_state. Which, being on the exception path, is not performance critical. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 11 +---------- tcg/region.c | 34 ++++++++++++++++++++++++++++++++++ tcg/tcg.c | 23 ----------------------- 3 files changed, 35 insertions(+), 33 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée Reviewed-by: Luis Pires diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index a0122c0dd3..a19deb529f 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -696,16 +696,7 @@ extern const void *tcg_code_gen_epilogue; extern uintptr_t tcg_splitwx_diff; extern TCGv_env cpu_env; -static inline bool in_code_gen_buffer(const void *p) -{ - const TCGContext *s = &tcg_init_ctx; - /* - * Much like it is valid to have a pointer to the byte past the - * end of an array (so long as you don't dereference it), allow - * a pointer to the byte past the end of the code gen buffer. - */ - return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size; -} +bool in_code_gen_buffer(const void *p); #ifdef CONFIG_DEBUG_TCG const void *tcg_splitwx_to_rx(void *rw); diff --git a/tcg/region.c b/tcg/region.c index 652f328d2c..893256f9f4 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -68,6 +68,40 @@ static struct tcg_region_state region; static void *region_trees; static size_t tree_size; +bool in_code_gen_buffer(const void *p) +{ + const TCGContext *s = &tcg_init_ctx; + /* + * Much like it is valid to have a pointer to the byte past the + * end of an array (so long as you don't dereference it), allow + * a pointer to the byte past the end of the code gen buffer. + */ + return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size; +} + +#ifdef CONFIG_DEBUG_TCG +const void *tcg_splitwx_to_rx(void *rw) +{ + /* Pass NULL pointers unchanged. */ + if (rw) { + g_assert(in_code_gen_buffer(rw)); + rw += tcg_splitwx_diff; + } + return rw; +} + +void *tcg_splitwx_to_rw(const void *rx) +{ + /* Pass NULL pointers unchanged. */ + if (rx) { + rx -= tcg_splitwx_diff; + /* Assert that we end with a pointer in the rw region. */ + g_assert(in_code_gen_buffer(rx)); + } + return (void *)rx; +} +#endif /* CONFIG_DEBUG_TCG */ + /* compare a pointer @ptr and a tb_tc @s */ static int ptr_cmp_tb_tc(const void *ptr, const struct tb_tc *s) { diff --git a/tcg/tcg.c b/tcg/tcg.c index 0926454845..212df31622 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -419,29 +419,6 @@ static const TCGTargetOpDef constraint_sets[] = { #include "tcg-target.c.inc" -#ifdef CONFIG_DEBUG_TCG -const void *tcg_splitwx_to_rx(void *rw) -{ - /* Pass NULL pointers unchanged. */ - if (rw) { - g_assert(in_code_gen_buffer(rw)); - rw += tcg_splitwx_diff; - } - return rw; -} - -void *tcg_splitwx_to_rw(const void *rx) -{ - /* Pass NULL pointers unchanged. */ - if (rx) { - rx -= tcg_splitwx_diff; - /* Assert that we end with a pointer in the rw region. */ - g_assert(in_code_gen_buffer(rx)); - } - return (void *)rx; -} -#endif /* CONFIG_DEBUG_TCG */ - static void alloc_tcg_plugin_context(TCGContext *s) { #ifdef CONFIG_PLUGIN