From patchwork Tue Dec 12 12:33:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 753060 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp1875371wrs; Tue, 12 Dec 2023 04:35:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IElYrYh/VZm4DuV9qqGTzoR1RQbrSCHSVK2Umw8nQUanlfiubmi/XNEIJyqZAyFBJNPQbhL X-Received: by 2002:a05:6870:5aaa:b0:1e9:f0fe:6ba4 with SMTP id dt42-20020a0568705aaa00b001e9f0fe6ba4mr5440325oab.11.1702384547679; Tue, 12 Dec 2023 04:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702384547; cv=none; d=google.com; s=arc-20160816; b=SBAhyTVPeOO+B5kYwIbM1mBlXNlJB7YqeiF4JzsW0OgLamgeDlLo0P/MvSzSPKCbPc Qw6UhAzi1PZibtIPZfKURLpdRIdKOUVhZkgtqkmtfKlJoL6I3PHRDV/4/KhGpLXqZYFi sQWeHJB2N6qVB1Jb06DBaU+1K/Xqsn1/P4nhJ+mf1P0RKaPDg0MFKIZ8RooqQZY1H/ZA vRm84VNEVnBAqtuX6tI9BIK7BgDsISUtdXnov/+voqV4ORRbFzRRnLeuetJgxy4UjMwS f/ubA3ASMlO9VOLcCp4QewHrdRCfmBn/0SkxdB2GMTXNEMWXJr70cTkhBcXgPFKU+cPr 2XHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=NDQDiSIXlkgjP0mASXiCW1Z5PDJEfauay7W7xh/vCZQ=; fh=L9+xlWXyKm6KsUaf8nJ3E7Oku33KOKYECsFhykRkiiE=; b=kNR5mppD2I26H7USfluIZZhOLgcutoH+n/VNZXIKyaJtG/FonHTffxVPfGKtFAdN2t 4AHydTzI1PFQOwMS274vo94DlpcFYj66vl3A9GDocB6viWKJXqrPOQg8pg1ifbB2tfh1 WmlCa6GRqvpkVmQp73m3FyXUOol+vpPfhavfi8gagVdjvNkUhz5TVOZHFInR7jM8LgiW M5gGbsckWrdmgL/c65JWTzgoQp6pk9n9r/5erOArNSvweGyfVAcfxf+cX7PJ5eF8JgS8 kN+DcdPvRZY3Q2tlj0bNfo4sATUJJCY07jKff0aoEL7FLA6S6XtJDWdD42Cgn4WfwhS9 PU4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TI3PkvJA; 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 bp37-20020a05622a1ba500b00425893f2fc1si7236958qtb.406.2023.12.12.04.35.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2023 04:35:47 -0800 (PST) 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=TI3PkvJA; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD1y8-0007gz-De; Tue, 12 Dec 2023 07:34:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rD1xy-0007fJ-N3 for qemu-devel@nongnu.org; Tue, 12 Dec 2023 07:34:28 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rD1xt-0006cX-KF for qemu-devel@nongnu.org; Tue, 12 Dec 2023 07:34:24 -0500 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a1ef2f5ed02so608132166b.1 for ; Tue, 12 Dec 2023 04:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702384460; x=1702989260; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NDQDiSIXlkgjP0mASXiCW1Z5PDJEfauay7W7xh/vCZQ=; b=TI3PkvJAKD3QCOSMf3OoM3oY9H9xJQdUAGWM2FwVzWmfFRrLlMSszTSbk5PNkAaWiM RCb2cL/Y3ChkDmtg4hDg2QqVTjhHkHnX3gt6FJbSsrcpbCwtYdvqgMFPN0LfWEgOWdqv zZlpCHJeV+6VfXiWPLjrTkBXQ7pTAzJvPLAX2TGCyL09Mc5OCt9/EzDwho78wSIPui/v 9NJHs6ULGsV4i1hDzHVArYsGV9n3eRG8Gl5zWoVdhxnBbhKJH5n2xmJLmFT2Hwc9XMw8 2QhG1EhA1aS0Qdys+wAwmdwnoumoGWMHBivupg1MBGEvw/08lVDsvRPWc5s7ddc1UFPs HEmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702384460; x=1702989260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NDQDiSIXlkgjP0mASXiCW1Z5PDJEfauay7W7xh/vCZQ=; b=Ezz/GGpT/7K/CJgqJOxfIdlEGJLFoE677qK4daSF4pV3l9XLedHbGoWJz1L/v4yZMN mKVmCj0C9e4mOwXXgjLTOkDSiLajg7/DnSuciX/GrZUJaEQ7Qz8DI5E7xAObeOXW3k+D z3tGbuAWXFYxNYyoZ9o5Z7bsvASVmExMKzDpVbWd4exYQiMYlWMqVKFlf5mUByPYnJ7r qi8V92KcC9YrFzmf6+j4lkB94JCIDhxWxFgcMZnBiU+pkYg3rGHbr2Q4LJ8PpxnXXeRe JimwTp3dAoml3T7CHG/VP2jA93mXvU3mg0InnWT6VPOzTxhi58sa+RKXdqPrvJf9v15C FOXQ== X-Gm-Message-State: AOJu0Yz/kG+xxJK0nZ2mKXQJKz4bEloAYFm7zeEuLvh61viHrvYcjrOR /UZdNqXnI6cd+Dla12QN6ucI59O1xjAFPphM0FAsNA== X-Received: by 2002:a17:906:74cf:b0:a1a:7568:1d4d with SMTP id z15-20020a17090674cf00b00a1a75681d4dmr3498417ejl.27.1702384459881; Tue, 12 Dec 2023 04:34:19 -0800 (PST) Received: from m1x-phil.lan ([176.176.175.193]) by smtp.gmail.com with ESMTPSA id ub27-20020a170907c81b00b00a1df4387f16sm6285128ejc.95.2023.12.12.04.34.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Dec 2023 04:34:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Claudio Fontana , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, Richard Henderson , qemu-riscv@nongnu.org, Brian Cain , Thomas Huth , Paolo Bonzini , qemu-arm@nongnu.org, Manos Pitsidianakis , =?utf-8?q?Alex_Benn=C3=A9e?= , Anton Johansson , Warner Losh , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Marc-And?= =?utf-8?q?r=C3=A9_Lureau?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=C3=A9?= , Peter Xu , David Hildenbrand Subject: [PATCH v2 02/23] exec: Expose 'target_page.h' API to user emulation Date: Tue, 12 Dec 2023 13:33:38 +0100 Message-ID: <20231212123401.37493-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231212123401.37493-1-philmd@linaro.org> References: <20231212123401.37493-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=philmd@linaro.org; helo=mail-ej1-x62a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org User-only objects might benefit from the "exec/target_page.h" API, which allows to build some objects once for all targets. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Warner Losh Reviewed-by: Richard Henderson --- meson.build | 2 +- page-target.c | 43 +++++++++++++++++++++++++++++++++++++++++++ system/physmem.c | 35 ----------------------------------- 3 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 page-target.c diff --git a/meson.build b/meson.build index d2c4c2adb3..5fdc4ef8db 100644 --- a/meson.build +++ b/meson.build @@ -3488,7 +3488,7 @@ if get_option('b_lto') pagevary = declare_dependency(link_with: pagevary) endif common_ss.add(pagevary) -specific_ss.add(files('page-vary-target.c')) +specific_ss.add(files('page-target.c', 'page-vary-target.c')) subdir('backends') subdir('disas') diff --git a/page-target.c b/page-target.c new file mode 100644 index 0000000000..d286e2d58b --- /dev/null +++ b/page-target.c @@ -0,0 +1,43 @@ +/* + * QEMU page values getters (target independent) + * + * Copyright (c) 2003 Fabrice Bellard + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "qemu/osdep.h" +#include "exec/target_page.h" +#include "exec/cpu-defs.h" +#include "exec/cpu-all.h" + +size_t qemu_target_page_size(void) +{ + return TARGET_PAGE_SIZE; +} + +int qemu_target_page_mask(void) +{ + return TARGET_PAGE_MASK; +} + +int qemu_target_page_bits(void) +{ + return TARGET_PAGE_BITS; +} + +int qemu_target_page_bits_min(void) +{ + return TARGET_PAGE_BITS_MIN; +} + +/* Convert target pages to MiB (2**20). */ +size_t qemu_target_pages_to_MiB(size_t pages) +{ + int page_bits = TARGET_PAGE_BITS; + + /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */ + g_assert(page_bits < 20); + + return pages >> (20 - page_bits); +} diff --git a/system/physmem.c b/system/physmem.c index a63853a7bc..4bdb3d0592 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3422,41 +3422,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, return 0; } -/* - * Allows code that needs to deal with migration bitmaps etc to still be built - * target independent. - */ -size_t qemu_target_page_size(void) -{ - return TARGET_PAGE_SIZE; -} - -int qemu_target_page_mask(void) -{ - return TARGET_PAGE_MASK; -} - -int qemu_target_page_bits(void) -{ - return TARGET_PAGE_BITS; -} - -int qemu_target_page_bits_min(void) -{ - return TARGET_PAGE_BITS_MIN; -} - -/* Convert target pages to MiB (2**20). */ -size_t qemu_target_pages_to_MiB(size_t pages) -{ - int page_bits = TARGET_PAGE_BITS; - - /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */ - g_assert(page_bits < 20); - - return pages >> (20 - page_bits); -} - bool cpu_physical_memory_is_io(hwaddr phys_addr) { MemoryRegion*mr;