mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00: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
|
#endif
|
||||||
#include "tcg/tcg-ldst.h"
|
#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 */
|
/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */
|
||||||
/* #define DEBUG_TLB */
|
/* #define DEBUG_TLB */
|
||||||
|
@ -34,14 +34,8 @@
|
|||||||
#ifndef TARGET_VIRT_ADDR_SPACE_BITS
|
#ifndef TARGET_VIRT_ADDR_SPACE_BITS
|
||||||
# error TARGET_VIRT_ADDR_SPACE_BITS must be defined in cpu-param.h
|
# error TARGET_VIRT_ADDR_SPACE_BITS must be defined in cpu-param.h
|
||||||
#endif
|
#endif
|
||||||
#ifndef TARGET_PAGE_BITS
|
#if !defined(TARGET_PAGE_BITS) && !defined(TARGET_PAGE_BITS_VARY)
|
||||||
# ifdef TARGET_PAGE_BITS_VARY
|
# error TARGET_PAGE_BITS must be defined in cpu-param.h
|
||||||
# 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
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "exec/target_long.h"
|
#include "exec/target_long.h"
|
||||||
|
@ -41,7 +41,6 @@ extern const TargetPageBits target_page;
|
|||||||
# endif
|
# endif
|
||||||
# define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK)
|
# define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK)
|
||||||
#else
|
#else
|
||||||
# define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS
|
|
||||||
# define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS)
|
# define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS)
|
||||||
# define TARGET_PAGE_MASK ((TARGET_PAGE_TYPE)-1 << TARGET_PAGE_BITS)
|
# define TARGET_PAGE_MASK ((TARGET_PAGE_TYPE)-1 << TARGET_PAGE_BITS)
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,19 +23,45 @@
|
|||||||
#include "exec/page-vary.h"
|
#include "exec/page-vary.h"
|
||||||
#include "exec/target_page.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)
|
int migration_legacy_page_bits(void)
|
||||||
{
|
{
|
||||||
#ifdef TARGET_PAGE_BITS_VARY
|
#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
|
#else
|
||||||
return TARGET_PAGE_BITS;
|
return TARGET_PAGE_BITS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool set_preferred_target_page_bits(int bits)
|
bool set_preferred_target_page_bits(int bits)
|
||||||
{
|
{
|
||||||
#ifdef TARGET_PAGE_BITS_VARY
|
|
||||||
assert(bits >= TARGET_PAGE_BITS_MIN);
|
assert(bits >= TARGET_PAGE_BITS_MIN);
|
||||||
|
#ifdef TARGET_PAGE_BITS_VARY
|
||||||
return set_preferred_target_page_bits_common(bits);
|
return set_preferred_target_page_bits_common(bits);
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
@ -44,5 +70,12 @@ bool set_preferred_target_page_bits(int bits)
|
|||||||
|
|
||||||
void finalize_target_page_bits(void)
|
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.
|
* a 4k minimum to match x86 host, which can minimize emulation issues.
|
||||||
*/
|
*/
|
||||||
# define TARGET_PAGE_BITS_VARY
|
# define TARGET_PAGE_BITS_VARY
|
||||||
# define TARGET_PAGE_BITS_MIN 12
|
|
||||||
# define TARGET_VIRT_ADDR_SPACE_BITS 63
|
# define TARGET_VIRT_ADDR_SPACE_BITS 63
|
||||||
#else
|
#else
|
||||||
# define TARGET_PAGE_BITS 13
|
# define TARGET_PAGE_BITS 13
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
# else
|
# else
|
||||||
/* Allow user-only to vary page size from 4k */
|
/* Allow user-only to vary page size from 4k */
|
||||||
# define TARGET_PAGE_BITS_VARY
|
# define TARGET_PAGE_BITS_VARY
|
||||||
# define TARGET_PAGE_BITS_MIN 12
|
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# define TARGET_PAGE_BITS 12
|
# define TARGET_PAGE_BITS 12
|
||||||
@ -35,7 +34,7 @@
|
|||||||
* have to support 1K tiny pages.
|
* have to support 1K tiny pages.
|
||||||
*/
|
*/
|
||||||
# define TARGET_PAGE_BITS_VARY
|
# define TARGET_PAGE_BITS_VARY
|
||||||
# define TARGET_PAGE_BITS_MIN 10
|
# define TARGET_PAGE_BITS_LEGACY 10
|
||||||
#endif /* !CONFIG_USER_ONLY */
|
#endif /* !CONFIG_USER_ONLY */
|
||||||
|
|
||||||
/* ARM processors have a weak memory model */
|
/* ARM processors have a weak memory model */
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#ifdef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
/* Allow user-only to vary page size from 4k */
|
/* Allow user-only to vary page size from 4k */
|
||||||
# define TARGET_PAGE_BITS_VARY
|
# define TARGET_PAGE_BITS_VARY
|
||||||
# define TARGET_PAGE_BITS_MIN 12
|
|
||||||
#else
|
#else
|
||||||
# define TARGET_PAGE_BITS 12
|
# define TARGET_PAGE_BITS 12
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user