From patchwork Fri Apr 26 19:41:24 2024 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: 792355 Delivered-To: patch@linaro.org Received: by 2002:adf:cc13:0:b0:346:15ad:a2a with SMTP id x19csp625515wrh; Fri, 26 Apr 2024 12:45:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkId4L2x3cxo8jrKF1Aa1Gs5lbEOq/rCQdYIrm6DR9avx0Zvt/ZinwXhOT1t03ba2GJfHLrLX7bHCZZC3JAlPv X-Google-Smtp-Source: AGHT+IEgaBliXu7S7DlDn5ZDueBRNKGPk/IPlGlAFwUJYDdic+2XTVjJ5a8vWoz8fKoL4kuCxoxA X-Received: by 2002:a05:620a:8305:b0:78d:743f:34ab with SMTP id pa5-20020a05620a830500b0078d743f34abmr3879272qkn.65.1714160711546; Fri, 26 Apr 2024 12:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714160711; cv=none; d=google.com; s=arc-20160816; b=QlazVbxoDISNqZirz72T8Ft0T1qXMg7BE5vIh4Y4cwVJAapqpxlaqPQZzMLpZ6xf29 0aIfZJ0bQQ+zc6NOocvASS8EFZt0MioAoAXCJXe8IMtEAAj2advjj2XNzdos57EJENGe S64e0csXjGQSBrfpoFc7HpdbLoeQ7xHtoTgShMimbpBuNXkitrhJIOC9ClNZSvCm8EyM /q8XNqMZZTOu51bNytugSpvzfU2iceLrGNI58VnmFdLrTE6xfUx+6oLnExXcPQbstF+i /yhRBNkCjlyyyNkZMNUt7AilCQehFQ2D0TSNFh0ikehlyhFH+IG3q7uNhwVpPfzPAhQk p1aw== 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=S4r3G1A3uieLAlLtfe4V5hp04cU912Q1LgbF6VzVX8w=; fh=qazebhOlHzaBfxrU5INcXm/HHTlsf/tJJNQLTH50jKQ=; b=YQd2OsGGwhKtqBaIAeXfizzRnUlJHMsN6/TDgf1jCmhYUcMSukyOr/m7eDmWiX8Vh2 FeckOaZDjP5A9afVAlq/+tN/Phy6lTmGL1qhg7PzM+xjK25GClZzXJgkywF9U44XsxBV RUW8rZrGuGN+AQVlasLMnGq36XUM4SlspTrjzzE7utwpoK8bTBIuL0jQPrpZLzrqONAx EmcQuLvqFd4lcozbCJldONp2vz//94EfL7VVSMxty0driaH5iQU9Dk4id35clbgeelX/ nYgKc4Dv990yByPy0IfKTckqB9V+MIpP/Rfoq8L3V4HvbCUrnAzIQ/6nKxVVP9RjnFpv xxbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rtYOCSNP; 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 h24-20020a37de18000000b00790636a4436si15593568qkj.374.2024.04.26.12.45.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Apr 2024 12:45:11 -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=rtYOCSNP; 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 1s0RSv-0000Uw-JF; Fri, 26 Apr 2024 15:42:37 -0400 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 1s0RSs-0000Mc-DW for qemu-devel@nongnu.org; Fri, 26 Apr 2024 15:42:34 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s0RSo-0002qE-T4 for qemu-devel@nongnu.org; Fri, 26 Apr 2024 15:42:34 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-51abd9fcbf6so4393630e87.1 for ; Fri, 26 Apr 2024 12:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714160548; x=1714765348; 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=S4r3G1A3uieLAlLtfe4V5hp04cU912Q1LgbF6VzVX8w=; b=rtYOCSNPRvlTRkjO3j1jcvOoMrUCNJVjC34gA/YJ6U7r31pVKuFrOTp0gzobW5O91I zpdiq55+fWg+lWmYcy8of8j38ElSnSEyxWLNWvRf9ggs2Tv3AcHbnBonAtvk9fc19Zi5 DVQyFckW1mu4GhW93/EbgwwZXT3XGUOtlc6GxVliT3+m5acn06H7DqWcXj4sEQrM/zwa R7G7hqyLIZ9Z71Dnogjta4WHlkSaYXbn3FYbj9axP1k8Zar38Zqz3Bjk84WwNFOueYHj imK0e6y0AbiTZ/Chhidv5ho9zV5Sl+mSaGtQEb02rGthluHd7psRihwrvZUI2kzM5ARV ZDJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714160548; x=1714765348; 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=S4r3G1A3uieLAlLtfe4V5hp04cU912Q1LgbF6VzVX8w=; b=Aa2KjKt/4c4qDD5fEUGX/JuRHT8/t9cx8Koic17NgpNxW5OHNlBCdEh+v+YVes2CoB HCugZNRzePuoHN1uCvGIMUZ2R0YL196A6GLC41Jc8/RDlK89oH5Ne9ZJreurQCQqUxYN AO+1kvunvovVajzSDSh8koSgbuJHZF/nqGkU2l6l2OhKMk0K9vHBxirKifkmlkhEF29B nUDryGVemErOwqAPDInja8V7t5GnF5kTxaLVby3M8+vqGZY4iGQJm+9OnCiDFqer3T+/ XnjHJvtUS8IgM4oUEf4EHnCrC+LBD64k8sle8wgU702vVpCGlveS9NWZPrVfQFt9MXqO laEg== X-Gm-Message-State: AOJu0YwRZ8W7/1mhUAC5ybWerfbPS03EoqdU0wFU4fF1DSadTuPV4XFQ RyxVKsDfKtqPtH4mxp2H4jBZy+lq+8AyovKlrlmZHRg8aACZacKEAGPeaCd2a953dFy4MOlaRCx txyo= X-Received: by 2002:ac2:483c:0:b0:51c:5570:f570 with SMTP id 28-20020ac2483c000000b0051c5570f570mr2916306lft.59.1714160548267; Fri, 26 Apr 2024 12:42:28 -0700 (PDT) Received: from m1x-phil.lan (aul93-h02-176-184-11-147.dsl.sta.abo.bbox.fr. [176.184.11.147]) by smtp.gmail.com with ESMTPSA id r25-20020a170906351900b00a55b5c365dfsm6435433eja.199.2024.04.26.12.42.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Apr 2024 12:42:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Warner Losh , Richard Henderson , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , Peter Xu , David Hildenbrand Subject: [PULL 04/38] exec: Expose 'target_page.h' API to user emulation Date: Fri, 26 Apr 2024 21:41:24 +0200 Message-ID: <20240426194200.43723-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240426194200.43723-1-philmd@linaro.org> References: <20240426194200.43723-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.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=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 Message-Id: <20231211212003.21686-3-philmd@linaro.org> --- meson.build | 2 +- page-target.c | 44 ++++++++++++++++++++++++++++++++++++++++++ system/physmem.c | 30 ---------------------------- target/target-common.c | 10 ---------- target/meson.build | 2 -- 5 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 page-target.c delete mode 100644 target/target-common.c diff --git a/meson.build b/meson.build index 96fdc6dfd2..5db2dbc12e 100644 --- a/meson.build +++ b/meson.build @@ -3523,7 +3523,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..82211c8593 --- /dev/null +++ b/page-target.c @@ -0,0 +1,44 @@ +/* + * 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 "cpu.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 c3d04ca921..1a81c226ba 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3540,36 +3540,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_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; diff --git a/target/target-common.c b/target/target-common.c deleted file mode 100644 index 903b10cfe4..0000000000 --- a/target/target-common.c +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "qemu/osdep.h" - -#include "cpu.h" -#include "exec/target_page.h" - -int qemu_target_page_mask(void) -{ - return TARGET_PAGE_MASK; -} diff --git a/target/meson.build b/target/meson.build index 59b46b2ef4..1c2e6f2b19 100644 --- a/target/meson.build +++ b/target/meson.build @@ -18,5 +18,3 @@ subdir('sh4') subdir('sparc') subdir('tricore') subdir('xtensa') - -specific_ss.add(files('target-common.c'))