diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/exec/cpu-defs.h | 7 | ||||
-rw-r--r-- | include/exec/cpu_ldst.h | 22 |
2 files changed, 24 insertions, 5 deletions
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index e1c498e..a6e0cf1 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -111,8 +111,11 @@ typedef struct CPUTLBEntry { use the corresponding iotlb value. */ uintptr_t addend; }; - /* padding to get a power of two size */ - uint8_t dummy[1 << CPU_TLB_ENTRY_BITS]; + /* + * Padding to get a power of two size, as well as index + * access to addr_{read,write,code}. + */ + target_ulong addr_idx[(1 << CPU_TLB_ENTRY_BITS) / TARGET_LONG_SIZE]; }; } CPUTLBEntry; diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index c141f03..7c867c9 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -360,15 +360,31 @@ static inline void clear_helper_retaddr(void) /* Needed for TCG_OVERSIZED_GUEST */ #include "tcg/tcg.h" -static inline target_ulong tlb_addr_write(const CPUTLBEntry *entry) +static inline target_ulong 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 * TARGET_LONG_SIZE); + QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_write) != + MMU_DATA_STORE * TARGET_LONG_SIZE); + QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_code) != + MMU_INST_FETCH * TARGET_LONG_SIZE); + + const target_ulong *ptr = &entry->addr_idx[access_type]; #if TCG_OVERSIZED_GUEST - return entry->addr_write; + return *ptr; #else - return qatomic_read(&entry->addr_write); + /* ofs might correspond to .addr_write, so use qatomic_read */ + return qatomic_read(ptr); #endif } +static inline target_ulong 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(CPUArchState *env, uintptr_t mmu_idx, target_ulong addr) |