gem5 v24.0.0.0
Loading...
Searching...
No Matches
smmu_v3_transl.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013, 2018-2019, 2024 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"
44#include "mem/packet.hh"
45
46namespace gem5
47{
48
49namespace ArmISA
50{
51struct PageTableOps;
52}
53
55{
57 unsigned size;
58 uint32_t sid; // streamId
59 uint32_t ssid; // substreamId
60 bool isWrite;
63
65
66 static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats = false);
67 static SMMUTranslRequest prefetch(Addr addr, uint32_t sid, uint32_t ssid);
68};
69
71{
72 private:
74 {
78 uint16_t asid;
79 uint16_t vmid;
82 uint8_t t0sz;
83 uint8_t s2t0sz;
84 };
85
86 enum FaultType : uint8_t
87 {
89 FAULT_UUT = 0x1, // F_UUT = Unsupported Upstream Transaction
90 FAULT_BAD_STREAMID = 0x2, // C_BAD_STREAMID = Transaction streamID out of range
91 FAULT_STE_FETCH = 0x3, // F_STE_FETCH = Fetch of STE caused external abort
92 FAULT_BAD_STE = 0x4, // C_BAD_STE = Invalid STE
93 FAULT_BAD_ATS_TREQ = 0x5, // F_BAD_ATS_TREQ
94 FAULT_STREAM_DISABLED = 0x6, // F_STREAM_DISABLED = Non-substream trans disabled
95 FAULT_TRANSL_FORBIDDEN = 0x7, // F_TRANSL_FORBIDDEN = SMMU bypass not allowed
96 FAULT_BAD_SUBSTREAMID = 0x8, // F_BAD_SUBSTREAMID = Bad substreamID
97 FAULT_CD_FETCH = 0x9, // F_CD_FETCH = Fetch of CD caused external abort
98 FAULT_BAD_CD = 0xa, // C_BAD_CD = Invalid CD
99 FAULT_WALK_EABT = 0xb, // F_WALK_EABT = Table walk/update caused external abort
100 FAULT_TRANSLATION = 0x10, // F_TRANSLATION = Translation Fault
101 FAULT_ADDR_SIZE = 0x11, // F_ADDR_SIZE = Address Size fault
102 FAULT_ACCESS = 0x12, // F_ACCESS = Access flag fault
103 FAULT_PERMISSION = 0x13, // F_PERMISSION = Permission fault
104 FAULT_TLB_CONFLICT = 0x20, // F_TLB_CONFLICT = TLB conflict
105 FAULT_CFG_CONFLICT = 0x21, // F_CFG_CONFLICT = Config cache conflict
106 FAULT_PAGE_REQUEST = 0x24, // E_PAGE_REQUEST
107 FAULT_VMS_FETCH = 0x25, // F_VMS_FETCH
108 };
109
110 /* The class of the operation that caused the fault */
112 {
113 CD = 0x0, // CD fetch
114 TT = 0x1, // Stage1 translation table fetch
115 IN = 0x2, // Input address caused fault
116 RESERVED = 0x3
117 };
118
119 struct Fault
120 {
121 explicit Fault(FaultType _type,
123 bool _stage2=false, Addr _ipa=0)
124 : type(_type), clss(_clss), stage2(_stage2), ipa(_ipa)
125 {}
126
127 Fault(const Fault &rhs) = default;
128 Fault& operator=(const Fault &rhs) = default;
129
130 bool isFaulting() const { return type != FAULT_NONE; }
131
134 bool stage2;
136 };
137
139 {
142 addr(0), addrMask(0), writable(false)
143 {}
144
145 TranslResult(const TranslResult&) = default;
146 TranslResult& operator=(const TranslResult &rhs) = default;
147
148 bool isFaulting() const { return fault.isFaulting(); }
149
154 };
155
157
160
163
164 virtual void main(Yield &yield);
165
168
169 bool microTLBLookup(Yield &yield, TranslResult &tr);
170 bool ifcTLBLookup(Yield &yield, TranslResult &tr, bool &wasPrefetched);
171 bool smmuTLBLookup(Yield &yield, TranslResult &tr);
172
173 void microTLBUpdate(Yield &yield, const TranslResult &tr);
174 void ifcTLBUpdate(Yield &yield, const TranslResult &tr);
175 void smmuTLBUpdate(Yield &yield, const TranslResult &tr);
176
177 bool configCacheLookup(Yield &yield, TranslContext &tc);
178 void configCacheUpdate(Yield &yield, const TranslContext &tc);
179 bool findConfig(Yield &yield, TranslContext &tc, TranslResult &tr);
180
181 void walkCacheLookup(Yield &yield,
182 const WalkCache::Entry *&walkEntry,
183 Addr addr, uint16_t asid, uint16_t vmid,
184 unsigned stage, unsigned level);
185
186 void walkCacheUpdate(Yield &yield, Addr va, Addr vaMask, Addr pa,
187 unsigned stage, unsigned level,
188 bool leaf, uint8_t permissions);
189
191 const ArmISA::PageTableOps *pt_ops,
192 unsigned level, Addr walkPtr);
193
194 TranslResult walkStage2(Yield &yield, Addr addr, bool final_tr,
195 const ArmISA::PageTableOps *pt_ops,
196 unsigned level, Addr walkPtr);
197
199 TranslResult translateStage2(Yield &yield, Addr addr, bool final_tr);
200
202 const TranslResult &s2tr) const;
203
209 bool hazard4kCheck();
210 void hazard4kRegister();
211 void hazard4kHold(Yield &yield);
212 void hazard4kRelease();
213
218 void hazardIdRegister();
219 void hazardIdHold(Yield &yield);
220 void hazardIdRelease();
221
222 void issuePrefetch(Addr addr);
223
224 void abortTransaction(Yield &yield, const TranslResult &tr);
225 void completeTransaction(Yield &yield, const TranslResult &tr);
226 void completePrefetch(Yield &yield);
227
229 void sendEvent(Yield &yield, const SMMUEvent &ev);
230 void sendEventInterrupt(Yield &yield);
231
232 void doReadSTE(Yield &yield, StreamTableEntry &ste, uint32_t sid);
234 const StreamTableEntry &ste, uint32_t sid, uint32_t ssid);
235 void doReadConfig(Yield &yield, Addr addr, void *ptr, size_t size,
236 uint32_t sid, uint32_t ssid);
237 void doReadPTE(Yield &yield, Addr va, Addr addr, void *ptr,
238 unsigned stage, unsigned level);
239
240 public:
241 SMMUTranslationProcess(const std::string &name, SMMUv3 &_smmu,
243
244 virtual ~SMMUTranslationProcess();
245
246 void beginTransaction(const SMMUTranslRequest &req);
247 void resumeTransaction();
248};
249
250} // namespace gem5
251
252#endif /* __DEV_ARM_SMMU_V3_TRANSL_HH__ */
CallerType: A reference to an object of this class will be passed to the coroutine task.
Definition coroutine.hh:85
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
const std::string name() const
bool ifcTLBLookup(Yield &yield, TranslResult &tr, bool &wasPrefetched)
void configCacheUpdate(Yield &yield, const TranslContext &tc)
TranslResult translateStage1And2(Yield &yield, Addr addr)
void smmuTLBUpdate(Yield &yield, const TranslResult &tr)
SMMUTranslationProcess(const std::string &name, SMMUv3 &_smmu, SMMUv3DeviceInterface &_ifc)
TranslResult smmuTranslation(Yield &yield)
TranslResult bypass(Addr addr) const
void beginTransaction(const SMMUTranslRequest &req)
bool findConfig(Yield &yield, TranslContext &tc, TranslResult &tr)
void walkCacheLookup(Yield &yield, const WalkCache::Entry *&walkEntry, Addr addr, uint16_t asid, uint16_t vmid, unsigned stage, unsigned level)
bool smmuTLBLookup(Yield &yield, TranslResult &tr)
void abortTransaction(Yield &yield, const TranslResult &tr)
SMMUEvent generateEvent(const TranslResult &tr)
void hazardIdRegister()
Used to force ordering on transactions with the same orderId.
TranslResult walkStage2(Yield &yield, Addr addr, bool final_tr, const ArmISA::PageTableOps *pt_ops, unsigned level, Addr walkPtr)
TranslResult translateStage2(Yield &yield, Addr addr, bool final_tr)
void doReadConfig(Yield &yield, Addr addr, void *ptr, size_t size, uint32_t sid, uint32_t ssid)
void doReadSTE(Yield &yield, StreamTableEntry &ste, uint32_t sid)
SMMUv3DeviceInterface & ifc
bool microTLBLookup(Yield &yield, TranslResult &tr)
bool configCacheLookup(Yield &yield, TranslContext &tc)
TranslResult doReadCD(Yield &yield, ContextDescriptor &cd, const StreamTableEntry &ste, uint32_t sid, uint32_t ssid)
bool hazard4kCheck()
Used to force ordering on transactions with same (SID, SSID, 4k page) to avoid multiple identical pag...
void ifcTLBUpdate(Yield &yield, const TranslResult &tr)
TranslResult walkStage1And2(Yield &yield, Addr addr, const ArmISA::PageTableOps *pt_ops, unsigned level, Addr walkPtr)
void sendEvent(Yield &yield, const SMMUEvent &ev)
void microTLBUpdate(Yield &yield, const TranslResult &tr)
void doReadPTE(Yield &yield, Addr va, Addr addr, void *ptr, unsigned stage, unsigned level)
void walkCacheUpdate(Yield &yield, Addr va, Addr vaMask, Addr pa, unsigned stage, unsigned level, bool leaf, uint8_t permissions)
void completePrefetch(Yield &yield)
GEM5_CLASS_VAR_USED Tick faultTick
TranslResult combineTranslations(const TranslResult &s1tr, const TranslResult &s2tr) const
void completeTransaction(Yield &yield, const TranslResult &tr)
void sendEventInterrupt(Yield &yield)
#define GEM5_CLASS_VAR_USED
Definition compiler.hh:141
int main()
Bitfield< 32 > cd
Bitfield< 39, 12 > pa
Bitfield< 8 > va
Bitfield< 20 > level
Definition intmessage.hh:51
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Bitfield< 10 > ats
Declaration of the Packet class.
static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats=false)
static SMMUTranslRequest prefetch(Addr addr, uint32_t sid, uint32_t ssid)
Fault(const Fault &rhs)=default
Fault & operator=(const Fault &rhs)=default
Fault(FaultType _type, FaultClass _clss=FaultClass::RESERVED, bool _stage2=false, Addr _ipa=0)
TranslResult(const TranslResult &)=default
TranslResult & operator=(const TranslResult &rhs)=default

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0