Skip to content

Commit 8c45039

Browse files
committed
cpu: Remove page_size_init
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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Tested-by: Ilya Leoshkevich <[email protected]> Acked-by: Helge Deller <[email protected]> Message-Id: <[email protected]>
1 parent 01e4498 commit 8c45039

File tree

7 files changed

+19
-27
lines changed

7 files changed

+19
-27
lines changed

accel/tcg/translate-all.c

-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data)
256256

257257
void page_init(void)
258258
{
259-
page_size_init();
260259
page_table_config_init();
261260
}
262261

bsd-user/main.c

+12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
#include "host-os.h"
5050
#include "target_arch_cpu.h"
5151

52+
53+
/*
54+
* TODO: Remove these and rely only on qemu_real_host_page_size().
55+
*/
56+
uintptr_t qemu_host_page_size;
57+
intptr_t qemu_host_page_mask;
58+
5259
static bool opt_one_insn_per_tb;
5360
uintptr_t guest_base;
5461
bool have_guest_base;
@@ -307,6 +314,9 @@ int main(int argc, char **argv)
307314
(void) envlist_setenv(envlist, *wrk);
308315
}
309316

317+
qemu_host_page_size = getpagesize();
318+
qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE);
319+
310320
cpu_model = NULL;
311321

312322
qemu_add_opts(&qemu_trace_opts);
@@ -404,6 +414,8 @@ int main(int argc, char **argv)
404414
}
405415
}
406416

417+
qemu_host_page_mask = -qemu_host_page_size;
418+
407419
/* init debug */
408420
{
409421
int mask = 0;

bsd-user/qemu.h

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ extern char **environ;
3939
#include "qemu/clang-tsa.h"
4040

4141
#include "qemu-os.h"
42+
/*
43+
* TODO: Remove these and rely only on qemu_real_host_page_size().
44+
*/
45+
extern uintptr_t qemu_host_page_size;
46+
extern intptr_t qemu_host_page_mask;
47+
#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
48+
4249
/*
4350
* This struct is used to hold certain information about the image. Basically,
4451
* it replicates in user space what would be certain task_struct fields in the

cpu-target.c

-16
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
#include "trace/trace-root.h"
4646
#include "qemu/accel.h"
4747

48-
uintptr_t qemu_host_page_size;
49-
intptr_t qemu_host_page_mask;
50-
5148
#ifndef CONFIG_USER_ONLY
5249
static int cpu_common_post_load(void *opaque, int version_id)
5350
{
@@ -474,16 +471,3 @@ const char *target_name(void)
474471
{
475472
return TARGET_NAME;
476473
}
477-
478-
void page_size_init(void)
479-
{
480-
/* NOTE: we can always suppose that qemu_host_page_size >=
481-
TARGET_PAGE_SIZE */
482-
if (qemu_host_page_size == 0) {
483-
qemu_host_page_size = qemu_real_host_page_size();
484-
}
485-
if (qemu_host_page_size < TARGET_PAGE_SIZE) {
486-
qemu_host_page_size = TARGET_PAGE_SIZE;
487-
}
488-
qemu_host_page_mask = -(intptr_t)qemu_host_page_size;
489-
}

include/exec/cpu-common.h

-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
void cpu_exec_init_all(void);
2121
void cpu_exec_step_atomic(CPUState *cpu);
2222

23-
/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even
24-
* when intptr_t is 32-bit and we are aligning a long long.
25-
*/
26-
extern uintptr_t qemu_host_page_size;
27-
extern intptr_t qemu_host_page_mask;
28-
29-
#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)
3023
#define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_size())
3124

3225
/* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */

include/hw/core/cpu.h

-2
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,6 @@ bool target_words_bigendian(void);
11791179

11801180
const char *target_name(void);
11811181

1182-
void page_size_init(void);
1183-
11841182
#ifdef NEED_CPU_H
11851183

11861184
#ifndef CONFIG_USER_ONLY

system/vl.c

-1
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,6 @@ static void qemu_create_machine(QDict *qdict)
21182118
}
21192119

21202120
cpu_exec_init_all();
2121-
page_size_init();
21222121

21232122
if (machine_class->hw_version) {
21242123
qemu_set_hw_version(machine_class->hw_version);

0 commit comments

Comments
 (0)