From patchwork Thu May 19 11:18:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9127553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1A676082E for ; Thu, 19 May 2016 13:02:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D1B281F8 for ; Thu, 19 May 2016 12:31:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0514A281FD; Thu, 19 May 2016 12:31:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 362E3281F8 for ; Thu, 19 May 2016 12:31:23 +0000 (UTC) Received: from localhost ([::1]:50107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3N6o-0000vc-Eo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 May 2016 08:31:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3LzV-0004oN-4K for qemu-devel@nongnu.org; Thu, 19 May 2016 07:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3LzS-0004L1-M5 for qemu-devel@nongnu.org; Thu, 19 May 2016 07:19:44 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3LzS-0004Kt-Cb for qemu-devel@nongnu.org; Thu, 19 May 2016 07:19:42 -0400 Received: by mail-wm0-x242.google.com with SMTP id n129so20164290wmn.1 for ; Thu, 19 May 2016 04:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=GgbC+le3CyiIzSyzlpixD65MvDGboZZHsPn4YTOiiXA=; b=tcLmHi5Sw1pENA/rHz7ZUNamdS9NqdAsQShcN6O+Pl5KRd0lDQJh+RXo1KXX5+l3hq fqJ3YWN8zV13X4aBBemo23A8Ta3gFw0YKUWiIN7l2oQmjOTg5qgkR98yTfETPDBup06g 6kz8KQ6HLfqkBWli7hKfMQwBGOgadCF7AtYG+dXk7eMxXqu2flphq9k1XQmXON50oTfQ lxt0ofQyXnOG5hgNicUE04k1ArFxwK/yiYGjRzwqw4PMeBOD/tBQ41A3WxSHWAw8I+jx KlK8VAfNy6nqHQvAEi5j8Fg3EskDykvKfthEudzRfacR+TwoRH+5HEpWCpunqnEZSgyy HXMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=GgbC+le3CyiIzSyzlpixD65MvDGboZZHsPn4YTOiiXA=; b=SBqTu+ZfFox0iEIF23Wu6MkXxLXMQGpc3RSClPSRjmwMLUmGHjs+vgJJGHvMUUzR9Z PW3xDf/DM/8xuipM41V7zmvQK1NErsh44KaGL/Fd3YRW0WlcSvJKZnQidYa+PTjJ4CZB iCO7OBU3nCT1yjF9KKH/OsaFBrijLpe+KboSivzW+9YETMuN88kMYkY52nfDr6oT4pKX p3HII2rnRL1Y6Knip1H0FyTXuR6zUDYFaBmuHg5Byw0JJAZa10v0gzB798ws2n/mmknI oyNi8pbcrKbGM0FOnz+puaR5GpMWwsu9DDD9DwDnPNiDp4n/EzrmtLWGhLe06vY7aZOX 0jww== X-Gm-Message-State: AOPr4FX0K+wCZuiZXSwpauGSAO6hjAZA7SQrs2YyXtjG9+BzeEFuAya8wbOGXuQru0BXOQ== X-Received: by 10.28.158.79 with SMTP id h76mr33930588wme.79.1463656781779; Thu, 19 May 2016 04:19:41 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-252-58.clienti.tiscali.it. [78.12.252.58]) by smtp.gmail.com with ESMTPSA id c7sm8374317wji.38.2016.05.19.04.19.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 May 2016 04:19:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 19 May 2016 13:18:43 +0200 Message-Id: <1463656726-35952-50-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1463656726-35952-1-git-send-email-pbonzini@redhat.com> References: <1463656726-35952-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 49/52] exec: extract exec/tb-context.h 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP TCG backends do not need most of exec-all.h; extract what they actually need to a separate file or move it directly to tcg.h. The next patch will stop including exec-all.h from everywhere. Signed-off-by: Paolo Bonzini --- include/exec/exec-all.h | 45 +-------------------------------------------- include/exec/tb-context.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tcg/optimize.c | 2 +- tcg/tcg-common.c | 2 ++ tcg/tcg.h | 22 ++++++++++++++++++++++ 5 files changed, 72 insertions(+), 45 deletions(-) create mode 100644 include/exec/tb-context.h diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 85528f9..fd30a0c 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -21,6 +21,7 @@ #define _EXEC_ALL_H_ #include "qemu-common.h" +#include "exec/tb-context.h" /* allow to see translation results - the slowdown should be negligible, so we leave it */ #define DEBUG_DISAS @@ -40,30 +41,6 @@ typedef ram_addr_t tb_page_addr_t; #define DISAS_UPDATE 2 /* cpu state was modified dynamically */ #define DISAS_TB_JUMP 3 /* only pc was modified statically */ -struct TranslationBlock; -typedef struct TranslationBlock TranslationBlock; - -/* XXX: make safe guess about sizes */ -#define MAX_OP_PER_INSTR 266 - -#if HOST_LONG_BITS == 32 -#define MAX_OPC_PARAM_PER_ARG 2 -#else -#define MAX_OPC_PARAM_PER_ARG 1 -#endif -#define MAX_OPC_PARAM_IARGS 5 -#define MAX_OPC_PARAM_OARGS 1 -#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) - -/* A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N = number of input arguments + output arguments). */ -#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) -#define OPC_BUF_SIZE 640 -#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) - -#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) - #include "qemu/log.h" void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); @@ -212,9 +189,6 @@ static inline void tlb_flush_by_mmuidx(CPUState *cpu, ...) #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ -#define CODE_GEN_PHYS_HASH_BITS 15 -#define CODE_GEN_PHYS_HASH_SIZE (1 << CODE_GEN_PHYS_HASH_BITS) - /* Estimated block size for TB allocation. */ /* ??? The following is based on a 2015 survey of x86_64 host output. Better would seem to be some sort of dynamically sized TB array, @@ -289,23 +263,6 @@ struct TranslationBlock { uintptr_t jmp_list_first; }; -#include "qemu/thread.h" - -typedef struct TBContext TBContext; - -struct TBContext { - - TranslationBlock *tbs; - TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE]; - int nb_tbs; - /* any access to the tbs or the page table must use this lock */ - QemuMutex tb_lock; - - /* statistics */ - int tb_flush_count; - int tb_phys_invalidate_count; -}; - 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-context.h b/include/exec/tb-context.h new file mode 100644 index 0000000..0312410 --- /dev/null +++ b/include/exec/tb-context.h @@ -0,0 +1,46 @@ +/* + * Internal structs that QEMU exports to TCG + * + * 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 QEMU_TB_CONTEXT_H_ +#define QEMU_TB_CONTEXT_H_ + +#include "qemu/thread.h" + +#define CODE_GEN_PHYS_HASH_BITS 15 +#define CODE_GEN_PHYS_HASH_SIZE (1 << CODE_GEN_PHYS_HASH_BITS) + +typedef struct TranslationBlock TranslationBlock; +typedef struct TBContext TBContext; + +typedef struct TBContext TBContext; + +struct TBContext { + + TranslationBlock *tbs; + TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE]; + int nb_tbs; + /* any access to the tbs or the page table must use this lock */ + QemuMutex tb_lock; + + /* statistics */ + int tb_flush_count; + int tb_phys_invalidate_count; +}; + +#endif diff --git a/tcg/optimize.c b/tcg/optimize.c index def4ba6..c0d975b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -25,7 +25,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "cpu.h" +#include "exec/cpu-common.h" #include "tcg-op.h" #define CASE_OP_32_64(x) \ diff --git a/tcg/tcg-common.c b/tcg/tcg-common.c index 97305a3..2f139de 100644 --- a/tcg/tcg-common.c +++ b/tcg/tcg-common.c @@ -23,6 +23,8 @@ */ #include "qemu/osdep.h" +#include "qemu-common.h" +#include "exec/cpu-common.h" #include "tcg/tcg.h" #if defined(CONFIG_TCG_INTERPRETER) diff --git a/tcg/tcg.h b/tcg/tcg.h index 8abf318..909db3f 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -27,9 +27,31 @@ #include "qemu-common.h" #include "cpu.h" +#include "exec/tb-context.h" #include "qemu/bitops.h" #include "tcg-target.h" +/* XXX: make safe guess about sizes */ +#define MAX_OP_PER_INSTR 266 + +#if HOST_LONG_BITS == 32 +#define MAX_OPC_PARAM_PER_ARG 2 +#else +#define MAX_OPC_PARAM_PER_ARG 1 +#endif +#define MAX_OPC_PARAM_IARGS 5 +#define MAX_OPC_PARAM_OARGS 1 +#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) + +/* A Call op needs up to 4 + 2N parameters on 32-bit archs, + * and up to 4 + N parameters on 64-bit archs + * (N = number of input arguments + output arguments). */ +#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) +#define OPC_BUF_SIZE 640 +#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) + +#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) + #define CPU_TEMP_BUF_NLONGS 128 /* Default target word size to pointer size. */