[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 47/60] cpu: Remove page_size_init
From: |
Richard Henderson |
Subject: |
[PATCH 47/60] cpu: Remove page_size_init |
Date: |
Fri, 1 Mar 2024 13:06:06 -1000 |
Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user.
It should be removed from bsd-user as well, but defer that cleanup.
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Helge Deller <deller@gmx.de>
Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org>
---
bsd-user/qemu.h | 7 +++++++
include/exec/cpu-common.h | 7 -------
include/hw/core/cpu.h | 2 --
accel/tcg/translate-all.c | 1 -
bsd-user/main.c | 12 ++++++++++++
cpu-target.c | 16 ----------------
system/vl.c | 1 -
7 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index dc842fffa7..c05c512767 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -39,6 +39,13 @@ extern char **environ;
#include "qemu/clang-tsa.h"
#include "qemu-os.h"
+/*
+ * TODO: Remove these and rely only on qemu_real_host_page_size().
+ */
+extern uintptr_t qemu_host_page_size;
+extern intptr_t qemu_host_page_mask;
+#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
+
/*
* This struct is used to hold certain information about the image. Basically,
* it replicates in user space what would be certain task_struct fields in the
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 9ead1be100..6346df17ce 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -20,13 +20,6 @@
void cpu_exec_init_all(void);
void cpu_exec_step_atomic(CPUState *cpu);
-/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even
- * when intptr_t is 32-bit and we are aligning a long long.
- */
-extern uintptr_t qemu_host_page_size;
-extern intptr_t qemu_host_page_mask;
-
-#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
#define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size())
/* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index af1a29526d..d0e345419f 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1179,8 +1179,6 @@ bool target_words_bigendian(void);
const char *target_name(void);
-void page_size_init(void);
-
#ifdef NEED_CPU_H
#ifndef CONFIG_USER_ONLY
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 1c695efe02..c1f57e894a 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t
host_pc, uint64_t *data)
void page_init(void)
{
- page_size_init();
page_table_config_init();
}
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 6ab3efd6c0..512d4ab69f 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -49,6 +49,13 @@
#include "host-os.h"
#include "target_arch_cpu.h"
+
+/*
+ * TODO: Remove these and rely only on qemu_real_host_page_size().
+ */
+uintptr_t qemu_host_page_size;
+intptr_t qemu_host_page_mask;
+
static bool opt_one_insn_per_tb;
uintptr_t guest_base;
bool have_guest_base;
@@ -307,6 +314,9 @@ int main(int argc, char **argv)
(void) envlist_setenv(envlist, *wrk);
}
+ qemu_host_page_size = getpagesize();
+ qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE);
+
cpu_model = NULL;
qemu_add_opts(&qemu_trace_opts);
@@ -404,6 +414,8 @@ int main(int argc, char **argv)
}
}
+ qemu_host_page_mask = -qemu_host_page_size;
+
/* init debug */
{
int mask = 0;
diff --git a/cpu-target.c b/cpu-target.c
index 86444cc2c6..4c0621bf33 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -45,9 +45,6 @@
#include "trace/trace-root.h"
#include "qemu/accel.h"
-uintptr_t qemu_host_page_size;
-intptr_t qemu_host_page_mask;
-
#ifndef CONFIG_USER_ONLY
static int cpu_common_post_load(void *opaque, int version_id)
{
@@ -474,16 +471,3 @@ const char *target_name(void)
{
return TARGET_NAME;
}
-
-void page_size_init(void)
-{
- /* NOTE: we can always suppose that qemu_host_page_size >=
- TARGET_PAGE_SIZE */
- if (qemu_host_page_size == 0) {
- qemu_host_page_size = qemu_real_host_page_size();
- }
- if (qemu_host_page_size < TARGET_PAGE_SIZE) {
- qemu_host_page_size = TARGET_PAGE_SIZE;
- }
- qemu_host_page_mask = -(intptr_t)qemu_host_page_size;
-}
diff --git a/system/vl.c b/system/vl.c
index e480afd7a0..48aae6e053 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2118,7 +2118,6 @@ static void qemu_create_machine(QDict *qdict)
}
cpu_exec_init_all();
- page_size_init();
if (machine_class->hw_version) {
qemu_set_hw_version(machine_class->hw_version);
--
2.34.1
- [PATCH 17/60] tcg: Avoid double lock if page tables happen to be in mmio memory., (continued)
- [PATCH 17/60] tcg: Avoid double lock if page tables happen to be in mmio memory., Richard Henderson, 2024/03/01
- [PATCH 29/60] migration: Remove qemu_host_page_size, Richard Henderson, 2024/03/01
- [PATCH 31/60] softmmu/physmem: Remove qemu_host_page_size, Richard Henderson, 2024/03/01
- [PATCH 36/60] linux-user: Fix sub-host-page mmap, Richard Henderson, 2024/03/01
- [PATCH 38/60] linux-user: Do early mmap placement only for reserved_va, Richard Henderson, 2024/03/01
- [PATCH 39/60] linux-user: Split out do_munmap, Richard Henderson, 2024/03/01
- [PATCH 41/60] linux-user: Split out mmap_h_eq_g, Richard Henderson, 2024/03/01
- [PATCH 45/60] tests/tcg: Extend file in linux-madvise.c, Richard Henderson, 2024/03/01
- [PATCH 42/60] linux-user: Split out mmap_h_lt_g, Richard Henderson, 2024/03/01
- [PATCH 50/60] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only, Richard Henderson, 2024/03/01
- [PATCH 47/60] cpu: Remove page_size_init,
Richard Henderson <=
- [PATCH 40/60] linux-user: Use do_munmap for target_mmap failure, Richard Henderson, 2024/03/01
- [PATCH 51/60] linux-user: Bound mmap_min_addr by host page size, Richard Henderson, 2024/03/01
- [PATCH 57/60] linux-user/loongarch64: Remove TARGET_FORCE_SHMLBA, Richard Henderson, 2024/03/01
- [PATCH 55/60] tcg/optimize: fix uninitialized variable, Richard Henderson, 2024/03/01
- [PATCH 59/60] linux-user: Rewrite target_shmat, Richard Henderson, 2024/03/01
- [PATCH 48/60] accel/tcg: Disconnect TargetPageDataNode from page size, Richard Henderson, 2024/03/01
- [PATCH 53/60] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only, Richard Henderson, 2024/03/01
- [PATCH 60/60] tests/tcg: Check that shmat() does not break /proc/self/maps, Richard Henderson, 2024/03/01
- [PATCH 49/60] linux-user: Allow TARGET_PAGE_BITS_VARY, Richard Henderson, 2024/03/01
- [PATCH 56/60] linux-user/x86_64: Handle the vsyscall page in open_self_maps_{2, 4}, Richard Henderson, 2024/03/01