From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Warner Losh" <imp@bsdimp.com>
Subject: [PATCH 05/21] exec: Expose 'target_page.h' API to user emulation
Date: Wed, 17 Apr 2024 20:27:50 +0200 [thread overview]
Message-ID: <20240417182806.69446-6-philmd@linaro.org> (raw)
In-Reply-To: <20240417182806.69446-1-philmd@linaro.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é <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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 da8295b405..44d337f67b 100644
--- a/meson.build
+++ b/meson.build
@@ -3554,7 +3554,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 a4fe3d2bf8..dd7b222942 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3504,36 +3504,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 dee2ac47e0..a53a60486f 100644
--- a/target/meson.build
+++ b/target/meson.build
@@ -19,5 +19,3 @@ subdir('sh4')
subdir('sparc')
subdir('tricore')
subdir('xtensa')
-
-specific_ss.add(files('target-common.c'))
--
2.41.0
next prev parent reply other threads:[~2024-04-17 18:29 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 18:27 [PATCH 00/21] exec/next for 9.1 Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 01/21] gdbstub: Simplify #ifdef'ry in helpers.h Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 02/21] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 03/21] exec: Rename NEED_CPU_H -> COMPILING_PER_TARGET Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 04/21] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
2024-04-17 18:27 ` Philippe Mathieu-Daudé [this message]
2024-04-17 18:27 ` [PATCH 06/21] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 07/21] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 08/21] gdbstub: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
2024-04-17 19:10 ` Richard Henderson
2024-04-17 18:27 ` [PATCH 09/21] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
2024-04-17 19:14 ` Richard Henderson
2024-04-18 10:59 ` Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 10/21] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
2024-04-17 19:17 ` Richard Henderson
2024-04-17 18:27 ` [PATCH 11/21] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 12/21] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
2024-04-17 19:18 ` Richard Henderson
2024-04-17 18:27 ` [PATCH 13/21] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
2024-04-17 19:30 ` Richard Henderson
2024-04-18 10:45 ` Philippe Mathieu-Daudé
2024-04-17 18:27 ` [PATCH 14/21] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
2024-04-17 18:28 ` [PATCH 15/21] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
2024-04-17 19:25 ` Richard Henderson
2024-04-17 18:28 ` [PATCH 16/21] exec/cpu-all: Remove unused 'qemu/thread.h' header Philippe Mathieu-Daudé
2024-04-17 19:25 ` Richard Henderson
2024-04-17 18:28 ` [PATCH 17/21] exec/cpu-all: Remove unused tswapls() definitions Philippe Mathieu-Daudé
2024-04-17 19:26 ` Richard Henderson
2024-04-17 18:28 ` [PATCH 18/21] exec: Declare target_words_bigendian() in 'exec/tswap.h' Philippe Mathieu-Daudé
2024-04-17 19:32 ` Richard Henderson
2024-04-17 18:28 ` [PATCH 19/21] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h' Philippe Mathieu-Daudé
2024-04-17 19:33 ` Richard Henderson
2024-04-17 18:28 ` [PATCH 20/21] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
2024-04-17 19:35 ` Richard Henderson
2024-04-17 18:28 ` [PATCH 21/21] exec: Declare abi_ptr type in its own 'abi_ptr.h' header Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240417182806.69446-6-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=imp@bsdimp.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).