From patchwork Wed Feb 6 04:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 157553 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5974566jaa; Tue, 5 Feb 2019 20:36:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJcVcJc45FgfJxngbYcz9jx4DF1CJc20JREEsMXNOAPvevRSGc4o2vE9PH2WaIIHkLybS7 X-Received: by 2002:a81:6246:: with SMTP id w67mr7018120ywb.60.1549427765949; Tue, 05 Feb 2019 20:36:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549427765; cv=none; d=google.com; s=arc-20160816; b=NqrstuZIL6VxY5R8RqZGdTpTSw5g4/mOWgOVuH8A/8zZWUvk9ZEHDXRaDPVH/kU9wH LTHGBJPCpiNcxr1GF4TxZbBEvITnyrhkVfRT3ME35+iy0BxR4nnDbJxR790966rk3VzS okgg5AnF0vpq/9d0jiWOJz1qnvaIOkJohSLCogIXosvwF4Be/nUToIoAV6pVCOBKB6G1 Jwas35wY7kWrpXYess70pmIIsBzCSbMzU36H/O73MjVTrXMwWFdFJC759rHST0EtLd9n 11Ee6t4d0faW5v9PfAvJEOzAPK2COQ3TOOjtJ1+zExI/aqsg5F+8H47/IiLAzIOQZjUs fbBg== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=G7xyjQ5I4ikKCmR0R0iMN0Nm7+eGJ4RmAdhai8noOjI=; b=okklgfSOKqUdWB++GKFJNWj1lAIC8gTFbI4huNJs9wJUwr/32o07oDKSgFqUNK+44Y Qn+fnAUWrH+/RtgN+xZaG1UKkvo9RrTTcqCajrJEKs4J8UIgR5eyrQNg8YOIMhOuie3+ poHcopyvdiPFtI4r5A7pedWOLVabBY3wa9OlSkOFvaoEoRnsAVQxyr3+p5jQhGnZWgzy ycMr6ON8WqIgLI14AYM0MNb0weSTQsWm02r7a2cVvm3L29Pu5zryapflPS6rgL++qxkM c6IfNjg0ndTT/VClqfrU70peoCWzqmkF/29MWxlujwj2TJn3JYuU2Cmz1KISmNPZI7p1 NfvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xEWay8Z1; 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=fail (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 y11si2764739ybr.486.2019.02.05.20.36.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Feb 2019 20:36:05 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=xEWay8Z1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:44901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grEwP-0001Uj-8z for patch@linaro.org; Tue, 05 Feb 2019 23:36:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grEvz-0001TR-Sm for qemu-devel@nongnu.org; Tue, 05 Feb 2019 23:35:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grEvy-0007Tl-Ru for qemu-devel@nongnu.org; Tue, 05 Feb 2019 23:35:39 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:54120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1grEvx-0007Mu-PZ for qemu-devel@nongnu.org; Tue, 05 Feb 2019 23:35:38 -0500 Received: by mail-wm1-x334.google.com with SMTP id d15so1064307wmb.3 for ; Tue, 05 Feb 2019 20:35:28 -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:in-reply-to:references; bh=G7xyjQ5I4ikKCmR0R0iMN0Nm7+eGJ4RmAdhai8noOjI=; b=xEWay8Z1U/5g45is3Owz3eQm4xAI2x5Q3T7nhngx3bOY/2ywt9OMyqe+0VriYe9Cji DOkJsLPaDs+EhZvLwkL57hluMAg3vAji6emMNMsvXYwORv+/SZHH2uuQF9KNo9XrQ47Q kuPBY6rXyfe31FAsB/Cdyjgtqku3KEp4/zJAfHh5f4cZx4IQ4j2RWjcqGB1YkbzqrKO3 mh7lJ+1kedmoBgoNVzSHS5pGjuY6CWL293uvP1ihin1qwjD2eyFrU+qwPX4IiVk8+DYl nHJ/fXYTdqF361sEF2aYuPq220uE1acSVfAWXTIQJlk4nnr0zGJO/hgRZKdMCJvPhkxY WfkQ== 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; bh=G7xyjQ5I4ikKCmR0R0iMN0Nm7+eGJ4RmAdhai8noOjI=; b=Au62MURepDJpztBUtqKdWlCARusPzoE5BhsTA5pS8+UKsK7xubFhXAhfVnYKjOJWR+ RJQwpnlpeR7H8rCY886fGbMv98Cx77vHMgozwnEMZlgjEoms9RcI5MCop91dqcmqBMKf E4fLGuc9qBXLamMvde+CG5kGcbrYDIv1zL02SLoJKuY7gWrjl/zzwW3qwdU2/rQDF+vU 1kDVKyIZdsjW1TtnPes+Vau92xNiPMTIA4caxVFGNn2yd0sltL54ZJuiJPkHVZkpZmV4 ZOGeZ3+H1P9ejSAbPDeFqbARGCKXVvnelSuUmzb5dAVHI9I9kb314XFK88p9HMMvno8j mcLg== X-Gm-Message-State: AHQUAuasnjL+6KsarcyIynZpJq97Zw+ZNWfDryn9n/nsY0K3wGdTGsJ6 Rvj8EB47QPT245OSVERJ0IGRRfba8pBeBg== X-Received: by 2002:a1c:2088:: with SMTP id g130mr1332485wmg.122.1549427727420; Tue, 05 Feb 2019 20:35:27 -0800 (PST) Received: from cloudburst.twiddle.net (host81-133-38-158.in-addr.btopenworld.com. [81.133.38.158]) by smtp.gmail.com with ESMTPSA id x186sm30255006wmg.41.2019.02.05.20.35.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 20:35:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Feb 2019 04:35:16 +0000 Message-Id: <20190206043516.11462-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190206043516.11462-1-richard.henderson@linaro.org> References: <20190206043516.11462-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 Subject: [Qemu-devel] [PULL 2/2] 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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") Tested-by: Cleber Rosa Tested-by: Mark Cave-Ayland Reported-by: Howard Spoelstra Reported-by: Cleber Rosa Signed-off-by: Peter Maydell Message-Id: <20190205151810.571-1-peter.maydell@linaro.org> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- include/exec/tb-lookup.h | 4 ++++ accel/tcg/cpu-exec.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) -- 2.17.2 diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h index 492cb68289..26921b6daf 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, target_ulong *cs_base, cpu_get_tb_cpu_state(env, pc, cs_base, flags); hash = tb_jmp_cache_hash_func(*pc); tb = atomic_rcu_read(&cpu->tb_jmp_cache[hash]); + + cf_mask &= ~CF_CLUSTER_MASK; + cf_mask |= cpu->cluster_index << CF_CLUSTER_SHIFT; + if (likely(tb && tb->pc == *pc && tb->cs_base == *cs_base && diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7cf1292546..60d87d5a19 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -325,9 +325,6 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, struct tb_desc desc; uint32_t h; - cf_mask &= ~CF_CLUSTER_MASK; - cf_mask |= cpu->cluster_index << CF_CLUSTER_SHIFT; - desc.env = (CPUArchState *)cpu->env_ptr; desc.cs_base = cs_base; desc.flags = flags;