gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
smmu_v3_caches.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, 2018-2019 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __DEV_ARM_SMMU_V3_CACHES_HH__
39 #define __DEV_ARM_SMMU_V3_CACHES_HH__
40 
41 #include <stdint.h>
42 
43 #include <array>
44 #include <cstddef>
45 #include <string>
46 #include <vector>
47 
48 #include "base/random.hh"
49 #include "base/statistics.hh"
50 #include "base/types.hh"
51 
52 #define WALK_CACHE_LEVELS 4
53 
54 enum {
58 };
59 
61 {
62  protected:
64  size_t nextToReplace;
66  uint32_t useStamp;
67 
70 
73 
76 
78 
80 
81  static int decodePolicyName(const std::string &policy_name);
82 
83  public:
84  SMMUv3BaseCache(const std::string &policy_name, uint32_t seed);
85  virtual ~SMMUv3BaseCache() {}
86 
87  virtual void regStats(const std::string &name);
88 };
89 
90 class SMMUTLB : public SMMUv3BaseCache
91 {
92  public:
93  enum AllocPolicy {
97  };
98 
99  struct Entry
100  {
101  bool valid;
103  mutable uint32_t lastUsed;
104 
105  // TAGS
106  uint32_t sid;
107  uint32_t ssid;
110 
111  // EXTRA TAGS
112  uint16_t asid;
113  uint16_t vmid;
114 
115  // OUTPUTS
117  uint8_t permissions;
118  };
119 
120  SMMUTLB(unsigned numEntries, unsigned _associativity,
121  const std::string &policy);
122  SMMUTLB(const SMMUTLB& tlb) = delete;
123  virtual ~SMMUTLB() {}
124 
125  const Entry *lookup(uint32_t sid, uint32_t ssid, Addr va,
126  bool updStats=true);
127  const Entry *lookupAnyVA(uint32_t sid, uint32_t ssid,
128  bool updStats=true);
129  void store(const Entry &incoming, AllocPolicy alloc);
130 
131  void invalidateSSID(uint32_t sid, uint32_t ssid);
132  void invalidateSID(uint32_t sid);
133  void invalidateVA(Addr va, uint16_t asid, uint16_t vmid);
134  void invalidateVAA(Addr va, uint16_t vmid);
135  void invalidateASID(uint16_t asid, uint16_t vmid);
136  void invalidateVMID(uint16_t vmid);
137  void invalidateAll();
138 
139  private:
142 
144 
145  size_t pickSetIdx(uint32_t sid, uint32_t ssid) const;
146  size_t pickSetIdx(Addr va) const;
147  size_t pickEntryIdxToReplace(const Set &set, AllocPolicy alloc);
148 };
149 
151 {
152  public:
153  struct Entry
154  {
155  bool valid;
156  mutable uint32_t lastUsed;
157 
158  // TAGS
161  uint16_t asid;
162  uint16_t vmid;
163 
164  // OUTPUTS
166  uint8_t permissions;
167  };
168 
169  ARMArchTLB(unsigned numEntries, unsigned _associativity,
170  const std::string &policy);
171  virtual ~ARMArchTLB() {}
172 
173  const Entry *lookup(Addr va, uint16_t asid, uint16_t vmid,
174  bool updStats=true);
175 
176  void store(const Entry &incoming);
177 
178  void invalidateVA(Addr va, uint16_t asid, uint16_t vmid);
179  void invalidateVAA(Addr va, uint16_t vmid);
180  void invalidateASID(uint16_t asid, uint16_t vmid);
181  void invalidateVMID(uint16_t vmid);
182  void invalidateAll();
183 
184  private:
187 
189 
190  size_t pickSetIdx(Addr va, uint16_t asid, uint16_t vmid) const;
191  size_t pickEntryIdxToReplace(const Set &set);
192 };
193 
194 class IPACache : public SMMUv3BaseCache
195 {
196  public:
197  struct Entry
198  {
199  bool valid;
200  mutable uint32_t lastUsed;
201 
202  // TAGS
205  uint16_t vmid;
206 
207  // OUTPUTS
209  uint8_t permissions;
210  };
211 
212  IPACache(unsigned numEntries, unsigned _associativity,
213  const std::string &policy);
214  virtual ~IPACache() {}
215 
216  const Entry *lookup(Addr ipa, uint16_t vmid, bool updStats=true);
217  void store(const Entry &incoming);
218 
219  void invalidateIPA(Addr ipa, uint16_t vmid);
220  void invalidateIPAA(Addr ipa);
221  void invalidateVMID(uint16_t vmid);
222  void invalidateAll();
223 
224  private:
227 
229 
230  size_t pickSetIdx(Addr ipa, uint16_t vmid) const;
231  size_t pickEntryIdxToReplace(const Set &set);
232 };
233 
235 {
236  public:
237  struct Entry
238  {
239  bool valid;
240  mutable uint32_t lastUsed;
241 
242  // TAGS
243  uint32_t sid;
244  uint32_t ssid;
245 
246  // OUTPUTS
247  bool stage1_en;
248  bool stage2_en;
252  uint16_t asid;
253  uint16_t vmid;
254  uint8_t stage1_tg;
255  uint8_t stage2_tg;
256  uint8_t t0sz;
257  uint8_t s2t0sz;
258  };
259 
260  ConfigCache(unsigned numEntries, unsigned _associativity,
261  const std::string &policy);
262  virtual ~ConfigCache() {}
263 
264  const Entry *lookup(uint32_t sid, uint32_t ssid, bool updStats=true);
265  void store(const Entry &incoming);
266 
267  void invalidateSSID(uint32_t sid, uint32_t ssid);
268  void invalidateSID(uint32_t sid);
269  void invalidateAll();
270 
271  private:
274 
276 
277  size_t pickSetIdx(uint32_t sid, uint32_t ssid) const;
278  size_t pickEntryIdxToReplace(const Set &set);
279 };
280 
282 {
283  public:
284  struct Entry
285  {
286  bool valid;
287  mutable uint32_t lastUsed;
288 
289  // TAGS
292  uint16_t asid;
293  uint16_t vmid;
294  unsigned stage;
295  unsigned level;
296 
297  // OUTPUTS
298  bool leaf;
300  uint8_t permissions;
301  };
302 
303  WalkCache(const std::array<unsigned, 2*WALK_CACHE_LEVELS> &_sizes,
304  unsigned _associativity, const std::string &policy);
305  virtual ~WalkCache() {}
306 
307  const Entry *lookup(Addr va, Addr vaMask, uint16_t asid, uint16_t vmid,
308  unsigned stage, unsigned level, bool updStats=true);
309  void store(const Entry &incoming);
310 
311  void invalidateVA(Addr va, uint16_t asid, uint16_t vmid,
312  const bool leaf_only);
313  void invalidateVAA(Addr va, uint16_t vmid, const bool leaf_only);
314  void invalidateASID(uint16_t asid, uint16_t vmid);
315  void invalidateVMID(uint16_t vmid);
316  void invalidateAll();
317 
318  void regStats(const std::string &name) override;
319 
320  protected:
321  unsigned int lookupsByStageLevel[2][WALK_CACHE_LEVELS];
322  Stats::Formula averageLookupsByStageLevel[2][WALK_CACHE_LEVELS];
323  Stats::Scalar totalLookupsByStageLevel[2][WALK_CACHE_LEVELS];
324 
325  unsigned int missesByStageLevel[2][WALK_CACHE_LEVELS];
326  Stats::Formula averageMissesByStageLevel[2][WALK_CACHE_LEVELS];
327  Stats::Scalar totalMissesByStageLevel[2][WALK_CACHE_LEVELS];
328 
329  unsigned int updatesByStageLevel[2][WALK_CACHE_LEVELS];
330  Stats::Formula averageUpdatesByStageLevel[2][WALK_CACHE_LEVELS];
331  Stats::Scalar totalUpdatesByStageLevel[2][WALK_CACHE_LEVELS];
332 
333  Stats::Formula averageHitRateByStageLevel[2][WALK_CACHE_LEVELS];
334 
335  Stats::Scalar insertionsByStageLevel[2][WALK_CACHE_LEVELS];
336 
337  private:
340 
342  std::array<unsigned, 2*WALK_CACHE_LEVELS> sizes;
343  std::array<unsigned, 2*WALK_CACHE_LEVELS> offsets;
344 
345  size_t pickSetIdx(Addr va, Addr vaMask,
346  unsigned stage, unsigned level) const;
347 
348  size_t pickEntryIdxToReplace(const Set &set,
349  unsigned stage, unsigned level);
350 };
351 
352 #endif /* __DEV_ARM_SMMU_V3_CACHES_HH__ */
Stats::Scalar insertions
std::vector< Set > sets
virtual ~ConfigCache()
const std::string & name()
Definition: trace.cc:50
std::array< unsigned, 2 *WALK_CACHE_LEVELS > offsets
std::vector< Entry > Set
virtual ~SMMUTLB()
std::vector< Entry > Set
virtual ~IPACache()
Declaration of Statistics objects.
std::vector< Set > sets
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
size_t associativity
Definition: random.hh:58
std::array< unsigned, 2 *WALK_CACHE_LEVELS > sizes
std::vector< Set > sets
size_t associativity
Stats::Scalar totalUpdates
Bitfield< 59, 56 > tlb
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
#define WALK_CACHE_LEVELS
Bitfield< 8 > va
std::vector< Entry > Set
Bitfield< 20 > level
Definition: intmessage.hh:47
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3009
size_t associativity
Stats::Formula averageHitRate
Stats::Formula averageLookups
static int decodePolicyName(const std::string &policy_name)
std::vector< Set > sets
Stats::Formula averageMisses
SMMUv3BaseCache(const std::string &policy_name, uint32_t seed)
Stats::Scalar totalLookups
virtual ~ARMArchTLB()
std::vector< Set > sets
virtual ~SMMUv3BaseCache()
std::vector< Entry > Set
std::vector< Entry > Set
size_t associativity
Stats::Formula averageUpdates
virtual void regStats(const std::string &name)
size_t associativity
virtual ~WalkCache()
Stats::Scalar totalMisses

Generated on Mon Jun 8 2020 15:45:10 for gem5 by doxygen 1.8.13