From patchwork Wed Oct 23 15:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 177332 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp996636ill; Wed, 23 Oct 2019 09:58:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMeiCZM+2hfmiG1S51A4wsfFrDmZLQchXhIx/C3rUByWuAhkSEKa93iCox0xtkxwl+qrg/ X-Received: by 2002:a17:906:e296:: with SMTP id gg22mr16284699ejb.211.1571849907647; Wed, 23 Oct 2019 09:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571849907; cv=none; d=google.com; s=arc-20160816; b=b8oYmWbl2pu773Z84BuQpYOFjuY1syBLsgcJh+4pb8//T+/n2ghOe7RRY6O/SNEDSj OFexsR3XxBJ5zWCfyUrO16QW4lgON9veRa8iey7l/I1Pr8tOwJj6/cu+MmAaLXaSK20F KTIjBIDeWQ5DBwW6Df/RPg3hBoECAB7QjcxP3vvUv4vXhWUSRWGzRgWiNlxss9vPJh0A Qsba/g3hCezm9gskl7YjMPFnJvyONm5u/iORuLzO7kJsmGq9j4bVUzJTOkOIsWR2P26z tX762GQhccvWJ8KYoGZdkSFB1USDc8tXIfBvKDyQ4cO+gid03+HET6BigxqqP0Ffgx85 /qUA== 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=PzEJPTABzvYPmN/2adJfy5uLdEuaRGm0+mdzHd64cl8=; b=yDyl3x/B2rBtMSrHOMWTiS+YrUgVP1UeXxVs3wzRitkK1xPUuade9uFjC9k7GfQ8T0 YaKnDfuA3rPuUgaNy6TI0DbFBqrCMLzaWISoXUZrI5Syh/gyvgnpxbH9vlz9PS2CzHct 1MbPIfjk43vghkfspLgmT98HbnqCuhERzdx0ctkrDHg1jrQJPLg2U2ScG5z4jgGvYZZt NIWGAM7DXcoGoOCtMUBaSDYPRDzYjnqjcu5ABBKDGHUW0g4ZzwCbmdtDzTNq7Yh2YW7x /Cj4BJYOiy5JkG3/rFsy+cmwtFPr1ybNZmBw7jkLeghvARAgT+JnEOHFgW6kh8KwbAUF NA1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DrjcKVqM; 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 b31si6623408edb.113.2019.10.23.09.58.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Oct 2019 09:58:27 -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=DrjcKVqM; 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]:41856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJxp-0005Vn-NN for patch@linaro.org; Wed, 23 Oct 2019 12:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42527) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp3-0004iA-18 for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp1-0005VQ-2y for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:16 -0400 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]:38958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIoz-0005Nw-3Y for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:15 -0400 Received: by mail-qt1-x843.google.com with SMTP id t8so15415592qtc.6 for ; Wed, 23 Oct 2019 08:45:11 -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=PzEJPTABzvYPmN/2adJfy5uLdEuaRGm0+mdzHd64cl8=; b=DrjcKVqMKxbcZyq0X/pR2ND36ep6US7cUZWY57k9PsE4RyArSC6l97TFoIIN52WWRs t1NC/LEP+njpM75STy6IiBgWw6/E9R7iYfeVB0viiosCU1H0jgvJiDkJOIspaEGNqwXV h52rrVNW+Wx8t1H8qTSTCgM3/cIXA5Q0+Z/HNdk8SE8z0IPsA9sfUHZTqyB1QIQ0Jka2 LbejPbtmfhQv6jeI6EfLcEeLFpKg9eBdnOIQ1XFDXIcFTi2zS5DhRvdrPS1bzbrRUy4l TW01AS054vW39CBmDTcb/DBYBJYaNf5aggxuFKf3p3MvUUmHRikYnwdmmALhJQvBw7Ev OrYg== 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=PzEJPTABzvYPmN/2adJfy5uLdEuaRGm0+mdzHd64cl8=; b=r81khUpJehhF8wsmftcmBxiHrSWO/gwpfgC6QDOiZ0hQ4afqEhWBt4BQYj7fZdJlBz vHa8efw5l9DcbdYX0trZBoXShqW4aTjN6jUMA+MCwq5mUeVxwF/2h9g60k5zFHAc5JBC ZPExmtYZiIJzPTg2saaU54NSV6fChQCUOBR+VbJvNewitQ9LaED4Z1uWC+onjz4NCgAk 0EMurENAATZJppObpzO2Ps+YwLwUupXxeQHt7kqQWefH0a4xQK3cyDgTKAfW2I978fGC c+VxP7K1zUs/UcFlGTJKXJaOIpcLLe47n/Tm6hyY5uHoAkNeSJYkEAoDsxqNMR3/Pphc T4OQ== X-Gm-Message-State: APjAAAXxoYMRlU6OWZvgF9j7pXpjJ6qhGrPNg0qJRQ3meSqQNciyJvfT cAMBn9cJKorHWuThSFoUhxUaceYLrE0= X-Received: by 2002:ac8:2247:: with SMTP id p7mr10137158qtp.180.1571845510213; Wed, 23 Oct 2019 08:45:10 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] exec: Split out variable page size support to exec-vary.c Date: Wed, 23 Oct 2019 11:45:00 -0400 Message-Id: <20191023154505.30521-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::843 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: pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The next patch will play a trick with "const" that will confuse the compiler about the uses of target_page_bits within exec.c. Moving everything to a new file prevents this confusion. No functional change so far. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson --- Makefile.target | 2 +- include/qemu-common.h | 6 +++++ exec-vary.c | 57 +++++++++++++++++++++++++++++++++++++++++++ exec.c | 34 -------------------------- 4 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 exec-vary.c -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/Makefile.target b/Makefile.target index 5e916230c4..ca3d14efe1 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ obj-y += trace/ ######################################################### # cpu emulator library -obj-y += exec.o +obj-y += exec.o exec-vary.o obj-y += accel/ obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o diff --git a/include/qemu-common.h b/include/qemu-common.h index 8d84db90b0..082da59e85 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -74,6 +74,12 @@ void cpu_exec_step_atomic(CPUState *cpu); */ bool set_preferred_target_page_bits(int bits); +/** + * finalize_target_page_bits: + * Commit the final value set by set_preferred_target_page_bits. + */ +void finalize_target_page_bits(void); + /** * Sends a (part of) iovec down a socket, yielding when the socket is full, or * Receives data into a (part of) iovec from a socket, diff --git a/exec-vary.c b/exec-vary.c new file mode 100644 index 0000000000..48c0ab306c --- /dev/null +++ b/exec-vary.c @@ -0,0 +1,57 @@ +/* + * Variable page size handling + * + * 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 . + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "exec/exec-all.h" + +#ifdef TARGET_PAGE_BITS_VARY +int target_page_bits; +bool target_page_bits_decided; +#endif + +bool set_preferred_target_page_bits(int bits) +{ + /* + * The target page size is the lowest common denominator for all + * the CPUs in the system, so we can only make it smaller, never + * larger. And we can't make it smaller once we've committed to + * a particular size. + */ +#ifdef TARGET_PAGE_BITS_VARY + assert(bits >= TARGET_PAGE_BITS_MIN); + if (target_page_bits == 0 || target_page_bits > bits) { + if (target_page_bits_decided) { + return false; + } + target_page_bits = bits; + } +#endif + return true; +} + +void finalize_target_page_bits(void) +{ +#ifdef TARGET_PAGE_BITS_VARY + if (target_page_bits == 0) { + target_page_bits = TARGET_PAGE_BITS_MIN; + } + target_page_bits_decided = true; +#endif +} diff --git a/exec.c b/exec.c index fb0943cfed..5bf181d23e 100644 --- a/exec.c +++ b/exec.c @@ -91,11 +91,6 @@ AddressSpace address_space_memory; static MemoryRegion io_mem_unassigned; #endif -#ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; -#endif - CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); /* current CPU in the current thread. It is only valid inside @@ -109,37 +104,8 @@ int use_icount; uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; -bool set_preferred_target_page_bits(int bits) -{ - /* The target page size is the lowest common denominator for all - * the CPUs in the system, so we can only make it smaller, never - * larger. And we can't make it smaller once we've committed to - * a particular size. - */ -#ifdef TARGET_PAGE_BITS_VARY - assert(bits >= TARGET_PAGE_BITS_MIN); - if (target_page_bits == 0 || target_page_bits > bits) { - if (target_page_bits_decided) { - return false; - } - target_page_bits = bits; - } -#endif - return true; -} - #if !defined(CONFIG_USER_ONLY) -static void finalize_target_page_bits(void) -{ -#ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits == 0) { - target_page_bits = TARGET_PAGE_BITS_MIN; - } - target_page_bits_decided = true; -#endif -} - typedef struct PhysPageEntry PhysPageEntry; struct PhysPageEntry {