From patchwork Sun May 31 06:11:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 478560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B4D37140FDB for ; Sun, 31 May 2015 16:17:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mh5Mo1wL; dkim-atps=neutral Received: from localhost ([::1]:41233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YywYT-0003B1-Oq for incoming@patchwork.ozlabs.org; Sun, 31 May 2015 02:17:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YywUI-0002AS-CV for qemu-devel@nongnu.org; Sun, 31 May 2015 02:12:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YywUG-0000ZS-I7 for qemu-devel@nongnu.org; Sun, 31 May 2015 02:12:46 -0400 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]:32810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YywUG-0000ZI-7V for qemu-devel@nongnu.org; Sun, 31 May 2015 02:12:44 -0400 Received: by padj3 with SMTP id j3so21086069pad.0 for ; Sat, 30 May 2015 23:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=P9mbVM8hrlTxBrNn1+6VleZWyfCV3Fb5V9efDSHdB44=; b=mh5Mo1wLl6mXRtwF06Ul+XzgCVQvyrkgQbfx75w0QEbeNi1Tmfdj1M7DHbjWndF8h+ xtnG3QkRR6+yZwaRitgZGT9beVhv6lfFn49gtRrC7n61aTQoY9rjx8EdmE7dla8iX1/r rbEv5tfLlFX1OWI0iLBMfDPVD0/fBdjO/FE1rEPwveAsgevP+LRnRGEE5C77ZlnIl1/j AdFejTRIPaw1S7RlQM8vJpXY1OM8QS/hc5y+HKKu7PoISC3kNm8S/Czd5kKWk8oq78RJ ITE4ih78x5ON6h0FbKWkFtWUO9Qo2SiYlIMdPgUWvfMUMrXU1We72IXp3OFRcfUItZHs 7KNw== X-Received: by 10.70.49.168 with SMTP id v8mr29699255pdn.24.1433052763640; Sat, 30 May 2015 23:12:43 -0700 (PDT) Received: from pcrost-laptop.hsd1.ca.comcast.net (c-24-5-157-48.hsd1.ca.comcast.net. [24.5.157.48]) by mx.google.com with ESMTPSA id de2sm10407396pdb.15.2015.05.30.23.12.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 May 2015 23:12:42 -0700 (PDT) From: Peter Crosthwaite X-Google-Original-From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Sat, 30 May 2015 23:11:45 -0700 Message-Id: <9d048b96f7cfa64a4d9c0b88e0dd2877fac51d41.1433052532.git.crosthwaite.peter@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::236 Cc: peter.maydell@linaro.org, Peter Crosthwaite , pbonzini@redhat.com, edgar.iglesias@gmail.com, afaerber@suse.de, rth@twiddle.net Subject: [Qemu-devel] [RFC v2 12/34] include/exec: Move tb hash functions out X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is one of very few things in exec-all with a genuine CPU architecture dependency. Move these hashing helpers to a new header to trim exec-all.h down to a near architecture-agnostic header. The defs are only used by cpu-exec and translate-all which are both arch-obj's so the new tb-hash.h has no core code usage. Signed-off-by: Peter Crosthwaite Reviewed-by: Richard Henderson --- cpu-exec.c | 2 ++ include/exec/exec-all.h | 20 -------------------- include/exec/tb-hash.h | 43 +++++++++++++++++++++++++++++++++++++++++++ target-multi/helper.h | 1 + translate-all.c | 1 + 5 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 include/exec/tb-hash.h create mode 100644 target-multi/helper.h diff --git a/cpu-exec.c b/cpu-exec.c index dbea47c..f255ea9 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -27,6 +27,8 @@ #include "exec/address-spaces.h" #include "qemu/rcu.h" +#include "exec/tb-hash.h" + /* -icount align implementation. */ typedef struct SyncClocks { diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index d52885e..745cb4a 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -195,26 +195,6 @@ struct TBContext { int tb_invalidated_flag; }; -static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) -{ - target_ulong tmp; - tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); - return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; -} - -static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) -{ - target_ulong tmp; - tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); - return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) - | (tmp & TB_JMP_ADDR_MASK)); -} - -static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) -{ - return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); -} - void tb_free(TranslationBlock *tb); void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h new file mode 100644 index 0000000..e0bd786 --- /dev/null +++ b/include/exec/tb-hash.h @@ -0,0 +1,43 @@ +/* + * internal execution defines for qemu + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef EXEC_TB_HASH +#define EXEC_TB_HASH + +static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) +{ + target_ulong tmp; + tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); + return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; +} + +static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) +{ + target_ulong tmp; + tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); + return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) + | (tmp & TB_JMP_ADDR_MASK)); +} + +static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) +{ + return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); +} + +#endif diff --git a/target-multi/helper.h b/target-multi/helper.h new file mode 100644 index 0000000..6b9ee59 --- /dev/null +++ b/target-multi/helper.h @@ -0,0 +1 @@ +/* Multi arch has no helpers, but core code expects this file anyway */ diff --git a/translate-all.c b/translate-all.c index 7d27c5d..bf0d689 100644 --- a/translate-all.c +++ b/translate-all.c @@ -58,6 +58,7 @@ #endif #include "exec/cputlb.h" +#include "exec/tb-hash.h" #include "translate-all.h" #include "qemu/bitmap.h" #include "qemu/timer.h"