From patchwork Tue Jan 8 16:30:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 154991 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5070152jaa; Tue, 8 Jan 2019 08:30:16 -0800 (PST) X-Received: by 2002:a1c:ac42:: with SMTP id v63mr2201333wme.119.1546965015857; Tue, 08 Jan 2019 08:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546965015; cv=none; d=google.com; s=arc-20160816; b=TAhcp3NyoowhP3LcFj6tmkJVSRrrGuZpP1zqzZvsfbPD+/gWg74wlfTgXvElriq0YL LTKn1Z7RFLjSEm2EusTTUy5Oi4YggiA2KpjkbALvd07t4vyjbjmD0h5Yz1mYAFxivWLg MN1/LRKCEl0+eGnG6TD3gb3kDo6FYaQn7ikFwYeothpipn1MWKlMWc9u3n2VT2+kOJBb zdwmvrDMttv1xHe+QtxAJZWAqBUPMavkTUwOMF3I/URE4z4PtKiQgQELZDS6bzU2THOC Voo67NIxX0UUR/wUapCwkMEoKSDpENRD3UrD9+LQU3ujdkCkEWc7pGeTx0h9jOJPjbFt /BXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=46ldnkoBNzwTQapSHqF1F5MiDCIH8/mF+o2srm542zA=; b=T+hoSlcqCrsYCvjkuXlvy5NZw4HJDb11ygQzaBoi1mrwvZfHbSs9td4xAPHIi45HAh KJqD93vfkv71sIi/NxTQqQuIk7ZSylef/n8TmAxlFailk631pfCw42ylWYmXkOtZBEGQ Ly9/sRMFHhSTjVR+VH9S4p0yue4zyH3EngM171Cp1ii8B+zRQL9NR2Kt//qQ8qOsyVMm dE4dSXIl03jGo49YvXtqMO5S1WyIvLViLrzJSylXVFp3OJ771tKPxVxerERkK3V/ME5D ssMqG1v5nwXH/PEltkuV3U/ZbLBrOQ05HO1GmY8OClNkO0/Ee1j5G4S4uI9QC7t42CSC o4vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaPUYokY; spf=pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=peter.maydell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 140sor7444674wme.14.2019.01.08.08.30.15 for (Google Transport Security); Tue, 08 Jan 2019 08:30:15 -0800 (PST) Received-SPF: pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WaPUYokY; spf=pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=peter.maydell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=46ldnkoBNzwTQapSHqF1F5MiDCIH8/mF+o2srm542zA=; b=WaPUYokY5ErXyR7LdmjSESE3txFpKVAfb+jQ2XV7N7W9M0t5rQM1VHbbGd/DxJFHvy c2KlgQw3cYVn9DyvHT7AywpuGKLR5PYDtJM94fqzpk0NjQkrjJJpr5qmU2htXgy+QrRF bkSrPYTJhcV5FTnceKH76MBklxcmTejTqEW/w= 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=46ldnkoBNzwTQapSHqF1F5MiDCIH8/mF+o2srm542zA=; b=lgJLVVPOxklSHovhaAKY4K1IxzvDR4OURIS4KJOuqovgDDm4DxGm63y3vueWiI9nOa Gj1iEm8S+x6PCRGfssZxZ5fJOnlieGM3jn0lkGDl8OfQGMmGxSW//FPpZX4oekOt8E7h 2G40iCfL6avKmXppnb9lzFKWE6sL4qKSunLtJXo600wM1ZKHdWItaCN7P+/APcfOmiBi lIWtl9iNXISIJXkNJC7M8cRio7tzM2b+nUFebro9xHS5QQ5KGFw3y0QVSb63f+Ki8Sgh cPT7mHaBLixCgLf+3hK6IhdCFhVdJGnY44TTSyiCnh98gDtqSoQHf68dMYopjJwczeQu Ag6A== X-Gm-Message-State: AJcUukdalmw9IDUiffDWCmU2yeCF1nLJQSSS9blY43SgKiItm/PEjhNp qNUrVnZbKr/XOsfhpVgFkJ8SoGZm X-Google-Smtp-Source: ALg8bN74tF166Sq83/2IFptmgmnhGHhKb5TkeuvcFr88Irmh4Gm1DF4/Z21hHUYjWUDU4S1tNkBB9A== X-Received: by 2002:a1c:1b8d:: with SMTP id b135mr2312163wmb.115.1546965015380; Tue, 08 Jan 2019 08:30:15 -0800 (PST) Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x81sm11278839wmg.17.2019.01.08.08.30.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Jan 2019 08:30:14 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Richard Henderson , Peter Crosthwaite , Paolo Bonzini , Alistair Francis , "Edgar E. Iglesias" , Eduardo Habkost , Marcel Apfelbaum , "Emilio G . Cota" Subject: [PATCH 3/4] accel/tcg: Add cluster number to TCG TB hash Date: Tue, 8 Jan 2019 16:30:07 +0000 Message-Id: <20190108163008.7006-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190108163008.7006-1-peter.maydell@linaro.org> References: <20190108163008.7006-1-peter.maydell@linaro.org> MIME-Version: 1.0 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 --- include/exec/exec-all.h | 4 +++- accel/tcg/cpu-exec.c | 4 ++++ accel/tcg/translate-all.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) -- 2.19.2 Reviewed-by: Luc Michel Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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) /* 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..e578a1a3aee 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -336,6 +336,10 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, return NULL; } desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; + + cf_mask &= ~CF_CLUSTER_MASK; + cf_mask |= cpu->cluster_index << CF_CLUSTER_SHIFT; + h = tb_hash_func(phys_pc, pc, flags, cf_mask, *cpu->trace_dstate); return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 639f0b27287..ba27f5acc8c 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1692,6 +1692,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, cflags |= CF_NOCACHE | 1; } + cflags &= ~CF_CLUSTER_MASK; + cflags |= cpu->cluster_index << CF_CLUSTER_SHIFT; + buffer_overflow: tb = tb_alloc(pc); if (unlikely(!tb)) {