From patchwork Sat Jul 10 15:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 472368 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1375697jao; Sat, 10 Jul 2021 08:57:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ9XN2oRIx1i/vswjdxLvGJVlmYiWfdagfzd4PY9dZJ36XzPtzv85IhC3DtfLiV1r68OjU X-Received: by 2002:a05:6214:4b:: with SMTP id c11mr41862259qvr.18.1625932642786; Sat, 10 Jul 2021 08:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625932642; cv=none; d=google.com; s=arc-20160816; b=CF8pNl9cFxrlmkdcjnMZm1cZqHvIbFeLnMbQGbBQP+NAobGNvDUXzZKm4s1885iI5i NPi+1s5nVK1ITlqCQIOBFHNPCii0pyDm1Ss3Ldn5L6H4HCKO/UHQAkmmiFxrBf9h2nqb qnx12b7QpccIfBx4daPOLJrAO+JENaDbrr0ZDisBb2Dn9U/gWW8yAbDKfHGqqR+ikLNE RRaKZW/k1m+G0LCddGnbBLszLLuL4UJWuPttUN1aLKqnIiITdpztQWgBMGDxY+gc75Y1 Zx8JiTN+ILyT3flPOo7Z+y6QotbOkZO6zdMjnOe0ucz3Wrx4TXRQC3GjdxnLYuz08MkM Pjig== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=N9trJ1kjKGoNILkYQrFrW0/ogeTQmik7Rpq4HjTsUMQ=; b=aXnzvFTKVALIfPxQJ7xZ3wWkzVcaUnD/Y4UBVa5eP+alhSkTfhrbrN+/yn8Cv9X9M+ lkSTHnsmxlcsWfBJjPWI8Xmr9xVNDKjrv5kWpkZfpO/dLHLswnYJPvq/UmmPCyQaxWvO bU40/aOneKdCcat0rnJSrFEbKZbcFOR9Uc6CQTwcBOlNY8o8WWbKU6IwCxG+t6MVt/vC Fjcr3JHK5+Nm4ysBSnAwK3bh6SwCNYfpNkhO4pcWlhAxDbPE5YzSrcQwCWwK+ErAmgq8 uJ1aacghjaf/o9G+Z4LgKRJbXBv+pi4TYacRqv6fVDb4pSfU9ckjFS4iMps/+wNpxl7m 5Nuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tpns8aJP; 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 y124si8448350qke.378.2021.07.10.08.57.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jul 2021 08:57:22 -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=tpns8aJP; 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]:41552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m2FM2-0006SB-5X for patch@linaro.org; Sat, 10 Jul 2021 11:57:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2Exg-0006EJ-GS for qemu-devel@nongnu.org; Sat, 10 Jul 2021 11:32:12 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:46909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m2Exe-0002UK-PD for qemu-devel@nongnu.org; Sat, 10 Jul 2021 11:32:12 -0400 Received: by mail-pl1-x630.google.com with SMTP id c15so6622300pls.13 for ; Sat, 10 Jul 2021 08:32:10 -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=N9trJ1kjKGoNILkYQrFrW0/ogeTQmik7Rpq4HjTsUMQ=; b=tpns8aJPE6wLgu/SUznDn9IsAIvqw6libgybVkfiz6F7Y3v25IAa0nx32UMVNnniNk 9F80eI4iJZQroZV9B9+uuv/CC40RTKS5gTJ1N5xmPoQ4nJIyHzIHonNp8KSDvADhvPws KBMw/BBQp/sl9Vk7ojcB/cpCKGMZSrQUGqMPZsL6TYXjktruW3TPAx+S1lztwULkrtCU SQzlhN1tRwSbfrjCJthwBuqKgFD3txkSvaWk0tSVnWtEB3njyIrk54qYX/WiDTXhNZbr MOh529cfRrD2uudOY+d1OAh49wP2i74O3XwB7oiaoa+lt1VzPpEkqrIOs37DZ/VTmFh2 xIlA== 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=N9trJ1kjKGoNILkYQrFrW0/ogeTQmik7Rpq4HjTsUMQ=; b=h2QOHa5KPzgMdCBAUjJmrur9+05l534ZMjA4eEsGOE2Vh37QAyQasLrKXop/v3cIh1 l8oK6Rfiy1mXz3lqikTZrauqnEpjBkCF1x20eVvLLw5HOXnmWvwbmRvpeVU0/Nbn1nGN lZXUIP+dnjLPCmnYuPTf1Wcao1hLIJb5Bfhdn7QAdz/dno4B4c85kaIFSkRvMbkzXyRQ Uut50YA12NErim+GpB4j2l8jmsplWG/6Z4KgvajMkYkho2F2lyHnn41Nd2dOjMJZsVQH Xv3ClbEW4zM6408nAYeysR7hS37FgBVtB1tPifeEzNR3/1ThBJ830kv94vVjrPRGhSOF B0uA== X-Gm-Message-State: AOAM531juDcZL6VYnPeGDhpH1+SSY4HsowrKEEDMucvB8gMNQq2HVbED oc6c7WcLqFNlcYE7vWkQ5BNP2VTo9Df+Jg== X-Received: by 2002:a17:902:9895:b029:128:cdfb:f389 with SMTP id s21-20020a1709029895b0290128cdfbf389mr35038289plp.45.1625931129519; Sat, 10 Jul 2021 08:32:09 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id u23sm11975374pgk.38.2021.07.10.08.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 08:32:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 37/41] accel/tcg: Move tb_lookup to cpu-exec.c Date: Sat, 10 Jul 2021 08:31:39 -0700 Message-Id: <20210710153143.1320521-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710153143.1320521-1-richard.henderson@linaro.org> References: <20210710153143.1320521-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that we've moved helper_lookup_tb_ptr, the only user of tb-lookup.h is cpu-exec.c; merge the contents in. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/tb-lookup.h | 49 ------------------------------------------- accel/tcg/cpu-exec.c | 31 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 50 deletions(-) delete mode 100644 accel/tcg/tb-lookup.h -- 2.25.1 diff --git a/accel/tcg/tb-lookup.h b/accel/tcg/tb-lookup.h deleted file mode 100644 index 9c9e0079da..0000000000 --- a/accel/tcg/tb-lookup.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2017, Emilio G. Cota - * - * License: GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ -#ifndef EXEC_TB_LOOKUP_H -#define EXEC_TB_LOOKUP_H - -#ifdef NEED_CPU_H -#include "cpu.h" -#else -#include "exec/poison.h" -#endif - -#include "exec/exec-all.h" -#include "tb-hash.h" - -/* Might cause an exception, so have a longjmp destination ready */ -static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, - target_ulong cs_base, - uint32_t flags, uint32_t cflags) -{ - TranslationBlock *tb; - uint32_t hash; - - /* we should never be trying to look up an INVALID tb */ - tcg_debug_assert(!(cflags & CF_INVALID)); - - hash = tb_jmp_cache_hash_func(pc); - tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); - - if (likely(tb && - tb->pc == pc && - tb->cs_base == cs_base && - tb->flags == flags && - tb->trace_vcpu_dstate == *cpu->trace_dstate && - tb_cflags(tb) == cflags)) { - return tb; - } - tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); - if (tb == NULL) { - return NULL; - } - qatomic_set(&cpu->tb_jmp_cache[hash], tb); - return tb; -} - -#endif /* EXEC_TB_LOOKUP_H */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index fb6668606f..0d92698030 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -40,7 +40,6 @@ #include "sysemu/replay.h" #include "exec/helper-proto.h" #include "tb-hash.h" -#include "tb-lookup.h" #include "tb-context.h" #include "internal.h" @@ -146,6 +145,36 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu) } #endif /* CONFIG USER ONLY */ +/* Might cause an exception, so have a longjmp destination ready */ +static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, + target_ulong cs_base, + uint32_t flags, uint32_t cflags) +{ + TranslationBlock *tb; + uint32_t hash; + + /* we should never be trying to look up an INVALID tb */ + tcg_debug_assert(!(cflags & CF_INVALID)); + + hash = tb_jmp_cache_hash_func(pc); + tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); + + if (likely(tb && + tb->pc == pc && + tb->cs_base == cs_base && + tb->flags == flags && + tb->trace_vcpu_dstate == *cpu->trace_dstate && + tb_cflags(tb) == cflags)) { + return tb; + } + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); + if (tb == NULL) { + return NULL; + } + qatomic_set(&cpu->tb_jmp_cache[hash], tb); + return tb; +} + /** * helper_lookup_tb_ptr: quick check for next tb * @env: current cpu state