From nobody Sun Apr 28 17:48:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549380082525363.1834339307542; Tue, 5 Feb 2019 07:21:22 -0800 (PST) Received: from localhost ([127.0.0.1]:33633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr2XH-0005Id-CQ for importer@patchew.org; Tue, 05 Feb 2019 10:21:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr2Um-0003tb-5L for qemu-devel@nongnu.org; Tue, 05 Feb 2019 10:18:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gr2Ue-0007KN-Gc for qemu-devel@nongnu.org; Tue, 05 Feb 2019 10:18:40 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gr2UL-000799-U8 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 10:18:20 -0500 Received: by mail-wm1-x344.google.com with SMTP id y139so4007510wmc.5 for ; Tue, 05 Feb 2019 07:18:14 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id g9sm16723290wmg.44.2019.02.05.07.18.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 07:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7qUxvj1e/FbpomWdSZsVf+MBefrp8zJTv578oPpEehg=; b=wNYpQu+ZdSxSSz/FpF0nV3/aeGp6eTwZa1kcH5nvRdSFHq+P3hhH/uNmcqFuuGz5I5 pQp3oiOWDIiXbpmK48+Mm1wY699WKT0xpgYAEhsjhB/iFQwMFBSh1XJw9rn/L9HvtDsX BJ5spyxtXKW7DXMjtFKUjZzAd8IhJ6B9DVdAGtd8sfFJviyNW06gAo5rjWii3Jbf78tC yqPsvvYjR4eoIN/o284uWBmF1wwTuBB4tS+RyuxjrjvQ9ECZ3qtC8Ns1MNxhOi1yBLOz BJJGOMLxWGpAdXSgUBVhHtwipo+Jm9hb5/TNc9a1ouLVxwpQAP7oMcyaoEX2RHdas1/7 KUlQ== 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:mime-version :content-transfer-encoding; bh=7qUxvj1e/FbpomWdSZsVf+MBefrp8zJTv578oPpEehg=; b=qP6msmjAjyZLXalK2AtCXNPaIE5T6aSHuin9n1HxaOyKfIrOFiNmlNT2Yt76Bw1/ST MkXUP7X/XI2qoEKY5AQB5MoMAjRqUmUcs04U0eJ8moVaXyf2iWnm29/FlaVBmPgKgx81 jUyMNLYofRaKDceXc1HKUG+kWQ3EInjjciYMnZgxYGn7Hb1xDvYJr92MD81aw3qHS+Bt g+/7tc6vRIPCNqeAkecgLDSpF6C1TqBp9jjbh8GI0iFUd6gw62Kv+NtO7jg0lbA6B/CD TP7YgRmLFuGrhkCFfvN1TuX/wtrin6X1MvbVIOge8qYDfG+hMCPrglsat/IjlgNe7IG1 uKjg== X-Gm-Message-State: AHQUAuZercRudGSJn8m4tE3k6ZXsjRGg0EakPeDebEn3YrmIgsYr9djh GQqiux5oXEOujmCUt/fJNneCzN8MIhTMUQ== X-Google-Smtp-Source: AHgI3IYD6mMHwu8W+j29HAxnjuh45bu6CM8v61pP4qT7OEeNk4+MAOWgi1VapNLzRVx5OpFCC4DkIQ== X-Received: by 2002:a1c:7510:: with SMTP id o16mr4172817wmc.38.1549379893213; Tue, 05 Feb 2019 07:18:13 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 15:18:10 +0000 Message-Id: <20190205151810.571-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH] accel/tcg: Consider cluster index in tb_lookup__cpu_state() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@linaro.org, Richard Henderson , Howard Spoelstra , Mark Cave-Ayland , "Emilio G . Cota" , Cleber Rosa , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In commit f7b78602fdc6c6e4be we added the CPU cluster number to the cflags field of the TB hash; this included adding it to the value kept in tb->cflags, since we pass that field directly into the hash calculation in some places. Unfortunately we forgot to check whether other parts of the code were doing comparisons against tb->cflags that would need to be updated. It turns out that there is exactly one such place: the tb_lookup__cpu_state() function checks whether the TB it has found in the tb_jmp_cache has a tb->cflags matching the cf_mask that is passed in. The tb->cflags has the cluster_index in it but the cf_mask does not. Hoist the "add cluster index to the cf_mask" code up from tb_htable_lookup() to tb_lookup__cpu_state() so it can be considered in the "did this TB match in the jmp cache" condition, as well as when we do the full hash lookup by physical PC, flags, etc. (tb_htable_lookup() is only called from tb_lookup__cpu_state(), so this change doesn't require any further knock-on changes.) Fixes: f7b78602fdc6c6e4be ("accel/tcg: Add cluster number to TCG TB hash") Reported-by: Howard Spoelstra Reported-by: Cleber Rosa Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Tested-by: Cleber Rosa Tested-by: Mark Cave-Ayland --- Does anybody know why tb_lookup__cpu_state() has that odd double-underscore in the middle of its name? Since the jmp_cache is per-vcpu we know that we're always going to match on the cluster_index, so the other option would be to leave the cluster_index bits out of the comparison, and leave the "fold in cluster index to cf_mask" code in tb_htable_lookup(). Or we could require the callers of tb_lookup__cpu_state() to all provide the cluster index, but that's more places to change, so I prefer this. --- include/exec/tb-lookup.h | 4 ++++ accel/tcg/cpu-exec.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h index 492cb682894..26921b6dafd 100644 --- a/include/exec/tb-lookup.h +++ b/include/exec/tb-lookup.h @@ -28,6 +28,10 @@ tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, ta= rget_ulong *cs_base, cpu_get_tb_cpu_state(env, pc, cs_base, flags); hash =3D tb_jmp_cache_hash_func(*pc); tb =3D atomic_rcu_read(&cpu->tb_jmp_cache[hash]); + + cf_mask &=3D ~CF_CLUSTER_MASK; + cf_mask |=3D cpu->cluster_index << CF_CLUSTER_SHIFT; + if (likely(tb && tb->pc =3D=3D *pc && tb->cs_base =3D=3D *cs_base && diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7cf1292546f..60d87d5a19b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -325,9 +325,6 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, targe= t_ulong pc, struct tb_desc desc; uint32_t h; =20 - cf_mask &=3D ~CF_CLUSTER_MASK; - cf_mask |=3D cpu->cluster_index << CF_CLUSTER_SHIFT; - desc.env =3D (CPUArchState *)cpu->env_ptr; desc.cs_base =3D cs_base; desc.flags =3D flags; --=20 2.20.1