From patchwork Fri Jun 11 23:41:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 458627 Delivered-To: patch@linaro.org Received: by 2002:a17:907:7409:0:0:0:0 with SMTP id gj9csp710445ejc; Fri, 11 Jun 2021 16:55:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn7cA1sSCOJz1+jbHjeExvOmCMHo3gxyLIYo5aVN4/hOqcyxU7oppwZx5MCU4mzRfHunY1 X-Received: by 2002:a37:aa50:: with SMTP id t77mr257591qke.102.1623455722483; Fri, 11 Jun 2021 16:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623455722; cv=none; d=google.com; s=arc-20160816; b=LUEi2uCdXKkc8rISXrG0umJFx1rkhYsLgrvWoLqoV3DSjPJRtqIlyOc/NUKRJmX8p0 jGHFR+tMjLjQQQa+ged/1QZ21fdBx4R8dMfrEVX0ivMqjxLXWRQCl60QpKi3mPolXLX4 wy5EFCI9OT9QubXctRa9D+oagHVkPSAorPebB/8z8JBZdaAg2kVyl8V/JK8Ht45exdE3 6YN6FHgmQAKcalO4kL8l0wkEWtonqQqFpGD9k2Psp0d951DLkxV+SkXiTgJHOu4ufxBX nhzH8bOEzF95Qxq2DIYcuCn2C5jLlJD0r3lsxyv/h9z9OR8yKdcjEJhXEeuDHopJ5lMz MkpQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rVXDKDz9VV+CueY0JW5pxfv4fXwklGCn3HdEg7Jb5yI=; b=DNdriDfXPUo7rXKy9JT1bB+zb+A3GBykbnkDJM2fuKAVsMiW9LE94mpZAw/ChrJni9 g5UzM4sVM6ksOqzvk5zZy9bg7nUh7V0Y6bRd51vxnHOtFAN4XdaKY+4zpJ1ZQFYV7oR0 YhRXGfWt8om8rj340YlgrN3n4YeljBazkCwOZhze1XuR5C285F87zEcaOyCZDgpLzejA tjrPByzIirRu3QHlkySxL0Bo8SZY2YTz0V9RqvpJqK36CN+SYo9zA1ilOrxfQUseH3lp J5IMg3rAVOpCE/32rROZ/TSQAeJnCYVU2zOxe7zc2k3rWry06cnm+ryKqsYw3Kk7EKxI R8bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q9cfMLAu; 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=pass (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 t63si5411367qkb.199.2021.06.11.16.55.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Jun 2021 16:55:22 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=Q9cfMLAu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:32872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrqzh-0004vd-Oh for patch@linaro.org; Fri, 11 Jun 2021 19:55:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrqmk-0002ft-P1 for qemu-devel@nongnu.org; Fri, 11 Jun 2021 19:41:58 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:39764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrqmg-0002e4-6d for qemu-devel@nongnu.org; Fri, 11 Jun 2021 19:41:58 -0400 Received: by mail-pf1-x429.google.com with SMTP id k15so5692617pfp.6 for ; Fri, 11 Jun 2021 16:41:53 -0700 (PDT) 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=rVXDKDz9VV+CueY0JW5pxfv4fXwklGCn3HdEg7Jb5yI=; b=Q9cfMLAuN8JYVME3XH38A1xn5P1ELwmFrcR7Xthz+RL2ccSYOIgmtoPa5UMiFoaHOg 4IYUz/Ko6S2G6QzQoiOGu47IdGNFSu5Z4RWogXNEz2WK0z2lnfNjP1NSA/bcROncAZIh jIpaEgJY3oebgDu9RqdAyi4oFOPDWCwr5k4EHVGx+Zp08WP3WdNWKbOz/PCFQ8WeoJMy NSWJahdgLOcfwvk/A4IeIy6c9BqtdlNV4JXaxeuC35VItkNvLmurhQxnNQFDwMaCLauD PH1S5iY0F47+le5Jdc3lmJ8+7hA2/5C4sUstJkOpXcS7eJrG3VYRfRpWzxr/0kP9s+Q7 +ebA== 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=rVXDKDz9VV+CueY0JW5pxfv4fXwklGCn3HdEg7Jb5yI=; b=R5++/nYACrzhvOKH/del64I7ijRr9ze3m4c4rwLVwyXR+nX12hZa6MCAp8OresycUg 33tTHys0avv6oUBL9teAj2+eJjR7ksjYWvLJp7J41YlymmzE3cpnPPea9Oo4UZ9a4gVo iByvs5D/X12XRHGicqxbNKJpL13X+a5IHJYQGSVyAMTVWMYVuP7tOwG+EeSL292t2ALp 6ExLvT7AIfpuQrn7UNU/bAy481V8GR3Pt6HXk4/9hgM56b8jnGRjYvS00iZf9DJaS1MI c/Pce1aVLf/hoH7PSTfL37hZ+JR2Gv9BrO2Z7xv4eRcHBWaDGJERkOCAM7Ses2DYWfmu OFMg== X-Gm-Message-State: AOAM5302y9TzhRMJUzF9EnNn/sNjDmHuzqn32rbU/ATWs/mBav1T23ON vpflBLJdi2IlTCBegv/RqKRPCNHFja07zw== X-Received: by 2002:a65:6114:: with SMTP id z20mr5981132pgu.249.1623454912873; Fri, 11 Jun 2021 16:41:52 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id q23sm6139829pgm.31.2021.06.11.16.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 16:41:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/34] accel/tcg: Merge tcg_exec_init into tcg_init_machine Date: Fri, 11 Jun 2021 16:41:22 -0700 Message-Id: <20210611234144.653682-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611234144.653682-1-richard.henderson@linaro.org> References: <20210611234144.653682-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Luis Pires , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is only one caller, and shortly we will need access to the MachineState, which tcg_init_machine already has. Reviewed-by: Luis Pires Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- accel/tcg/internal.h | 2 ++ include/sysemu/tcg.h | 2 -- accel/tcg/tcg-all.c | 16 +++++++++++++++- accel/tcg/translate-all.c | 21 ++------------------- bsd-user/main.c | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) -- 2.25.1 diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h index e9c145e0fb..881bc1ede0 100644 --- a/accel/tcg/internal.h +++ b/accel/tcg/internal.h @@ -16,5 +16,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, int cflags); void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr); +void page_init(void); +void tb_htable_init(void); #endif /* ACCEL_TCG_INTERNAL_H */ diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h index 00349fb18a..53352450ff 100644 --- a/include/sysemu/tcg.h +++ b/include/sysemu/tcg.h @@ -8,8 +8,6 @@ #ifndef SYSEMU_TCG_H #define SYSEMU_TCG_H -void tcg_exec_init(unsigned long tb_size, int splitwx); - #ifdef CONFIG_TCG extern bool tcg_allowed; #define tcg_enabled() (tcg_allowed) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 30d81ff7f5..e990180c4b 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -32,6 +32,7 @@ #include "qemu/error-report.h" #include "qemu/accel.h" #include "qapi/qapi-builtin-visit.h" +#include "internal.h" struct TCGState { AccelState parent_obj; @@ -109,8 +110,21 @@ static int tcg_init_machine(MachineState *ms) { TCGState *s = TCG_STATE(current_accel()); - tcg_exec_init(s->tb_size * 1024 * 1024, s->splitwx_enabled); + tcg_allowed = true; mttcg_enabled = s->mttcg_enabled; + + page_init(); + tb_htable_init(); + tcg_init(s->tb_size * 1024 * 1024, s->splitwx_enabled); + +#if defined(CONFIG_SOFTMMU) + /* + * There's no guest base to take into account, so go ahead and + * initialize the prologue now. + */ + tcg_prologue_init(tcg_ctx); +#endif + return 0; } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4f563b8724..59609d62d5 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -408,7 +408,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) return false; } -static void page_init(void) +void page_init(void) { page_size_init(); page_table_config_init(); @@ -907,30 +907,13 @@ static bool tb_cmp(const void *ap, const void *bp) a->page_addr[1] == b->page_addr[1]; } -static void tb_htable_init(void) +void tb_htable_init(void) { unsigned int mode = QHT_MODE_AUTO_RESIZE; qht_init(&tb_ctx.htable, tb_cmp, CODE_GEN_HTABLE_SIZE, mode); } -/* Must be called before using the QEMU cpus. 'tb_size' is the size - (in bytes) allocated to the translation buffer. Zero means default - size. */ -void tcg_exec_init(unsigned long tb_size, int splitwx) -{ - tcg_allowed = true; - page_init(); - tb_htable_init(); - tcg_init(tb_size, splitwx); - -#if defined(CONFIG_SOFTMMU) - /* There's no guest base to take into account, so go ahead and - initialize the prologue now. */ - tcg_prologue_init(tcg_ctx); -#endif -} - /* call with @p->lock held */ static inline void invalidate_page_bitmap(PageDesc *p) { diff --git a/bsd-user/main.c b/bsd-user/main.c index 270cf2ca70..fe66204b6b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -813,7 +813,7 @@ int main(int argc, char **argv) envlist_free(envlist); /* - * Now that page sizes are configured in tcg_exec_init() we can do + * Now that page sizes are configured we can do * proper page alignment for guest_base. */ guest_base = HOST_PAGE_ALIGN(guest_base);