aboutsummaryrefslogtreecommitdiff
path: root/include/exec/cpu-defs.h
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2019-03-22 13:52:09 -0700
committerRichard Henderson <richard.henderson@linaro.org>2019-06-10 07:03:34 -0700
commita40ec84ee2b02086e27fab78a152c20b09c723cf (patch)
treecf5efed68e90ae2240ecf558eddb0e18d890e275 /include/exec/cpu-defs.h
parent74433bf083b0766aba81534f92de13194f23ff3e (diff)
tcg: Create struct CPUTLB
Move all softmmu tlb data into this structure. Arrange the members so that we are able to place mask+table together and at a smaller absolute offset from ENV. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include/exec/cpu-defs.h')
-rw-r--r--include/exec/cpu-defs.h59
1 files changed, 34 insertions, 25 deletions
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 2694481769..b9ec261b01 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -78,6 +78,7 @@ typedef uint64_t target_ulong;
#endif
#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
+
/* use a fully associative victim tlb of 8 entries */
#define CPU_VTLB_SIZE 8
@@ -147,6 +148,10 @@ typedef struct CPUIOTLBEntry {
MemTxAttrs attrs;
} CPUIOTLBEntry;
+/*
+ * Data elements that are per MMU mode, minus the bits accessed by
+ * the TCG fast path.
+ */
typedef struct CPUTLBDesc {
/*
* Describe a region covering all of the large pages allocated
@@ -160,16 +165,31 @@ typedef struct CPUTLBDesc {
int64_t window_begin_ns;
/* maximum number of entries observed in the window */
size_t window_max_entries;
+ size_t n_used_entries;
/* The next index to use in the tlb victim table. */
size_t vindex;
- size_t n_used_entries;
+ /* The tlb victim table, in two parts. */
+ CPUTLBEntry vtable[CPU_VTLB_SIZE];
+ CPUIOTLBEntry viotlb[CPU_VTLB_SIZE];
+ /* The iotlb. */
+ CPUIOTLBEntry *iotlb;
} CPUTLBDesc;
/*
+ * Data elements that are per MMU mode, accessed by the fast path.
+ */
+typedef struct CPUTLBDescFast {
+ /* Contains (n_entries - 1) << CPU_TLB_ENTRY_BITS */
+ uintptr_t mask;
+ /* The array of tlb entries itself. */
+ CPUTLBEntry *table;
+} CPUTLBDescFast;
+
+/*
* Data elements that are shared between all MMU modes.
*/
typedef struct CPUTLBCommon {
- /* Serialize updates to tlb_table and tlb_v_table, and others as noted. */
+ /* Serialize updates to f.table and d.vtable, and others as noted. */
QemuSpin lock;
/*
* Within dirty, for each bit N, modifications have been made to
@@ -187,35 +207,24 @@ typedef struct CPUTLBCommon {
size_t elide_flush_count;
} CPUTLBCommon;
-# define CPU_TLB \
- /* tlb_mask[i] contains (n_entries - 1) << CPU_TLB_ENTRY_BITS */ \
- uintptr_t tlb_mask[NB_MMU_MODES]; \
- CPUTLBEntry *tlb_table[NB_MMU_MODES];
-# define CPU_IOTLB \
- CPUIOTLBEntry *iotlb[NB_MMU_MODES];
-
/*
+ * The entire softmmu tlb, for all MMU modes.
* The meaning of each of the MMU modes is defined in the target code.
- * Note that NB_MMU_MODES is not yet defined; we can only reference it
- * within preprocessor defines that will be expanded later.
*/
-#define CPU_COMMON_TLB \
- CPUTLBCommon tlb_c; \
- CPUTLBDesc tlb_d[NB_MMU_MODES]; \
- CPU_TLB \
- CPUTLBEntry tlb_v_table[NB_MMU_MODES][CPU_VTLB_SIZE]; \
- CPU_IOTLB \
- CPUIOTLBEntry iotlb_v[NB_MMU_MODES][CPU_VTLB_SIZE];
-
-#else
+typedef struct CPUTLB {
+ CPUTLBDescFast f[NB_MMU_MODES];
+ CPUTLBDesc d[NB_MMU_MODES];
+ CPUTLBCommon c;
+} CPUTLB;
-#define CPU_COMMON_TLB
+/* There are target-specific members named "tlb". This is temporary. */
+#define CPU_COMMON CPUTLB tlb_;
+#define env_tlb(ENV) (&(ENV)->tlb_)
-#endif
+#else
+#define CPU_COMMON /* Nothing */
-#define CPU_COMMON \
- /* soft mmu support */ \
- CPU_COMMON_TLB \
+#endif /* !CONFIG_USER_ONLY && CONFIG_TCG */
#endif