From nobody Tue Feb 10 04:07:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1614186341; cv=none; d=zohomail.com; s=zohoarc; b=evy3FDXdTlEn7bKSpKZ2PMHWhF30Jb2zAO5puQa4KW0zMdUh8XfbI5GnrHwYPVswKJMi2fC2dVoBkREF+lpEMzpbrI6HvgniSMHzzJRs02KWkzrH+IgYmoTV0mpReBHosGdWc+86WspgAb0CT9x1rdxffaHrHWUsbKsUcWOKnd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614186341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AwSqA5g84lGAhAL1w2zSXZBGJIZPg/hYExK6AypbDmU=; b=XKGC78obuhx6Iu8ySW5bV4qavTOF/owiTvbvuEWqTvU70MO+NjlWEM6b/zQKaJd9XhIg5tVEj7HFYeidAnLHfSS+uKbL016vliLoGKS4lzVm4kmqAFwXGVfhiH2x3tJ/Q9OrMZ6s0FzZ/btRt8KO7GNoahwp1ji+G9ZGDYFy57E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614186341038444.6966869039311; Wed, 24 Feb 2021 09:05:41 -0800 (PST) Received: from localhost ([::1]:39556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lExbX-0008PA-W7 for importer@patchew.org; Wed, 24 Feb 2021 12:05:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lExUU-0003HL-Oo for qemu-devel@nongnu.org; Wed, 24 Feb 2021 11:58:24 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:53261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lExUN-00072g-MU for qemu-devel@nongnu.org; Wed, 24 Feb 2021 11:58:22 -0500 Received: by mail-wm1-x32e.google.com with SMTP id x16so2381861wmk.3 for ; Wed, 24 Feb 2021 08:58:14 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g63sm4150970wma.40.2021.02.24.08.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 08:58:12 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7721D1FF87; Wed, 24 Feb 2021 16:58:11 +0000 (GMT) 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=AwSqA5g84lGAhAL1w2zSXZBGJIZPg/hYExK6AypbDmU=; b=JIroZYon6oOABliT3VnssgHgpzb0aXrMsoYARFHKPdWe8I7MwMnOmcXEVejPamlAoE IjXcU0E9ULHHIZPdxytl59yS/il3RimpmD8u5tvhU2tlTbezR7YEUfbwdvxQ27u+EPjY Gp9TqNT3RWP6XlQ5LjrLBBL4nujg31uThuNrfH2aAxyn0ljChX0jl8JfuIpzM/2mlzD2 TIjAlnIdJKsFHpydU7S8ivqZBqyguWWNapOF0vRVQ4NqdIKrl+6JB4p7g/455pQflYjv uX5g+ZZ7lASMcjkPIDi4KjLZDNoQjkr/ZAA2rQxiRvZT+LafX2H9qA/XhA60E4rDXTlW 1OEg== 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=AwSqA5g84lGAhAL1w2zSXZBGJIZPg/hYExK6AypbDmU=; b=ltGNUhDoxz3dzKYEP9eyzTpt9EWIvMsJaaz5wEgQbcHU8latml3kApVTWlWVNA5+R5 h0w0mlQb/zcLKOFiZGiIHcsgFU6XANWSw3XOLlA8uaguuGlbOxXU2l9KpusXV0YbLzy2 FAdplRVv8vE16DkM4xTLRZeA7Loo0SGGwoul32tLzVO+QEl3E62BOxtfKW7G/e2eG7rQ hzdSSy9sxL8FJA5lcIeL1fRg99+A5PWwW+Zasu0kjat+UUpvHw/e6ENzgeN40m/VgwSW yuEBz2T1/mLDKkryy75DcFmjug5Yn+NQXjD456g5FTrWZjmRMjA+ndAwi7mqU1IjNbTq xwHA== X-Gm-Message-State: AOAM530bknZwrYYQzGuvL0TylGO53kk4Glh6sZm2J59D2vEx8UQP0lOe 8/4iOhiGWVLFH57t/xy2yJlvVA== X-Google-Smtp-Source: ABdhPJxvnvvYUbpxSDEMX9JEGKnc7WYNafK/uqc2RIKpvFoTmpN4ogcFyC7OzB4XDC0i4+kt7/baOg== X-Received: by 2002:a1c:c903:: with SMTP id f3mr4548876wmb.69.1614185893103; Wed, 24 Feb 2021 08:58:13 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: richard.henderson@linaro.org Subject: [RFC PATCH 1/5] accel/tcg: rename tb_lookup__cpu_state and hoist state extraction Date: Wed, 24 Feb 2021 16:58:07 +0000 Message-Id: <20210224165811.11567-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210224165811.11567-1-alex.bennee@linaro.org> References: <20210224165811.11567-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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: Paolo Bonzini , cota@braap.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Having a function return either and valid TB and some system state seems excessive. It will make the subsequent re-factoring easier if we lookup the current state where we are. Signed-off-by: Alex Benn=C3=A9e --- include/exec/tb-lookup.h | 18 ++++++++---------- accel/tcg/cpu-exec.c | 10 ++++++++-- accel/tcg/tcg-runtime.c | 4 +++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h index 9cf475bb03..62a509535d 100644 --- a/include/exec/tb-lookup.h +++ b/include/exec/tb-lookup.h @@ -17,30 +17,28 @@ #include "exec/tb-hash.h" =20 /* Might cause an exception, so have a longjmp destination ready */ -static inline TranslationBlock * -tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_bas= e, - uint32_t *flags, uint32_t cf_mask) +static inline TranslationBlock * tb_lookup(CPUState *cpu, + target_ulong pc, target_ulong c= s_base, + uint32_t flags, uint32_t cf_mas= k) { - CPUArchState *env =3D (CPUArchState *)cpu->env_ptr; TranslationBlock *tb; uint32_t hash; =20 - cpu_get_tb_cpu_state(env, pc, cs_base, flags); - hash =3D tb_jmp_cache_hash_func(*pc); + hash =3D tb_jmp_cache_hash_func(pc); tb =3D qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); =20 cf_mask &=3D ~CF_CLUSTER_MASK; cf_mask |=3D cpu->cluster_index << CF_CLUSTER_SHIFT; =20 if (likely(tb && - tb->pc =3D=3D *pc && - tb->cs_base =3D=3D *cs_base && - tb->flags =3D=3D *flags && + tb->pc =3D=3D pc && + tb->cs_base =3D=3D cs_base && + tb->flags =3D=3D flags && tb->trace_vcpu_dstate =3D=3D *cpu->trace_dstate && (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) =3D=3D cf_mas= k)) { return tb; } - tb =3D tb_htable_lookup(cpu, *pc, *cs_base, *flags, cf_mask); + tb =3D tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask); if (tb =3D=3D NULL) { return NULL; } diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 16e4fe3ccd..ef96b312a1 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -245,6 +245,7 @@ static void cpu_exec_exit(CPUState *cpu) =20 void cpu_exec_step_atomic(CPUState *cpu) { + CPUArchState *env =3D (CPUArchState *)cpu->env_ptr; TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; @@ -258,7 +259,9 @@ void cpu_exec_step_atomic(CPUState *cpu) g_assert(!cpu->running); cpu->running =3D true; =20 - tb =3D tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); + tb =3D tb_lookup(cpu, pc, cs_base, flags, cf_mask); + if (tb =3D=3D NULL) { mmap_lock(); tb =3D tb_gen_code(cpu, pc, cs_base, flags, cflags); @@ -418,11 +421,14 @@ static inline TranslationBlock *tb_find(CPUState *cpu, TranslationBlock *last_tb, int tb_exit, uint32_t cf_mask) { + CPUArchState *env =3D (CPUArchState *)cpu->env_ptr; TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; =20 - tb =3D tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); + + tb =3D tb_lookup(cpu, pc, cs_base, flags, cf_mask); if (tb =3D=3D NULL) { mmap_lock(); tb =3D tb_gen_code(cpu, pc, cs_base, flags, cf_mask); diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index d736f4ff55..05e3d52c2f 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -152,7 +152,9 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) target_ulong cs_base, pc; uint32_t flags; =20 - tb =3D tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); + + tb =3D tb_lookup(cpu, pc, cs_base, flags, curr_cflags()); if (tb =3D=3D NULL) { return tcg_code_gen_epilogue; } --=20 2.20.1