From patchwork Thu Sep 19 23:29:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174110 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1589326oce; Thu, 19 Sep 2019 16:30:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8WLl2jWrKxRXLRiA0mXccHGPba3NU92VBDN9UPUMG8zllLHWx31/qu4B1uRxr8oK1se5C X-Received: by 2002:a17:906:6805:: with SMTP id k5mr16407952ejr.50.1568935843327; Thu, 19 Sep 2019 16:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568935843; cv=none; d=google.com; s=arc-20160816; b=0saYe1xPv9PlIMYO3n+IkMIzpKpUAt9dIZ2bdBbCtuVU1itXz5DDGD0WFk6iwfFOMu MwAYOH2KZJCehYY5XBp4MVUltq6iTi0glpJYhgesMPE4+UAH4NyKsrn0qhGswYLSCQQW loxVnuu1s9RdSl6Bwl4QjnD0Wphe2qvz3Cu6UobAwZtNYISEfN0vyQubLAzfzMHP6P2V D9G82SYGdrBtD4bEHldsuGVQVWqg/1U8PZymCQhIbNEZ8HpxpR6H3wVq2bqcHz53TF5w R/IX0jbERPDsehEbLpBe+y0l3E3qw1ZL43fiBM8hi0fgbWelPQBcXLDQ/oM/qkQfkcmT UYSQ== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=q7PGmLFt8k2gMw2v7XrzLTew2NhAfZzpYEa2cTqkTY8=; b=NhevQNBtwyLW2Usrawgzoni9atQTzU4GCSLt3Hb03os27sh6sJfwy5/NpSmHLZYkJb 6J6yq5TzI38rkgh5cS9I5wdNSSJvH9sE9Dq0YNea/GVzK6mhJ8J3UUQDS8W3oMS+YX1l du9VNLiHU6V05MwyEgwsiE3bckQ9qFPH4szPomN2B7WY0w28GfKJsCm3sOoLytZwSGeX sdEN6M/RJh5FIaZYwZcjZg7Lpet/15yjfUV3z9juTq6F9ytrBgCqg7PJ9aIfFO1WxFLh N1JcinaUA/rgDbYqNlHPcRpT1z9krJFM8sgrBsrIlQ6EA+9sI3WzQIp3DMC1DlU/5ecz IGEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vJzAZ60U; 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 i56si198981eda.19.2019.09.19.16.30.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:30:43 -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=vJzAZ60U; 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]:49726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5sm-0006M9-Ur for patch@linaro.org; Thu, 19 Sep 2019 19:30:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39261) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5s8-0006IK-Dz for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5s6-0000jr-Ph for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:00 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:40490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5s6-0000jB-EI for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:29:58 -0400 Received: by mail-pg1-x544.google.com with SMTP id w10so2729064pgj.7 for ; Thu, 19 Sep 2019 16:29:58 -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; bh=q7PGmLFt8k2gMw2v7XrzLTew2NhAfZzpYEa2cTqkTY8=; b=vJzAZ60Uz+FyOHGBPbW7vw1/Rm7vhO0zQKoqyGu7Z3I+lnrrpkVi/ntQiMICrWDv2t wfmyDDIRnw2JpwO/w+m+++dIufEhQ72lLz/XRPcbCRh0v2OvU6SgoXOUj/+3IeLz3639 FE2eZux4+VAQ8gIEbUyKuncJMmfrkAzWU8pzBicCTUTOsrEqgNMXdO0aNx4DaCkQhAMQ 2kRt+bhd4Opu3k23Mb+TtkxT53kDq6WqP7a/CnkxfEotOArNf8LXGOmOrZCGHfqIQNm/ 9jHUYk4IxwQdfppme3UETl17SEoFhOIpT3yzM4c7Y+jTxBNMxjTGwCWPkYxDDfsErqJ6 XGkA== 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; bh=q7PGmLFt8k2gMw2v7XrzLTew2NhAfZzpYEa2cTqkTY8=; b=pobzVgUTzXm0bybhnBlHKSOPm9wWzcM3KJP1l0xPPwjP+ddUvcUP2SG9TSE18nE5J7 VRmS6XDYHq1YRia4dkkIL/PvB+DePvkETUqFCP1VA5H+i0Sc67LT5/U+gn00I54ni6uq wnu09jOCqKkwKR1cD7/v8ktFUuPtktbdj7iAVT3011zz8B74g8El8eIaNBZ+DtmMEZnw tx/o9lCABioNzgj9/b3TOmcMqouFvmFBOGPDD5wIHOnYA52uHMcaJBtNUCBB7m7StJE0 Ze7qFVaZT7s9Stb/Ey1mxVqCHbAet56HaN24mhyWhf75gxyOm2xy25jjuQKHQpWE4nvN 35oA== X-Gm-Message-State: APjAAAXL9c/SKo+yE1jBRtdVRMJL9DMnbl/iV+5dW5cIW4rYRG9Xhxi5 I3Hwk4trcBUaSYdiO6UpmGgcApxFna0= X-Received: by 2002:a63:c050:: with SMTP id z16mr10063295pgi.250.1568935796893; Thu, 19 Sep 2019 16:29:56 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/7] exec: Split out variable page size support to exec-vary.c Date: Thu, 19 Sep 2019 16:29:47 -0700 Message-Id: <20190919232952.6382-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 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, peter.maydell@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. 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: Philippe Mathieu-Daudé 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 0235cd3b91..3e800c2224 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 8b998974f8..33bd0e36c1 100644 --- a/exec.c +++ b/exec.c @@ -92,11 +92,6 @@ MemoryRegion io_mem_rom, io_mem_notdirty; 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 @@ -110,37 +105,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 {