mirror of https://github.com/xemu-project/xemu.git
exec: Move CPUTLBEntry helpers to cputlb.c
The following CPUTLBEntry helpers are only used in accel/tcg/cputlb.c: - tlb_index() - tlb_entry() - tlb_read_idx() - tlb_addr_write() Move them to this file, allowing to remove the huge "cpu.h" header inclusion from "exec/cpu_ldst.h". Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20240418192525.97451-13-philmd@linaro.org>
This commit is contained in:
parent
16aa8eaaac
commit
aacfd8bbaf
|
@ -27,6 +27,9 @@
|
||||||
#include "exec/tb-flush.h"
|
#include "exec/tb-flush.h"
|
||||||
#include "exec/memory-internal.h"
|
#include "exec/memory-internal.h"
|
||||||
#include "exec/ram_addr.h"
|
#include "exec/ram_addr.h"
|
||||||
|
#include "exec/mmu-access-type.h"
|
||||||
|
#include "exec/tlb-common.h"
|
||||||
|
#include "exec/vaddr.h"
|
||||||
#include "tcg/tcg.h"
|
#include "tcg/tcg.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "exec/log.h"
|
#include "exec/log.h"
|
||||||
|
@ -95,6 +98,54 @@ static inline size_t sizeof_tlb(CPUTLBDescFast *fast)
|
||||||
return fast->mask + (1 << CPU_TLB_ENTRY_BITS);
|
return fast->mask + (1 << CPU_TLB_ENTRY_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint64_t tlb_read_idx(const CPUTLBEntry *entry,
|
||||||
|
MMUAccessType access_type)
|
||||||
|
{
|
||||||
|
/* Do not rearrange the CPUTLBEntry structure members. */
|
||||||
|
QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_read) !=
|
||||||
|
MMU_DATA_LOAD * sizeof(uint64_t));
|
||||||
|
QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_write) !=
|
||||||
|
MMU_DATA_STORE * sizeof(uint64_t));
|
||||||
|
QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_code) !=
|
||||||
|
MMU_INST_FETCH * sizeof(uint64_t));
|
||||||
|
|
||||||
|
#if TARGET_LONG_BITS == 32
|
||||||
|
/* Use qatomic_read, in case of addr_write; only care about low bits. */
|
||||||
|
const uint32_t *ptr = (uint32_t *)&entry->addr_idx[access_type];
|
||||||
|
ptr += HOST_BIG_ENDIAN;
|
||||||
|
return qatomic_read(ptr);
|
||||||
|
#else
|
||||||
|
const uint64_t *ptr = &entry->addr_idx[access_type];
|
||||||
|
# if TCG_OVERSIZED_GUEST
|
||||||
|
return *ptr;
|
||||||
|
# else
|
||||||
|
/* ofs might correspond to .addr_write, so use qatomic_read */
|
||||||
|
return qatomic_read(ptr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t tlb_addr_write(const CPUTLBEntry *entry)
|
||||||
|
{
|
||||||
|
return tlb_read_idx(entry, MMU_DATA_STORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the TLB index corresponding to the mmu_idx + address pair. */
|
||||||
|
static inline uintptr_t tlb_index(CPUState *cpu, uintptr_t mmu_idx,
|
||||||
|
vaddr addr)
|
||||||
|
{
|
||||||
|
uintptr_t size_mask = cpu->neg.tlb.f[mmu_idx].mask >> CPU_TLB_ENTRY_BITS;
|
||||||
|
|
||||||
|
return (addr >> TARGET_PAGE_BITS) & size_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the TLB entry corresponding to the mmu_idx + address pair. */
|
||||||
|
static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx,
|
||||||
|
vaddr addr)
|
||||||
|
{
|
||||||
|
return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)];
|
||||||
|
}
|
||||||
|
|
||||||
static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns,
|
static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns,
|
||||||
size_t max_entries)
|
size_t max_entries)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,6 @@
|
||||||
#include "exec/abi_ptr.h"
|
#include "exec/abi_ptr.h"
|
||||||
#include "exec/mmu-access-type.h"
|
#include "exec/mmu-access-type.h"
|
||||||
#include "qemu/int128.h"
|
#include "qemu/int128.h"
|
||||||
#include "cpu.h"
|
|
||||||
|
|
||||||
#if defined(CONFIG_USER_ONLY)
|
#if defined(CONFIG_USER_ONLY)
|
||||||
|
|
||||||
|
@ -296,60 +295,6 @@ Int128 cpu_atomic_cmpxchgo_be_mmu(CPUArchState *env, abi_ptr addr,
|
||||||
Int128 cmpv, Int128 newv,
|
Int128 cmpv, Int128 newv,
|
||||||
MemOpIdx oi, uintptr_t retaddr);
|
MemOpIdx oi, uintptr_t retaddr);
|
||||||
|
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
|
||||||
|
|
||||||
#include "tcg/oversized-guest.h"
|
|
||||||
|
|
||||||
static inline uint64_t tlb_read_idx(const CPUTLBEntry *entry,
|
|
||||||
MMUAccessType access_type)
|
|
||||||
{
|
|
||||||
/* Do not rearrange the CPUTLBEntry structure members. */
|
|
||||||
QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_read) !=
|
|
||||||
MMU_DATA_LOAD * sizeof(uint64_t));
|
|
||||||
QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_write) !=
|
|
||||||
MMU_DATA_STORE * sizeof(uint64_t));
|
|
||||||
QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_code) !=
|
|
||||||
MMU_INST_FETCH * sizeof(uint64_t));
|
|
||||||
|
|
||||||
#if TARGET_LONG_BITS == 32
|
|
||||||
/* Use qatomic_read, in case of addr_write; only care about low bits. */
|
|
||||||
const uint32_t *ptr = (uint32_t *)&entry->addr_idx[access_type];
|
|
||||||
ptr += HOST_BIG_ENDIAN;
|
|
||||||
return qatomic_read(ptr);
|
|
||||||
#else
|
|
||||||
const uint64_t *ptr = &entry->addr_idx[access_type];
|
|
||||||
# if TCG_OVERSIZED_GUEST
|
|
||||||
return *ptr;
|
|
||||||
# else
|
|
||||||
/* ofs might correspond to .addr_write, so use qatomic_read */
|
|
||||||
return qatomic_read(ptr);
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t tlb_addr_write(const CPUTLBEntry *entry)
|
|
||||||
{
|
|
||||||
return tlb_read_idx(entry, MMU_DATA_STORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the TLB index corresponding to the mmu_idx + address pair. */
|
|
||||||
static inline uintptr_t tlb_index(CPUState *cpu, uintptr_t mmu_idx,
|
|
||||||
vaddr addr)
|
|
||||||
{
|
|
||||||
uintptr_t size_mask = cpu->neg.tlb.f[mmu_idx].mask >> CPU_TLB_ENTRY_BITS;
|
|
||||||
|
|
||||||
return (addr >> TARGET_PAGE_BITS) & size_mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the TLB entry corresponding to the mmu_idx + address pair. */
|
|
||||||
static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx,
|
|
||||||
vaddr addr)
|
|
||||||
{
|
|
||||||
return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !defined(CONFIG_USER_ONLY) */
|
|
||||||
|
|
||||||
#if TARGET_BIG_ENDIAN
|
#if TARGET_BIG_ENDIAN
|
||||||
# define cpu_lduw_data cpu_lduw_be_data
|
# define cpu_lduw_data cpu_lduw_be_data
|
||||||
# define cpu_ldsw_data cpu_ldsw_be_data
|
# define cpu_ldsw_data cpu_ldsw_be_data
|
||||||
|
|
Loading…
Reference in New Issue