From patchwork Tue Aug 23 22:05:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 599488 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2739854mae; Tue, 23 Aug 2022 15:12:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR456HYFabNWgoPaeYlGjlEIcwodKbPjx9KIX2LrX8YrZnsrhyumBMPDWPAxK401KUxNTzQS X-Received: by 2002:a05:6214:d89:b0:48f:7dcf:2914 with SMTP id e9-20020a0562140d8900b0048f7dcf2914mr22191836qve.52.1661292770287; Tue, 23 Aug 2022 15:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661292770; cv=none; d=google.com; s=arc-20160816; b=E806TNl8rQT4HR/BedFOFVtunGqU1ybmLvI8/Ieq1lZ8vllnduFd6D9TX0vMbKCPI1 GpwvgDCn67ih1t6a6XOPcFzCpSUfaUaby02Yh2aobIZHiYGjkKNYYPEJoGwTQw8DOEd/ 8HXtTrkU2UeyXnsvT57IiQDNCWWo1/lW+9OnwiIs8YRL/+0pXwf6XpcFuyQEmoG4FaEf PdshNG4csqTeUu5t1Z6y/auhYkuiBLDuNJB95gTSMzyqPrxGJB3SzrdJebyjpTk+xWA0 RVXYzzQBFqzYPoxXaOqHFAYYLGhIpfuoMJaO8CK02JsmVtsmQefIIdSjAMSUtz5T++9A vxsg== 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=slmhndayqMXp90TqeP/OmGrZ8It9AGaWY5HDWYj6Y4gjEzPvoUhr4TSg2AFBTM8GCm K1m8rvL5qVWAN+SufvTBFM3UVdazEaB/FlnlPaCr3OuvuXAHecImC623WUrkXNl+h80H z+njUtxr3t1py56BDCo+Son3eYzhS3rPrqTw8iBS6jlwR36EoDv5hVliZPFreNl4fIOs 5Eya6D/Es6AQCCCISIN6m+2JSSR5BGmKmlnk1AGsZSyhC8AuG9fGTc0sAtGJy6sNoE9S X+UpmarheY49n7hdTQq0ILWyp4pgOfvJNpUKppVpzA81yLYg0thmGrPCxrQjSeqnUmT6 dg4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PcZoUszI; 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 b134-20020ae9eb8c000000b006bb0a32f675si6232623qkg.335.2022.08.23.15.12.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Aug 2022 15:12:50 -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=PcZoUszI; 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]:51360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQc8f-0003Dy-SX for patch@linaro.org; Tue, 23 Aug 2022 18:12:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQc24-00005l-Np for qemu-devel@nongnu.org; Tue, 23 Aug 2022 18:06:00 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:42764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQc22-0001R5-Qv for qemu-devel@nongnu.org; Tue, 23 Aug 2022 18:06:00 -0400 Received: by mail-pj1-x102a.google.com with SMTP id s3-20020a17090a2f0300b001facfc6fdbcso15387453pjd.1 for ; Tue, 23 Aug 2022 15:05:57 -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=PcZoUszIsAlyZIlFXHh9MmxDi5j81nkgQG40bead2FwhIc3CSa3hsub4h5oHEUvkNg 2I/YRGUblT8sJ4PRpddA7HixGMlpHgPHSgCB4jkANf6A0CTY0tr+zfeixvTOCgFsCPnt Ts/S5uvQGO1QX7qxNnYIcYHoGfzVfUE8Ooi3lVVXVN6aiTgvZsKWIfwh3qU5Umbo4sxm AMAbwXTFt1mBnrmOLgiDLMS2R83xz7vIm0bIBOyqHgkHWuZU5787dcRjeIppW7EnqImt UKR/jwM/BLputtmPil0UP4Ruh8NNq+dMwepgH6Tw5D34xP5l7Th2yI/uPxJ4sJivu3fp UYYQ== 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=ivxNgXtYvSffEZhI8lDIJ1/L1QARIrEwr9FfkJjeoR3ELj8o1Yc+wzTULQM0di4L9G vdsRWA0q6GWJfRhTJYkE6CI22A8z1z9hK92fPyUiAaJyS76YiF9kI0DrBN29fRay8uET Dhbj3GMfK1jte8Wr3Llq+Ed6Xeb4EK2F7lawcVeA+Dn6CeEabZ8i2UUipmSrBGMYQFdY +1rkFQI7fnHAV+wf9TDoO4gFa/FOAY41/o6Y0p93J4eFTtwLo3wwR+rYE6kKwg3Op/s7 nAx9kVzDUY50JO3NR36ZgAAt9TEitRmFR9nSxEwmGFxO0Kt2BRBA7neO47Sz362etUfN OI4w== X-Gm-Message-State: ACgBeo1SDIUrzOKK+FmKx0AWRjHKRtD/r0MxXWj+h44WPiVvuEuyD/4w iy1ButBwmwyivBnCAhShc23sq9wNQFATHw== X-Received: by 2002:a17:903:1cb:b0:173:1015:d004 with SMTP id e11-20020a17090301cb00b001731015d004mr1870498plh.165.1661292356481; Tue, 23 Aug 2022 15:05:56 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:46f9:77b4:ec0a:c2d9]) by smtp.gmail.com with ESMTPSA id n12-20020a170902f60c00b0017292073839sm11020974plg.178.2022.08.23.15.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 15:05:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, laurent@vivier.eu, alex.bennee@linaro.org, Alistair Francis Subject: [PATCH v7 10/20] accel/tcg: Make tb_htable_lookup static Date: Tue, 23 Aug 2022 15:05:32 -0700 Message-Id: <20220823220542.1993395-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220823220542.1993395-1-richard.henderson@linaro.org> References: <20220823220542.1993395-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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) {