gem5  v20.1.0.0
smmu_v3_transl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, 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_TRANSL_HH__
39 #define __DEV_ARM_SMMU_V3_TRANSL_HH__
40 
41 #include "base/compiler.hh"
43 #include "dev/arm/smmu_v3_proc.hh"
44 #include "dev/arm/smmu_v3_ptops.hh"
45 #include "mem/packet.hh"
46 
48 {
50  unsigned size;
51  uint32_t sid; // streamId
52  uint32_t ssid; // substreamId
53  bool isWrite;
54  bool isPrefetch;
56 
58 
59  static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats = false);
60  static SMMUTranslRequest prefetch(Addr addr, uint32_t sid, uint32_t ssid);
61 };
62 
64 {
65  private:
67  {
71  uint16_t asid;
72  uint16_t vmid;
75  uint8_t t0sz;
76  uint8_t s2t0sz;
77  };
78 
79  enum FaultType
80  {
82  FAULT_TRANSLATION, // F_TRANSLATION
83  FAULT_PERMISSION, // F_PERMISSION
84  };
85 
86  struct TranslResult
87  {
91  bool writable;
92  };
93 
95 
98 
101 
102  virtual void main(Yield &yield);
103 
104  TranslResult bypass(Addr addr) const;
106 
107  bool microTLBLookup(Yield &yield, TranslResult &tr);
108  bool ifcTLBLookup(Yield &yield, TranslResult &tr, bool &wasPrefetched);
109  bool smmuTLBLookup(Yield &yield, TranslResult &tr);
110 
111  void microTLBUpdate(Yield &yield, const TranslResult &tr);
112  void ifcTLBUpdate(Yield &yield, const TranslResult &tr);
113  void smmuTLBUpdate(Yield &yield, const TranslResult &tr);
114 
115  bool configCacheLookup(Yield &yield, TranslContext &tc);
116  void configCacheUpdate(Yield &yield, const TranslContext &tc);
117  bool findConfig(Yield &yield, TranslContext &tc, TranslResult &tr);
118 
119  void walkCacheLookup(Yield &yield,
120  const WalkCache::Entry *&walkEntry,
121  Addr addr, uint16_t asid, uint16_t vmid,
122  unsigned stage, unsigned level);
123 
124  void walkCacheUpdate(Yield &yield, Addr va, Addr vaMask, Addr pa,
125  unsigned stage, unsigned level,
126  bool leaf, uint8_t permissions);
127 
129  const PageTableOps *pt_ops,
130  unsigned level, Addr walkPtr);
131 
132  TranslResult walkStage2(Yield &yield, Addr addr, bool final_tr,
133  const PageTableOps *pt_ops,
134  unsigned level, Addr walkPtr);
135 
137  TranslResult translateStage2(Yield &yield, Addr addr, bool final_tr);
138 
140  const TranslResult &s2tr) const;
141 
147  bool hazard4kCheck();
148  void hazard4kRegister();
149  void hazard4kHold(Yield &yield);
150  void hazard4kRelease();
151 
156  void hazardIdRegister();
157  void hazardIdHold(Yield &yield);
158  void hazardIdRelease();
159 
160  void issuePrefetch(Addr addr);
161 
162  void completeTransaction(Yield &yield, const TranslResult &tr);
163  void completePrefetch(Yield &yield);
164 
165  void sendEvent(Yield &yield, const SMMUEvent &ev);
166 
167  void doReadSTE(Yield &yield, StreamTableEntry &ste, uint32_t sid);
168  void doReadCD(Yield &yield, ContextDescriptor &cd,
169  const StreamTableEntry &ste, uint32_t sid, uint32_t ssid);
170  void doReadConfig(Yield &yield, Addr addr, void *ptr, size_t size,
171  uint32_t sid, uint32_t ssid);
172  void doReadPTE(Yield &yield, Addr va, Addr addr, void *ptr,
173  unsigned stage, unsigned level);
174 
175  public:
176  SMMUTranslationProcess(const std::string &name, SMMUv3 &_smmu,
177  SMMUv3DeviceInterface &_ifc);
178 
179  virtual ~SMMUTranslationProcess();
180 
181  void beginTransaction(const SMMUTranslRequest &req);
182  void resumeTransaction();
183 };
184 
185 #endif /* __DEV_ARM_SMMU_V3_TRANSL_HH__ */
SMMUTranslationProcess::TranslContext::s2t0sz
uint8_t s2t0sz
Definition: smmu_v3_transl.hh:76
SMMUTranslationProcess::hazard4kRegister
void hazard4kRegister()
Definition: smmu_v3_transl.cc:1060
SMMUTranslationProcess::TranslContext::stage1Enable
bool stage1Enable
Definition: smmu_v3_transl.hh:68
SMMUTranslationProcess::doReadCD
void doReadCD(Yield &yield, ContextDescriptor &cd, const StreamTableEntry &ste, uint32_t sid, uint32_t ssid)
Definition: smmu_v3_transl.cc:1396
SMMUTranslationProcess::TranslContext::asid
uint16_t asid
Definition: smmu_v3_transl.hh:71
SMMUTranslRequest::ssid
uint32_t ssid
Definition: smmu_v3_transl.hh:52
SMMUTranslationProcess::TranslContext::vmid
uint16_t vmid
Definition: smmu_v3_transl.hh:72
SMMUTranslationProcess::completeTransaction
void completeTransaction(Yield &yield, const TranslResult &tr)
Definition: smmu_v3_transl.cc:1224
m5::Coroutine::CallerType
CallerType: A reference to an object of this class will be passed to the coroutine task.
Definition: coroutine.hh:83
SMMUProcess
Definition: smmu_v3_proc.hh:93
SMMUTranslationProcess::FAULT_NONE
@ FAULT_NONE
Definition: smmu_v3_transl.hh:81
SMMUTranslRequest::prefetch
static SMMUTranslRequest prefetch(Addr addr, uint32_t sid, uint32_t ssid)
Definition: smmu_v3_transl.cc:64
SMMUTranslationProcess::TranslContext::httb
Addr httb
Definition: smmu_v3_transl.hh:70
SMMUTranslationProcess::faultTick
Tick M5_CLASS_VAR_USED faultTick
Definition: smmu_v3_transl.hh:100
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
SMMUEvent
Definition: smmu_v3_defs.hh:384
SMMUTranslationProcess::issuePrefetch
void issuePrefetch(Addr addr)
Definition: smmu_v3_transl.cc:1206
SMMUTranslationProcess::ifcTLBLookup
bool ifcTLBLookup(Yield &yield, TranslResult &tr, bool &wasPrefetched)
Definition: smmu_v3_transl.cc:342
SMMUTranslationProcess::walkStage1And2
TranslResult walkStage1And2(Yield &yield, Addr addr, const PageTableOps *pt_ops, unsigned level, Addr walkPtr)
Definition: smmu_v3_transl.cc:730
SMMUTranslationProcess::walkStage2
TranslResult walkStage2(Yield &yield, Addr addr, bool final_tr, const PageTableOps *pt_ops, unsigned level, Addr walkPtr)
Definition: smmu_v3_transl.cc:814
ContextDescriptor
Definition: smmu_v3_defs.hh:251
SMMUTranslationProcess::TranslContext::stage2Enable
bool stage2Enable
Definition: smmu_v3_transl.hh:69
SMMUTranslRequest::size
unsigned size
Definition: smmu_v3_transl.hh:50
WalkCache::Entry
Definition: smmu_v3_caches.hh:284
SMMUTranslationProcess::TranslContext::ttb0
Addr ttb0
Definition: smmu_v3_transl.hh:70
SMMUTranslationProcess::FaultType
FaultType
Definition: smmu_v3_transl.hh:79
SMMUTranslationProcess::hazardIdRelease
void hazardIdRelease()
Definition: smmu_v3_transl.cc:1181
SMMUTranslationProcess::doReadPTE
void doReadPTE(Yield &yield, Addr va, Addr addr, void *ptr, unsigned stage, unsigned level)
Definition: smmu_v3_transl.cc:1468
SMMUTranslationProcess::microTLBUpdate
void microTLBUpdate(Yield &yield, const TranslResult &tr)
Definition: smmu_v3_transl.cc:408
SMMUTranslRequest::addr
Addr addr
Definition: smmu_v3_transl.hh:49
SMMUTranslationProcess::configCacheUpdate
void configCacheUpdate(Yield &yield, const TranslContext &tc)
Definition: smmu_v3_transl.cc:546
packet.hh
SMMUTranslationProcess::configCacheLookup
bool configCacheLookup(Yield &yield, TranslContext &tc)
Definition: smmu_v3_transl.cc:506
SMMUv3DeviceInterface
Definition: smmu_v3_deviceifc.hh:55
SMMUTranslationProcess::request
SMMUTranslRequest request
Definition: smmu_v3_transl.hh:96
M5_CLASS_VAR_USED
#define M5_CLASS_VAR_USED
Definition: compiler.hh:64
SMMUTranslationProcess::ifc
SMMUv3DeviceInterface & ifc
Definition: smmu_v3_transl.hh:94
SMMUTranslationProcess::~SMMUTranslationProcess
virtual ~SMMUTranslationProcess()
Definition: smmu_v3_transl.cc:93
SMMUTranslationProcess::translateStage2
TranslResult translateStage2(Yield &yield, Addr addr, bool final_tr)
Definition: smmu_v3_transl.cc:936
SMMUTranslRequest::sid
uint32_t sid
Definition: smmu_v3_transl.hh:51
SMMUTranslationProcess::context
TranslContext context
Definition: smmu_v3_transl.hh:97
SMMUTranslationProcess::hazard4kCheck
bool hazard4kCheck()
Used to force ordering on transactions with same (SID, SSID, 4k page) to avoid multiple identical pag...
Definition: smmu_v3_transl.cc:1043
SMMUTranslRequest::fromPacket
static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats=false)
Definition: smmu_v3_transl.cc:47
StreamTableEntry
Definition: smmu_v3_defs.hh:185
SMMUTranslationProcess::ifcTLBUpdate
void ifcTLBUpdate(Yield &yield, const TranslResult &tr)
Definition: smmu_v3_transl.cc:440
SMMUTranslationProcess::findConfig
bool findConfig(Yield &yield, TranslContext &tc, TranslResult &tr)
Definition: smmu_v3_transl.cc:578
SMMUTranslRequest::isAtsRequest
bool isAtsRequest
Definition: smmu_v3_transl.hh:55
SMMUTranslationProcess::walkCacheLookup
void walkCacheLookup(Yield &yield, const WalkCache::Entry *&walkEntry, Addr addr, uint16_t asid, uint16_t vmid, unsigned stage, unsigned level)
Definition: smmu_v3_transl.cc:648
SMMUTranslationProcess::TranslResult
Definition: smmu_v3_transl.hh:86
SMMUTranslationProcess::completePrefetch
void completePrefetch(Yield &yield)
Definition: smmu_v3_transl.cc:1286
smmu_v3_ptops.hh
SMMUTranslationProcess::FAULT_TRANSLATION
@ FAULT_TRANSLATION
Definition: smmu_v3_transl.hh:82
SMMUTranslationProcess::hazard4kHold
void hazard4kHold(Yield &yield)
Definition: smmu_v3_transl.cc:1069
SMMUTranslationProcess::main
virtual void main(Yield &yield)
Definition: smmu_v3_transl.cc:133
SMMUTranslationProcess::smmuTLBUpdate
void smmuTLBUpdate(Yield &yield, const TranslResult &tr)
Definition: smmu_v3_transl.cc:477
SMMUTranslationProcess::TranslContext::ttb1
Addr ttb1
Definition: smmu_v3_transl.hh:70
SMMUTranslationProcess::sendEvent
void sendEvent(Yield &yield, const SMMUEvent &ev)
Definition: smmu_v3_transl.cc:1299
compiler.hh
SMMUTranslationProcess::resumeTransaction
void resumeTransaction()
Definition: smmu_v3_transl.cc:115
SMMUTranslationProcess::doReadSTE
void doReadSTE(Yield &yield, StreamTableEntry &ste, uint32_t sid)
Definition: smmu_v3_transl.cc:1329
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SMMUTranslationProcess::FAULT_PERMISSION
@ FAULT_PERMISSION
Definition: smmu_v3_transl.hh:83
smmu_v3_deviceifc.hh
SMMUTranslRequest::isPrefetch
bool isPrefetch
Definition: smmu_v3_transl.hh:54
ArmISA::asid
asid
Definition: miscregs_types.hh:611
SMMUTranslationProcess::TranslContext
Definition: smmu_v3_transl.hh:66
smmu_v3_proc.hh
SMMUTranslationProcess::TranslResult::fault
FaultType fault
Definition: smmu_v3_transl.hh:88
X86ISA::level
Bitfield< 20 > level
Definition: intmessage.hh:47
SMMUTranslationProcess::hazard4kRelease
void hazard4kRelease()
Definition: smmu_v3_transl.cc:1107
SMMUTranslationProcess::TranslResult::addrMask
Addr addrMask
Definition: smmu_v3_transl.hh:90
SMMUTranslationProcess::bypass
TranslResult bypass(Addr addr) const
Definition: smmu_v3_transl.cc:237
SMMUTranslRequest
Definition: smmu_v3_transl.hh:47
SMMUTranslationProcess::doReadConfig
void doReadConfig(Yield &yield, Addr addr, void *ptr, size_t size, uint32_t sid, uint32_t ssid)
Definition: smmu_v3_transl.cc:1460
SMMUTranslationProcess::hazardIdHold
void hazardIdHold(Yield &yield)
Definition: smmu_v3_transl.cc:1142
SMMUTranslationProcess::recvTick
Tick recvTick
Definition: smmu_v3_transl.hh:99
SMMUTranslationProcess::smmuTLBLookup
bool smmuTLBLookup(Yield &yield, TranslResult &tr)
Definition: smmu_v3_transl.cc:377
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
SMMUTranslationProcess
Definition: smmu_v3_transl.hh:63
addr
ip6_addr_t addr
Definition: inet.hh:423
SMMUTranslationProcess::TranslContext::t0sz
uint8_t t0sz
Definition: smmu_v3_transl.hh:75
SMMUTranslationProcess::translateStage1And2
TranslResult translateStage1And2(Yield &yield, Addr addr)
Definition: smmu_v3_transl.cc:880
SMMUTranslationProcess::TranslContext::stage1TranslGranule
uint8_t stage1TranslGranule
Definition: smmu_v3_transl.hh:73
SMMUTranslationProcess::hazardIdRegister
void hazardIdRegister()
Used to force ordering on transactions with the same orderId.
Definition: smmu_v3_transl.cc:1127
SMMUTranslationProcess::TranslContext::stage2TranslGranule
uint8_t stage2TranslGranule
Definition: smmu_v3_transl.hh:74
SMMUTranslationProcess::microTLBLookup
bool microTLBLookup(Yield &yield, TranslResult &tr)
Definition: smmu_v3_transl.cc:311
SMMUTranslRequest::pkt
PacketPtr pkt
Definition: smmu_v3_transl.hh:57
SMMUv3
Definition: smmu_v3.hh:81
SMMUTranslationProcess::walkCacheUpdate
void walkCacheUpdate(Yield &yield, Addr va, Addr vaMask, Addr pa, unsigned stage, unsigned level, bool leaf, uint8_t permissions)
Definition: smmu_v3_transl.cc:689
PageTableOps
Definition: smmu_v3_ptops.hh:45
SMMUTranslationProcess::beginTransaction
void beginTransaction(const SMMUTranslRequest &req)
Definition: smmu_v3_transl.cc:107
ArmISA::pa
Bitfield< 39, 12 > pa
Definition: miscregs_types.hh:650
SMMUTranslRequest::isWrite
bool isWrite
Definition: smmu_v3_transl.hh:53
ArmISA::cd
Bitfield< 32 > cd
Definition: miscregs_types.hh:248
SMMUTranslationProcess::smmuTranslation
TranslResult smmuTranslation(Yield &yield)
Definition: smmu_v3_transl.cc:249
SMMUTranslationProcess::SMMUTranslationProcess
SMMUTranslationProcess(const std::string &name, SMMUv3 &_smmu, SMMUv3DeviceInterface &_ifc)
Definition: smmu_v3_transl.cc:79
SMMUTranslationProcess::combineTranslations
TranslResult combineTranslations(const TranslResult &s1tr, const TranslResult &s2tr) const
Definition: smmu_v3_transl.cc:1025
SMMUProcess::name
const std::string name() const
Definition: smmu_v3_proc.hh:131
ArmISA::va
Bitfield< 8 > va
Definition: miscregs_types.hh:272
SMMUTranslationProcess::TranslResult::addr
Addr addr
Definition: smmu_v3_transl.hh:89
SMMUTranslationProcess::TranslResult::writable
bool writable
Definition: smmu_v3_transl.hh:91

Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17