From patchwork Thu Sep 1 06:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 601792 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp244839mae; Wed, 31 Aug 2022 23:57:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR5P+L6DR1Ct6ZzNtGurhrFQMvaCYtFlATmq6kYuJ6q7g8eUZ/DiE89Kndpx+CHbT5q2HI6+ X-Received: by 2002:ad4:5c89:0:b0:499:31d:b4ea with SMTP id o9-20020ad45c89000000b00499031db4eamr16052759qvh.104.1662015473685; Wed, 31 Aug 2022 23:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662015473; cv=none; d=google.com; s=arc-20160816; b=JEWTy2JDb9s6ll3OTgb7U6gQvT/MMzKz/3kUWfbDd0g6q7vN/VUcFJ/gLZ9eCqwjcK tZaAN2sDSt4hMTXGH9dW+vCpSbEPQawsmcTCY3xzi0FoG0+iqRaNFRWRIyNMht9mkvtp n23gRzB5Ia3Ed/DTfOGnCEJiflsz2NagMAKFJZk/dKZcLFeJe1FNC7D8JFsK3ztev3vB iieGxHsw4zWDRaPQs2WUeYzwmeilHYGcVE8pRGYQeJVO+bU5p4Bpv/vjwwJU8YHwOZlF qZHvV8hdKTX26AIR6iyq/q8nLhFTZ+VlHV8dZiZzxiUQn+oTGP6LYeEGSt9sOKCgUhct 4g7w== 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:cc:to :from:dkim-signature; bh=zG39VovyIZ/PsCMFUhH4j2iQCKj21MZ5YeRW0rCmN4k=; b=apaQD+dWbuQU7ALZZprdxIohzsNctjRgBagxzVrBhev2LiH1v+xF2x/y721uTJFsR3 e6XBZCRvQ2oUa9Esbqbmojs1d9Er6vhvXO/7Z8Z44DKuGIGMC/5nh45ZpbxM5UTUeXBS jlslyku5To6rVRmW3DNpifud5mj9gUZ2wF2G6B3MmOT8wlpMT3N1UQR2I8FOaqvKsCRl NDIBSQ6qgtoYMYVkaKIBtADi+0iKFE/Ll6YlIzpjvo5MJJ4oArYv63wkbLuOtFDDOF9e 8P61mRaAzIuyU/Ti/JNohNYzHZMVbQ1oeLiZ/rPo2aaLq2vQZPaq/nOfRcm2J1pG6clE LS6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yIEiKLRC; 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 r8-20020ad45768000000b00499176a41casi3173179qvx.505.2022.08.31.23.57.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Aug 2022 23:57:53 -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=yIEiKLRC; 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]:43430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTe9B-00060M-8S for patch@linaro.org; Thu, 01 Sep 2022 02:57:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTe4U-0005we-Ir for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:03 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:45914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTe4Q-0003G2-7n for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:00 -0400 Received: by mail-wr1-x42e.google.com with SMTP id w5so4832343wrn.12 for ; Wed, 31 Aug 2022 23:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=zG39VovyIZ/PsCMFUhH4j2iQCKj21MZ5YeRW0rCmN4k=; b=yIEiKLRCM7TgLMdcNPxS9cOM8lzBkmKHXmNR9jzi6abZTaMt+nLlixbst1n/nf76hf rDm7qNnymNkoAA8FCZ8HgwLBe98URiISgUn2ltW9g4sXt3hwEnbpyd804btFeB4JBf5K wFMTtdl+21UHn7dVnG17aYit/icIUCSvrlZ8GGK3vYeaulQrRt68mZvUyTAgb4/TZ2Gh r/Z1RfMquRVoFkkkRoanSV+rA83maZzmj/qhxW3/UGLmkHrqcguVRkIu0DjjkCqVLJMf KjbS14SSnFVo0C3MCq8OFDGKXx2p5S3QJQaPj5NujzztdMZmHjp/UaSPjTBY1SP2wLip BxgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=zG39VovyIZ/PsCMFUhH4j2iQCKj21MZ5YeRW0rCmN4k=; b=IepzW3+J+/8EbVDjsm+cw4gidjiIw98TDGXKP+ghZkFV5JXJgRasSbq9k+iy7wFqrx VdCaz/D5tMHMwubwtzob1/VowuWfh1WhnQI7FCeXBC+dpusYpVwyTwXzB/dCmQG4SnxE LXpnzpSMDeuV+JXWTaB3wGkU2YsLYbSwLNmMNX2YNIck6dTiwTATZ8SerdR4OtCXSah9 St2n/hCGR5VX4Y83e9o7OnSl0c3gS3HtTpCM6/gCBWq1dt3IpmBt/YcImctU83fumJ0h QjwVnnETZ2ZICPCmTjwtRCQVG187V3m9zXlG1K8E914I81ar/4MHL/g/SjkL5BwGxXUs XdEQ== X-Gm-Message-State: ACgBeo3GWE8/Kx4Uj0oWYyIB/RrLPGaue9LojRb8yuZaYP1GYA2B4RJp QrwY0ohEGrer9yCRe8RnldXZaoIgVw/XpVaO X-Received: by 2002:a05:6000:2ce:b0:226:d420:db7a with SMTP id o14-20020a05600002ce00b00226d420db7amr11854630wry.489.1662015176456; Wed, 31 Aug 2022 23:52:56 -0700 (PDT) Received: from stoup.. ([87.192.221.83]) by smtp.gmail.com with ESMTPSA id a6-20020a5d4d46000000b00226dedf1ab7sm8308153wru.76.2022.08.31.23.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 23:52:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Ilya Leoshkevich Subject: [PULL 10/20] accel/tcg: Make tb_htable_lookup static Date: Thu, 1 Sep 2022 07:52:00 +0100 Message-Id: <20220901065210.117081-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901065210.117081-1-richard.henderson@linaro.org> References: <20220901065210.117081-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" The function is not used outside of cpu-exec.c. Move it and its subroutines up in the file, before the first use. Reviewed-by: Alistair Francis Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 3 - accel/tcg/cpu-exec.c | 122 ++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 0475ec6007..9f35e3b7a9 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -552,9 +552,6 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs); #endif void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); -TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, - target_ulong cs_base, uint32_t flags, - uint32_t cflags); void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); /* GETPC is the true target of the return instruction that we'll execute. */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index d18081ca6f..7887af6f45 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -170,6 +170,67 @@ uint32_t curr_cflags(CPUState *cpu) return cflags; } +struct tb_desc { + target_ulong pc; + target_ulong cs_base; + CPUArchState *env; + tb_page_addr_t phys_page1; + uint32_t flags; + uint32_t cflags; + uint32_t trace_vcpu_dstate; +}; + +static bool tb_lookup_cmp(const void *p, const void *d) +{ + const TranslationBlock *tb = p; + const struct tb_desc *desc = d; + + if (tb->pc == desc->pc && + tb->page_addr[0] == desc->phys_page1 && + tb->cs_base == desc->cs_base && + tb->flags == desc->flags && + tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && + tb_cflags(tb) == desc->cflags) { + /* check next page if needed */ + if (tb->page_addr[1] == -1) { + return true; + } else { + tb_page_addr_t phys_page2; + target_ulong virt_page2; + + virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + phys_page2 = get_page_addr_code(desc->env, virt_page2); + if (tb->page_addr[1] == phys_page2) { + return true; + } + } + } + return false; +} + +static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, + target_ulong cs_base, uint32_t flags, + uint32_t cflags) +{ + tb_page_addr_t phys_pc; + struct tb_desc desc; + uint32_t h; + + desc.env = cpu->env_ptr; + desc.cs_base = cs_base; + desc.flags = flags; + desc.cflags = cflags; + desc.trace_vcpu_dstate = *cpu->trace_dstate; + desc.pc = pc; + phys_pc = get_page_addr_code(desc.env, pc); + if (phys_pc == -1) { + return NULL; + } + desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; + h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); + return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); +} + /* Might cause an exception, so have a longjmp destination ready */ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, target_ulong cs_base, @@ -485,67 +546,6 @@ void cpu_exec_step_atomic(CPUState *cpu) end_exclusive(); } -struct tb_desc { - target_ulong pc; - target_ulong cs_base; - CPUArchState *env; - tb_page_addr_t phys_page1; - uint32_t flags; - uint32_t cflags; - uint32_t trace_vcpu_dstate; -}; - -static bool tb_lookup_cmp(const void *p, const void *d) -{ - const TranslationBlock *tb = p; - const struct tb_desc *desc = d; - - if (tb->pc == desc->pc && - tb->page_addr[0] == desc->phys_page1 && - tb->cs_base == desc->cs_base && - tb->flags == desc->flags && - tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && - tb_cflags(tb) == desc->cflags) { - /* check next page if needed */ - if (tb->page_addr[1] == -1) { - return true; - } else { - tb_page_addr_t phys_page2; - target_ulong virt_page2; - - virt_page2 = (desc->pc & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; - phys_page2 = get_page_addr_code(desc->env, virt_page2); - if (tb->page_addr[1] == phys_page2) { - return true; - } - } - } - return false; -} - -TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, - target_ulong cs_base, uint32_t flags, - uint32_t cflags) -{ - tb_page_addr_t phys_pc; - struct tb_desc desc; - uint32_t h; - - desc.env = cpu->env_ptr; - desc.cs_base = cs_base; - desc.flags = flags; - desc.cflags = cflags; - desc.trace_vcpu_dstate = *cpu->trace_dstate; - desc.pc = pc; - phys_pc = get_page_addr_code(desc.env, pc); - if (phys_pc == -1) { - return NULL; - } - desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; - h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); - return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); -} - void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr) { if (TCG_TARGET_HAS_direct_jump) {