We need to be able access the variable TARGET_PAGE_* macros in a target-independent manner.
Signed-off-by: Anton Johansson <a...@rev.ng> --- include/exec/cpu-all.h | 29 ++++++++++------------------- include/exec/cpu-common.h | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index a1e4dee6a2..83165b1ce4 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -149,30 +149,21 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val #include "exec/memory_ldst_phys.h.inc" #endif -/* page related stuff */ - -#ifdef TARGET_PAGE_BITS_VARY -# include "exec/page-vary.h" -extern const TargetPageBits target_page; -#ifdef CONFIG_DEBUG_TCG -#define TARGET_PAGE_BITS_MIN ({ assert(target_page.decided); \ - target_page.bits_min; }) -#define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bits; }) -#define TARGET_PAGE_MASK ({ assert(target_page.decided); \ - (target_long)target_page.mask; }) -#else -#define TARGET_PAGE_BITS_MIN target_page.bits_min -#define TARGET_PAGE_BITS target_page.bits -#define TARGET_PAGE_MASK ((target_long)target_page.mask) -#endif -#define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) -#else +/* Non-variable page size macros */ +#ifndef TARGET_PAGE_BITS_VARY #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) #define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) #endif -#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) +/* + * Check that softmmu targets are using variable page sizes, we need this + * for the TARGET_PAGE_* macros to be target independent. + */ +#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_PAGE_BITS_VARY) +# error Need to use TARGET_PAGE_BITS_VARY on system mode +#endif /* same as PROT_xxx */ #define PAGE_READ 0x0001 diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 605b160a7e..df53252d51 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -26,6 +26,31 @@ typedef uint64_t vaddr; #define VADDR_PRIX PRIX64 #define VADDR_MAX UINT64_MAX +/** + * Variable page size macros + * + * TARGET_PAGE_BITS_VARY is assumed for softmmu targets so + * these macros are target independent. This is checked in + * cpu-all.h. + */ +#ifndef CONFIG_USER_ONLY +# include "exec/page-vary.h" +extern const TargetPageBits target_page; +#ifdef CONFIG_DEBUG_TCG +#define TARGET_PAGE_BITS_MIN ({ assert(target_page.decided); \ + target_page.bits_min; }) +#define TARGET_PAGE_BITS ({ assert(target_page.decided); target_page.bits; }) +#define TARGET_PAGE_MASK ({ assert(target_page.decided); \ + (int)target_page.mask; }) +#else +#define TARGET_PAGE_BITS_MIN target_page.bits_min +#define TARGET_PAGE_BITS target_page.bits +#define TARGET_PAGE_MASK ((int)target_page.mask) +#endif +#define TARGET_PAGE_SIZE (-(int)TARGET_PAGE_MASK) +#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE) +#endif + void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); -- 2.43.0