mirror of
https://gitlab.com/qemu-project/qemu
synced 2025-04-29 09:22:36 +08:00
page-vary: Restrict scope of TARGET_PAGE_BITS_MIN
The only place we really need to know the minimum is within page-vary-target.c. Rename the target/arm TARGET_PAGE_BITS_MIN to TARGET_PAGE_BITS_LEGACY to emphasize what it really means. Move the assertions related to minimum page size as well. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
12eeb04ab4
commit
d11bf649d5
@ -49,7 +49,6 @@
|
||||
#endif
|
||||
#include "tcg/tcg-ldst.h"
|
||||
|
||||
QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & ((1u < TARGET_PAGE_BITS_MIN) - 1));
|
||||
|
||||
/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */
|
||||
/* #define DEBUG_TLB */
|
||||
|
@ -34,14 +34,8 @@
|
||||
#ifndef TARGET_VIRT_ADDR_SPACE_BITS
|
||||
# error TARGET_VIRT_ADDR_SPACE_BITS must be defined in cpu-param.h
|
||||
#endif
|
||||
#ifndef TARGET_PAGE_BITS
|
||||
# ifdef TARGET_PAGE_BITS_VARY
|
||||
# ifndef TARGET_PAGE_BITS_MIN
|
||||
# error TARGET_PAGE_BITS_MIN must be defined in cpu-param.h
|
||||
# endif
|
||||
# else
|
||||
# error TARGET_PAGE_BITS must be defined in cpu-param.h
|
||||
# endif
|
||||
#if !defined(TARGET_PAGE_BITS) && !defined(TARGET_PAGE_BITS_VARY)
|
||||
# error TARGET_PAGE_BITS must be defined in cpu-param.h
|
||||
#endif
|
||||
|
||||
#include "exec/target_long.h"
|
||||
|
@ -41,7 +41,6 @@ extern const TargetPageBits target_page;
|
||||
# endif
|
||||
# define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK)
|
||||
#else
|
||||
# define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS
|
||||
# define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS)
|
||||
# define TARGET_PAGE_MASK ((TARGET_PAGE_TYPE)-1 << TARGET_PAGE_BITS)
|
||||
#endif
|
||||
|
@ -23,19 +23,45 @@
|
||||
#include "exec/page-vary.h"
|
||||
#include "exec/target_page.h"
|
||||
|
||||
|
||||
/*
|
||||
* For system mode, the minimum comes from the number of bits
|
||||
* required for maximum alignment (6) and the number of bits
|
||||
* required for TLB_FLAGS_MASK (3).
|
||||
*
|
||||
* For user mode, TARGET_PAGE_BITS_VARY is a hack to allow the target
|
||||
* page size to match the host page size. Mostly, this reduces the
|
||||
* ordinary target page size to run on a host with 4KiB pages (i.e. x86).
|
||||
* There is no true minimum required by the implementation, but keep the
|
||||
* same minimum as for system mode for sanity.
|
||||
* See linux-user/mmap.c, mmap_h_lt_g and mmap_h_gt_g.
|
||||
*/
|
||||
#define TARGET_PAGE_BITS_MIN 9
|
||||
|
||||
#ifndef TARGET_PAGE_BITS_VARY
|
||||
QEMU_BUILD_BUG_ON(TARGET_PAGE_BITS < TARGET_PAGE_BITS_MIN);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
#include "exec/tlb-flags.h"
|
||||
|
||||
QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & ((1u < TARGET_PAGE_BITS_MIN) - 1));
|
||||
|
||||
int migration_legacy_page_bits(void)
|
||||
{
|
||||
#ifdef TARGET_PAGE_BITS_VARY
|
||||
return TARGET_PAGE_BITS_MIN;
|
||||
QEMU_BUILD_BUG_ON(TARGET_PAGE_BITS_LEGACY < TARGET_PAGE_BITS_MIN);
|
||||
return TARGET_PAGE_BITS_LEGACY;
|
||||
#else
|
||||
return TARGET_PAGE_BITS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bool set_preferred_target_page_bits(int bits)
|
||||
{
|
||||
#ifdef TARGET_PAGE_BITS_VARY
|
||||
assert(bits >= TARGET_PAGE_BITS_MIN);
|
||||
#ifdef TARGET_PAGE_BITS_VARY
|
||||
return set_preferred_target_page_bits_common(bits);
|
||||
#else
|
||||
return true;
|
||||
@ -44,5 +70,12 @@ bool set_preferred_target_page_bits(int bits)
|
||||
|
||||
void finalize_target_page_bits(void)
|
||||
{
|
||||
finalize_target_page_bits_common(TARGET_PAGE_BITS_MIN);
|
||||
#ifndef TARGET_PAGE_BITS_VARY
|
||||
finalize_target_page_bits_common(TARGET_PAGE_BITS);
|
||||
#elif defined(CONFIG_USER_ONLY)
|
||||
assert(target_page.bits != 0);
|
||||
finalize_target_page_bits_common(target_page.bits);
|
||||
#else
|
||||
finalize_target_page_bits_common(TARGET_PAGE_BITS_LEGACY);
|
||||
#endif
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* a 4k minimum to match x86 host, which can minimize emulation issues.
|
||||
*/
|
||||
# define TARGET_PAGE_BITS_VARY
|
||||
# define TARGET_PAGE_BITS_MIN 12
|
||||
# define TARGET_VIRT_ADDR_SPACE_BITS 63
|
||||
#else
|
||||
# define TARGET_PAGE_BITS 13
|
||||
|
@ -24,7 +24,6 @@
|
||||
# else
|
||||
/* Allow user-only to vary page size from 4k */
|
||||
# define TARGET_PAGE_BITS_VARY
|
||||
# define TARGET_PAGE_BITS_MIN 12
|
||||
# endif
|
||||
# else
|
||||
# define TARGET_PAGE_BITS 12
|
||||
@ -35,7 +34,7 @@
|
||||
* have to support 1K tiny pages.
|
||||
*/
|
||||
# define TARGET_PAGE_BITS_VARY
|
||||
# define TARGET_PAGE_BITS_MIN 10
|
||||
# define TARGET_PAGE_BITS_LEGACY 10
|
||||
#endif /* !CONFIG_USER_ONLY */
|
||||
|
||||
/* ARM processors have a weak memory model */
|
||||
|
@ -33,7 +33,6 @@
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
/* Allow user-only to vary page size from 4k */
|
||||
# define TARGET_PAGE_BITS_VARY
|
||||
# define TARGET_PAGE_BITS_MIN 12
|
||||
#else
|
||||
# define TARGET_PAGE_BITS 12
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user