Skip to content

Commit

Permalink
cpu: Remove page_size_init
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rth7680 committed Feb 22, 2024
1 parent 1b65fc5 commit 490b288
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
1 change: 0 additions & 1 deletion accel/tcg/translate-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
12 changes: 12 additions & 0 deletions bsd-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -403,6 +413,8 @@ int main(int argc, char **argv)
}
}

qemu_host_page_mask = -qemu_host_page_size;

/* init debug */
{
int mask = 0;
Expand Down
7 changes: 7 additions & 0 deletions bsd-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions cpu-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,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;
}
7 changes: 0 additions & 7 deletions include/exec/cpu-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 0 additions & 2 deletions include/hw/core/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion system/vl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 490b288

Please sign in to comment.