From nobody Wed Apr 16 15:35:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1572275034; cv=none; d=zoho.com; s=zohoarc; b=SWIb0Ky0sujggBhipPb4ZDjW+IY2biOLBLQk3Xuz7ppa3g408ppCDRo5i88+UYMvO6+f6/xc8kWY+FuNGO6Z7YtHlmZ+ZzK73gkTCBNCJ+GdCNoOsUNrWyYOt8OsRik5b4c1Ohj+hnd1ZklzBjeyaab37/JtzRNOTikG6DsRkn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572275034; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MG1IpXQvrz4SptVhLZ2ZL/egepQYBWYRd+NyOkeOFrk=; b=D1UOFKOLuYcrn4wuZlooVvXdX2DJ851iZ8GwNwW2Vbad9hzYTAMLU6i3mbRVk69XxbFRqRmetH/6cDQwEjDdg/f15p+NRTHaOB0jr+6Y08HMx5i9ArXtdtWB55dTNDizHrO7P3hUW0Hqe8z4ocM2A9YiQRb5mZ41mo7ecNjCsuA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572275034742470.66331611516136; Mon, 28 Oct 2019 08:03:54 -0700 (PDT) Received: from localhost ([::1]:54780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP6Ye-0002iW-Nr for importer@patchew.org; Mon, 28 Oct 2019 11:03:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44563) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP6Uj-0007UJ-J3 for qemu-devel@nongnu.org; Mon, 28 Oct 2019 10:59:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iP6Ui-00043B-4Q for qemu-devel@nongnu.org; Mon, 28 Oct 2019 10:59:45 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iP6Uh-00042j-UP for qemu-devel@nongnu.org; Mon, 28 Oct 2019 10:59:44 -0400 Received: by mail-wm1-x341.google.com with SMTP id q70so9832657wme.1 for ; Mon, 28 Oct 2019 07:59:43 -0700 (PDT) Received: from localhost.localdomain (230.106.138.88.rev.sfr.net. [88.138.106.230]) by smtp.gmail.com with ESMTPSA id 143sm14842876wmb.33.2019.10.28.07.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 07:59:42 -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=MG1IpXQvrz4SptVhLZ2ZL/egepQYBWYRd+NyOkeOFrk=; b=InAaFjoJ0Df8tu1vuD+ZBd/ql3baejSfDlUFPASBNmVp5ugnlLzyjTrjstCpTgKnRg suUsPm8cO4eLOekYsVeEO27o9fDJpFeqSb0IUP+Z0kDyWl7g+Yl6nqd7RG8Y8/REY+73 6mGVuQwDGqRO1ulZo+s+pxycp2lPXgxvzflA4MsHI7uW0Y2nX5IxIrTgSWKgZVYAUBhQ A5QIapzUVANWgUaFq3F1exeqhSxEfl050gstB4AcCWYeqhDuTTDRCUKanHkiI1fsfZr1 u+FgeRU0PvXi3SMc1mKyNVtb2FwQRbZieDDt8cqfH36FSaWlDBxWd2cEsezsWlRWEMsn Ivdw== 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=MG1IpXQvrz4SptVhLZ2ZL/egepQYBWYRd+NyOkeOFrk=; b=GjmJ+E55n2if/MxpFgG+RUhFxiYe7rehPKsM8ze4sCWzO5jOM8e5bkwklAyWeu++Pn dPbRfhyX5oixeJY7h74k34rWspiW/SZwn7AhVJHsU15RSbLfEaUIcL8HY66tPDe9NRVv ktxc8AME32BTQW6MLbobFCBwBULO0XoyCAIeakPM+8YUTmIZKk9FkvZO4wRdk3T0zE43 1Rq1ZbMrgwFWa+2oPdoHZlS/b54nl/wkPNlkytp8TaSLk9LnjBaZ9qShYG0lSoFGH8Uk +a0GY4kkNG+v3C0wtL2tJ0aO3mIxqUvbRCnFuYvQnmYjtpA1yQBlWTb12Ov0+8xQst9D ikMw== X-Gm-Message-State: APjAAAWSFDOLiROwklBILtv+QOyyKov3mmAjrE8oAIXvnC+RlKFnvzaV tGlETUHZWqAw0qzgQKbpcXvko+4b03xInA== X-Google-Smtp-Source: APXvYqw4fn15a9WwHYWIMJKRwdSgEuhaDgEooNNu4EWnNNQo5vpRdPmSHuJBvnXLOcN2OVBmr6oAGA== X-Received: by 2002:a1c:2d4b:: with SMTP id t72mr418413wmt.112.1572274782572; Mon, 28 Oct 2019 07:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v2 04/12] exec: Split out variable page size support to exec-vary.c Date: Mon, 28 Oct 2019 15:59:29 +0100 Message-Id: <20191028145937.10914-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028145937.10914-1-richard.henderson@linaro.org> References: <20191028145937.10914-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 diff --git a/Makefile.target b/Makefile.target index 5e916230c4..ca3d14efe1 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ obj-y +=3D trace/ =20 ######################################################### # cpu emulator library -obj-y +=3D exec.o +obj-y +=3D exec.o exec-vary.o obj-y +=3D accel/ obj-$(CONFIG_TCG) +=3D tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-= gvec.o obj-$(CONFIG_TCG) +=3D 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); =20 +/** + * 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 >=3D TARGET_PAGE_BITS_MIN); + if (target_page_bits =3D=3D 0 || target_page_bits > bits) { + if (target_page_bits_decided) { + return false; + } + target_page_bits =3D bits; + } +#endif + return true; +} + +void finalize_target_page_bits(void) +{ +#ifdef TARGET_PAGE_BITS_VARY + if (target_page_bits =3D=3D 0) { + target_page_bits =3D TARGET_PAGE_BITS_MIN; + } + target_page_bits_decided =3D 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 =20 -#ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; -#endif - CPUTailQ cpus =3D QTAILQ_HEAD_INITIALIZER(cpus); =20 /* 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; =20 -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 >=3D TARGET_PAGE_BITS_MIN); - if (target_page_bits =3D=3D 0 || target_page_bits > bits) { - if (target_page_bits_decided) { - return false; - } - target_page_bits =3D bits; - } -#endif - return true; -} - #if !defined(CONFIG_USER_ONLY) =20 -static void finalize_target_page_bits(void) -{ -#ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits =3D=3D 0) { - target_page_bits =3D TARGET_PAGE_BITS_MIN; - } - target_page_bits_decided =3D true; -#endif -} - typedef struct PhysPageEntry PhysPageEntry; =20 struct PhysPageEntry { --=20 2.17.1