From nobody Fri Nov 7 07:36:08 2025 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 1548084264664827.3159871131422; Mon, 21 Jan 2019 07:24:24 -0800 (PST) Received: from localhost ([127.0.0.1]:55174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glbR1-0000dm-Ca for importer@patchew.org; Mon, 21 Jan 2019 10:24:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glbPK-00080I-UZ for qemu-devel@nongnu.org; Mon, 21 Jan 2019 10:22:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glbPH-0003uh-1P for qemu-devel@nongnu.org; Mon, 21 Jan 2019 10:22:37 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:32768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1glbPD-0003rd-QN for qemu-devel@nongnu.org; Mon, 21 Jan 2019 10:22:33 -0500 Received: by mail-wm1-x343.google.com with SMTP id r24so6401484wmh.0 for ; Mon, 21 Jan 2019 07:22:27 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o16sm128900134wrn.11.2019.01.21.07.22.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jan 2019 07:22:25 -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 :mime-version:content-transfer-encoding; bh=dhk3Zq9opGnAhyvLiJeHk55/147P47tsFD5cqMO13d8=; b=K7+FLLDPLAxC0VDE6tMo41Aa3M6C0B7zOo4ffLGlZcFAYtf1qdX+KU3HcB9IBFU0iy +tibzap5rv1Sqh0DxlF3+uJNlyoTYHIpEgO3BO/tpMFScVrIAwNdfLzImUXk/gFT6Y/s aOt1CquEURvucu3thODoLJieoCuXM+813skGc= 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=dhk3Zq9opGnAhyvLiJeHk55/147P47tsFD5cqMO13d8=; b=HkbEDMFD0u+fLmD4WuwrrpsDYzCVHjkj8wacNv0JGiZeLP8exS2V44oBkmhvNDv7Jk Ypc9rxTQLCSVTuC3ivBcQILHvb8WU16bOzfEqdvp9RGbOUhRYMxnMdFLCh3VSNvyxt23 O4lGDm6321Ix8GmWcXG0UR51yk+Z+b2YamHhYW3iyx/PwnL49rhec/Ye8zBOxoD1b0RW owXBkOxtudd2OBOpqPmlN7MbZo9o7Fa5oGTxY9ib827i45vsEmP+hmBTtkAq08uSCvXf IBQEH31KcWhxG/U2TzSV3mNUd7D55LHjOGziALvo6sCxmwpNBYRSuucHNeIwSXYH56da V7cQ== X-Gm-Message-State: AJcUukd++pMkCF056SlOPvtU/XzQY1i4eHLXo+DmqMLiweiyHQ70osFc SS0Sk6guinfMk+NfNpt61vGbHw== X-Google-Smtp-Source: ALg8bN4LXA3LaMnr8DUii8D2LAzSyCnhD20dD0lvYVo7GHNOzaaer642qrJxOLgzXsZu4nzOdqmLlg== X-Received: by 2002:a1c:bdc5:: with SMTP id n188mr26632670wmf.69.1548084146172; Mon, 21 Jan 2019 07:22:26 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Mon, 21 Jan 2019 15:22:17 +0000 Message-Id: <20190121152218.9592-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121152218.9592-1-peter.maydell@linaro.org> References: <20190121152218.9592-1-peter.maydell@linaro.org> 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::343 Subject: [Qemu-devel] [PATCH v3 3/4] accel/tcg: Add cluster number to TCG TB hash 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: Eduardo Habkost , Peter Crosthwaite , Alistair Francis , Richard Henderson , "Emilio G . Cota" , "Edgar E. Iglesias" , Paolo Bonzini , Aleksandar Markovic 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" Include the cluster number in the hash we use to look up TBs. This is important because a TB that is valid for one cluster at a given physical address and set of CPU flags is not necessarily valid for another: the two clusters may have different views of physical memory, or may have different CPU features (eg FPU present or absent). We put the cluster number in the high 8 bits of the TB cflags. This gives us up to 256 clusters, which should be enough for anybody. If we ever need more, or need more bits in cflags for other purposes, we could make tb_hash_func() take more data (and expand qemu_xxhash7() to qemu_xxhash8()). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- v1->v2: move the setting of the cluster index in cf_mask in tb_htable_lookup() up to before we set desc.cf_mask from it... --- include/exec/exec-all.h | 4 +++- accel/tcg/cpu-exec.c | 3 +++ accel/tcg/translate-all.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 815e5b1e838..aa7b81aaf01 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -351,9 +351,11 @@ struct TranslationBlock { #define CF_USE_ICOUNT 0x00020000 #define CF_INVALID 0x00040000 /* TB is stale. Set with @jmp_lock held = */ #define CF_PARALLEL 0x00080000 /* Generate code for a parallel context = */ +#define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ +#define CF_CLUSTER_SHIFT 24 /* cflags' mask for hashing/comparison */ #define CF_HASH_MASK \ - (CF_COUNT_MASK | CF_LAST_IO | CF_USE_ICOUNT | CF_PARALLEL) + (CF_COUNT_MASK | CF_LAST_IO | CF_USE_ICOUNT | CF_PARALLEL | CF_CLUSTER= _MASK) =20 /* Per-vCPU dynamic tracing state used to generate this TB */ uint32_t trace_vcpu_dstate; diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 870027d4359..6c4a33262f5 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -325,6 +325,9 @@ 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; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 8cb8c8870e6..7364e8a071f 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1688,6 +1688,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, cflags |=3D CF_NOCACHE | 1; } =20 + cflags &=3D ~CF_CLUSTER_MASK; + cflags |=3D cpu->cluster_index << CF_CLUSTER_SHIFT; + buffer_overflow: tb =3D tb_alloc(pc); if (unlikely(!tb)) { --=20 2.20.1