gem5  v19.0.0.0
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  * Authors: Stan Czerniawski
38  */
39 
40 #ifndef __DEV_ARM_SMMU_V3_CACHES_HH__
41 #define __DEV_ARM_SMMU_V3_CACHES_HH__
42 
43 #include <stdint.h>
44 
45 #include <array>
46 #include <cstddef>
47 #include <string>
48 #include <vector>
49 
50 #include "base/random.hh"
51 #include "base/statistics.hh"
52 #include "base/types.hh"
53 
54 #define WALK_CACHE_LEVELS 4
55 
56 enum {
60 };
61 
63 {
64  protected:
66  size_t nextToReplace;
68  uint32_t useStamp;
69 
72 
75 
78 
80 
82 
83  static int decodePolicyName(const std::string &policy_name);
84 
85  public:
86  SMMUv3BaseCache(const std::string &policy_name, uint32_t seed);
87  virtual ~SMMUv3BaseCache() {}
88 
89  virtual void regStats(const std::string &name);
90 };
91 
92 class SMMUTLB : public SMMUv3BaseCache
93 {
94  public:
95  enum AllocPolicy {
99  };
100 
101  struct Entry
102  {
103  bool valid;
105  mutable uint32_t lastUsed;
106 
107  // TAGS
108  uint32_t sid;
109  uint32_t ssid;
112 
113  // EXTRA TAGS
114  uint16_t asid;
115  uint16_t vmid;
116 
117  // OUTPUTS
119  uint8_t permissions;
120  };
121 
122  SMMUTLB(unsigned numEntries, unsigned _associativity,
123  const std::string &policy);
124  SMMUTLB(const SMMUTLB& tlb) = delete;
125  virtual ~SMMUTLB() {}
126 
127  const Entry *lookup(uint32_t sid, uint32_t ssid, Addr va,
128  bool updStats=true);
129  const Entry *lookupAnyVA(uint32_t sid, uint32_t ssid,
130  bool updStats=true);
131  void store(const Entry &incoming, AllocPolicy alloc);
132 
133  void invalidateSSID(uint32_t sid, uint32_t ssid);
134  void invalidateSID(uint32_t sid);
135  void invalidateVA(Addr va, uint16_t asid, uint16_t vmid);
136  void invalidateVAA(Addr va, uint16_t vmid);
137  void invalidateASID(uint16_t asid, uint16_t vmid);
138  void invalidateVMID(uint16_t vmid);
139  void invalidateAll();
140 
141  private:
144 
146 
147  size_t pickSetIdx(uint32_t sid, uint32_t ssid) const;
148  size_t pickSetIdx(Addr va) const;
149  size_t pickEntryIdxToReplace(const Set &set, AllocPolicy alloc);
150 };
151 
153 {
154  public:
155  struct Entry
156  {
157  bool valid;
158  mutable uint32_t lastUsed;
159 
160  // TAGS
163  uint16_t asid;
164  uint16_t vmid;
165 
166  // OUTPUTS
168  uint8_t permissions;
169  };
170 
171  ARMArchTLB(unsigned numEntries, unsigned _associativity,
172  const std::string &policy);
173  virtual ~ARMArchTLB() {}
174 
175  const Entry *lookup(Addr va, uint16_t asid, uint16_t vmid,
176  bool updStats=true);
177 
178  void store(const Entry &incoming);
179 
180  void invalidateVA(Addr va, uint16_t asid, uint16_t vmid);
181  void invalidateVAA(Addr va, uint16_t vmid);
182  void invalidateASID(uint16_t asid, uint16_t vmid);
183  void invalidateVMID(uint16_t vmid);
184  void invalidateAll();
185 
186  private:
189 
191 
192  size_t pickSetIdx(Addr va, uint16_t asid, uint16_t vmid) const;
193  size_t pickEntryIdxToReplace(const Set &set);
194 };
195 
196 class IPACache : public SMMUv3BaseCache
197 {
198  public:
199  struct Entry
200  {
201  bool valid;
202  mutable uint32_t lastUsed;
203 
204  // TAGS
207  uint16_t vmid;
208 
209  // OUTPUTS
211  uint8_t permissions;
212  };
213 
214  IPACache(unsigned numEntries, unsigned _associativity,
215  const std::string &policy);
216  virtual ~IPACache() {}
217 
218  const Entry *lookup(Addr ipa, uint16_t vmid, bool updStats=true);
219  void store(const Entry &incoming);
220 
221  void invalidateIPA(Addr ipa, uint16_t vmid);
222  void invalidateIPAA(Addr ipa);
223  void invalidateVMID(uint16_t vmid);
224  void invalidateAll();
225 
226  private:
229 
231 
232  size_t pickSetIdx(Addr ipa, uint16_t vmid) const;
233  size_t pickEntryIdxToReplace(const Set &set);
234 };
235 
237 {
238  public:
239  struct Entry
240  {
241  bool valid;
242  mutable uint32_t lastUsed;
243 
244  // TAGS
245  uint32_t sid;
246  uint32_t ssid;
247 
248  // OUTPUTS
249  bool stage1_en;
250  bool stage2_en;
254  uint16_t asid;
255  uint16_t vmid;
256  uint8_t stage1_tg;
257  uint8_t stage2_tg;
258  uint8_t t0sz;
259  uint8_t s2t0sz;
260  };
261 
262  ConfigCache(unsigned numEntries, unsigned _associativity,
263  const std::string &policy);
264  virtual ~ConfigCache() {}
265 
266  const Entry *lookup(uint32_t sid, uint32_t ssid, bool updStats=true);
267  void store(const Entry &incoming);
268 
269  void invalidateSSID(uint32_t sid, uint32_t ssid);
270  void invalidateSID(uint32_t sid);
271  void invalidateAll();
272 
273  private:
276 
278 
279  size_t pickSetIdx(uint32_t sid, uint32_t ssid) const;
280  size_t pickEntryIdxToReplace(const Set &set);
281 };
282 
284 {
285  public:
286  struct Entry
287  {
288  bool valid;
289  mutable uint32_t lastUsed;
290 
291  // TAGS
294  uint16_t asid;
295  uint16_t vmid;
296  unsigned stage;
297  unsigned level;
298 
299  // OUTPUTS
300  bool leaf;
302  uint8_t permissions;
303  };
304 
305  WalkCache(const std::array<unsigned, 2*WALK_CACHE_LEVELS> &_sizes,
306  unsigned _associativity, const std::string &policy);
307  virtual ~WalkCache() {}
308 
309  const Entry *lookup(Addr va, Addr vaMask, uint16_t asid, uint16_t vmid,
310  unsigned stage, unsigned level, bool updStats=true);
311  void store(const Entry &incoming);
312 
313  void invalidateVA(Addr va, uint16_t asid, uint16_t vmid,
314  const bool leaf_only);
315  void invalidateVAA(Addr va, uint16_t vmid, const bool leaf_only);
316  void invalidateASID(uint16_t asid, uint16_t vmid);
317  void invalidateVMID(uint16_t vmid);
318  void invalidateAll();
319 
320  void regStats(const std::string &name) override;
321 
322  protected:
323  unsigned int lookupsByStageLevel[2][WALK_CACHE_LEVELS];
324  Stats::Formula averageLookupsByStageLevel[2][WALK_CACHE_LEVELS];
325  Stats::Scalar totalLookupsByStageLevel[2][WALK_CACHE_LEVELS];
326 
327  unsigned int missesByStageLevel[2][WALK_CACHE_LEVELS];
328  Stats::Formula averageMissesByStageLevel[2][WALK_CACHE_LEVELS];
329  Stats::Scalar totalMissesByStageLevel[2][WALK_CACHE_LEVELS];
330 
331  unsigned int updatesByStageLevel[2][WALK_CACHE_LEVELS];
332  Stats::Formula averageUpdatesByStageLevel[2][WALK_CACHE_LEVELS];
333  Stats::Scalar totalUpdatesByStageLevel[2][WALK_CACHE_LEVELS];
334 
335  Stats::Formula averageHitRateByStageLevel[2][WALK_CACHE_LEVELS];
336 
337  Stats::Scalar insertionsByStageLevel[2][WALK_CACHE_LEVELS];
338 
339  private:
342 
344  std::array<unsigned, 2*WALK_CACHE_LEVELS> sizes;
345  std::array<unsigned, 2*WALK_CACHE_LEVELS> offsets;
346 
347  size_t pickSetIdx(Addr va, Addr vaMask,
348  unsigned stage, unsigned level) const;
349 
350  size_t pickEntryIdxToReplace(const Set &set,
351  unsigned stage, unsigned level);
352 };
353 
354 #endif /* __DEV_ARM_SMMU_V3_CACHES_HH__ */
Stats::Scalar insertions
std::vector< Set > sets
virtual ~ConfigCache()
const std::string & name()
Definition: trace.cc:54
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:2508
size_t associativity
Definition: random.hh:62
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:142
#define WALK_CACHE_LEVELS
Bitfield< 8 > va
std::vector< Entry > Set
Bitfield< 20 > level
Definition: intmessage.hh:49
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
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 Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13