gem5 v24.0.0.0
Loading...
Searching...
No Matches
tlbi_op.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2020, 2022-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 __ARCH_ARM_TLBI_HH__
39#define __ARCH_ARM_TLBI_HH__
40
41#include "arch/arm/system.hh"
42#include "arch/arm/tlb.hh"
43#include "cpu/thread_context.hh"
44
52namespace gem5
53{
54
55namespace ArmISA {
56
57class TLBIOp
58{
59 public:
60 TLBIOp(TranslationRegime _target_regime, bool _secure)
61 : secureLookup(_secure), targetRegime(_target_regime)
62 {}
63
64 virtual ~TLBIOp() {}
65 virtual void operator()(ThreadContext* tc) {}
66
72 void
74 {
75 for (auto *oc: tc->getSystemPtr()->threads)
76 (*this)(oc);
77 }
78
79 virtual bool match(TlbEntry *entry, vmid_t curr_vmid) const = 0;
80
86 virtual bool
88 {
89 return true;
90 }
91
97 virtual bool
99 {
100 return false;
101 }
102
105};
106
108class TLBIALL : public TLBIOp
109{
110 public:
111 TLBIALL(TranslationRegime _target_regime, bool _secure)
112 : TLBIOp(_target_regime, _secure), el2Enabled(false),
114 {}
115
116 void operator()(ThreadContext* tc) override;
117
118 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
119
120 bool
121 stage2Flush() const override
122 {
123 // TLBIALL (AArch32) flushing stage2 entries if we're currently
124 // in hyp mode
125 return currentEL == EL2;
126 }
127
128 TLBIALL
130 {
132 }
133
136};
137
139class ITLBIALL : public TLBIALL
140{
141 public:
142 ITLBIALL(TranslationRegime _target_regime, bool _secure)
143 : TLBIALL(_target_regime, _secure)
144 {}
145
146 void operator()(ThreadContext* tc) override;
147
148 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
149};
150
152class DTLBIALL : public TLBIALL
153{
154 public:
155 DTLBIALL(TranslationRegime _target_regime, bool _secure)
156 : TLBIALL(_target_regime, _secure)
157 {}
158
159 void operator()(ThreadContext* tc) override;
160
161 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
162};
163
165class TLBIALLEL : public TLBIOp
166{
167 public:
168 TLBIALLEL(TranslationRegime _target_regime, bool _secure)
169 : TLBIOp(_target_regime, _secure)
170 {}
171
172 void operator()(ThreadContext* tc) override;
173
174 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
175
176 bool
177 stage2Flush() const override
178 {
179 // If we're targeting EL1 then flush stage2 as well
182 }
183
186 {
188 }
189
190};
191
193class TLBIVMALL : public TLBIOp
194{
195 public:
196 TLBIVMALL(TranslationRegime _target_regime, bool _secure, bool _stage2)
197 : TLBIOp(_target_regime, _secure), el2Enabled(false),
198 stage2(_stage2)
199 {}
200
201 void operator()(ThreadContext* tc) override;
202
203 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
204
205 bool
206 stage2Flush() const override
207 {
208 return stage2;
209 }
210
213 {
214 return TLBIVMALL(targetRegime, secureLookup, false);
215 }
216
218 bool stage2;
219};
220
222class TLBIASID : public TLBIOp
223{
224 public:
225 TLBIASID(TranslationRegime _target_regime, bool _secure, uint16_t _asid)
226 : TLBIOp(_target_regime, _secure), asid(_asid),
227 el2Enabled(false)
228 {}
229
230 void operator()(ThreadContext* tc) override;
231
232 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
233
234 uint16_t asid;
236};
237
239class ITLBIASID : public TLBIASID
240{
241 public:
242 ITLBIASID(TranslationRegime _target_regime, bool _secure, uint16_t _asid)
243 : TLBIASID(_target_regime, _secure, _asid)
244 {}
245
246 void operator()(ThreadContext* tc) override;
247
248 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
249};
250
252class DTLBIASID : public TLBIASID
253{
254 public:
255 DTLBIASID(TranslationRegime _target_regime, bool _secure, uint16_t _asid)
256 : TLBIASID(_target_regime, _secure, _asid)
257 {}
258
259 void operator()(ThreadContext* tc) override;
260
261 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
262};
263
265class TLBIALLN : public TLBIOp
266{
267 public:
269 : TLBIOp(_target_regime, false)
270 {}
271
272 void operator()(ThreadContext* tc) override;
273
274 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
275
276 bool
277 stage2Flush() const override
278 {
280 }
281
284 {
285 return TLBIALLN(targetRegime);
286 }
287};
288
290class TLBIMVAA : public TLBIOp
291{
292 protected:
294 public:
295 TLBIMVAA(TranslationRegime _target_regime, bool _secure,
296 Addr _addr, bool last_level)
297 : TLBIOp(_target_regime, _secure), addr(_addr),
298 lastLevel(last_level)
299 {}
300
301 void operator()(ThreadContext* tc) override;
302
303 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
304
307};
308
310class TLBIMVA : public TLBIOp
311{
312 protected:
314
315 public:
316 TLBIMVA(TranslationRegime _target_regime, bool _secure,
317 Addr _addr, uint16_t _asid, bool last_level)
318 : TLBIOp(_target_regime, _secure), addr(_addr), asid(_asid),
319 lastLevel(last_level)
320 {}
321
322 void operator()(ThreadContext* tc) override;
323
324 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
325
327 uint16_t asid;
329};
330
332class ITLBIMVA : public TLBIMVA
333{
334 public:
335 ITLBIMVA(TranslationRegime _target_regime, bool _secure,
336 Addr _addr, uint16_t _asid)
337 : TLBIMVA(_target_regime, _secure, _addr, _asid, false)
338 {}
339
340 void operator()(ThreadContext* tc) override;
341
342 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
343};
344
346class DTLBIMVA : public TLBIMVA
347{
348 public:
349 DTLBIMVA(TranslationRegime _target_regime, bool _secure,
350 Addr _addr, uint16_t _asid)
351 : TLBIMVA(_target_regime, _secure, _addr, _asid, false)
352 {}
353
354 void operator()(ThreadContext* tc) override;
355
356 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
357};
358
360{
361 public:
366 bool valid() const { return granule != ReservedGrain; }
367
368 protected:
369 BitUnion64(RangeData)
370 Bitfield<47, 46> tg;
371 Bitfield<45, 44> scale;
372 Bitfield<43, 39> num;
373 Bitfield<38, 37> ttl;
374 Bitfield<36, 0> baseAddr;
375 EndBitUnion(RangeData)
376
377 static constexpr std::array<GrainSize, 4> tgMap = {
379 Grain4KB,
380 Grain16KB,
382 };
383
387
388 Addr
390 {
391 return sext<37>(rangeData.baseAddr) << granule;
392 }
393
394 Addr
395 rangeSize() const
396 {
397 return (rangeData.num + 1) << (5 * rangeData.scale + 1 + granule);
398 }
399
400 bool
401 resTLBIttl(uint8_t tg, uint8_t ttl) const
402 {
403 switch (ttl) {
404 case 0: return true;
405 case 1: return tgMap[tg] == Grain16KB;
406 default: return false;
407 }
408 }
409
410 RangeData rangeData;
412};
413
415class TLBIIPA : public TLBIOp
416{
417 public:
418 TLBIIPA(TranslationRegime _target_regime, bool _secure, Addr _addr,
419 bool last_level)
420 : TLBIOp(_target_regime, _secure), addr(_addr), lastLevel(last_level)
421 {}
422
423 void operator()(ThreadContext* tc) override;
424
425 bool
426 match(TlbEntry *entry, vmid_t curr_vmid) const override
427 {
428 panic("This shouldn't be called\n");
429 }
430
431 bool
432 stage1Flush() const override
433 {
434 return false;
435 }
436
438 virtual TLBIMVAA
440 {
442 }
443
446};
447
449class TLBIRMVA : public TLBIRange, public TLBIMVA
450{
451 public:
452 TLBIRMVA(TranslationRegime _target_regime, bool _secure,
453 RegVal val, uint16_t _asid, bool last_level)
454 : TLBIRange(val),
455 TLBIMVA(_target_regime, _secure, startAddress(), _asid, last_level)
456 {}
457
458 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
459};
460
462class TLBIRMVAA : public TLBIRange, public TLBIMVAA
463{
464 public:
465 TLBIRMVAA(TranslationRegime _target_regime, bool _secure,
466 RegVal val, bool last_level)
467 : TLBIRange(val),
468 TLBIMVAA(_target_regime, _secure, startAddress(), last_level)
469 {}
470
471 bool match(TlbEntry *entry, vmid_t curr_vmid) const override;
472};
473
475class TLBIRIPA : public TLBIRange, public TLBIIPA
476{
477 public:
478 TLBIRIPA(TranslationRegime _target_regime, bool _secure,
479 RegVal val, bool last_level)
480 : TLBIRange(val),
481 TLBIIPA(_target_regime, _secure, startAddress(), last_level)
482 {}
483
484 virtual TLBIMVAA
489};
490
491} // namespace ArmISA
492} // namespace gem5
493
494#endif //__ARCH_ARM_TLBI_HH__
Data TLB Invalidate All.
Definition tlbi_op.hh:153
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:85
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:92
DTLBIALL(TranslationRegime _target_regime, bool _secure)
Definition tlbi_op.hh:155
Data TLB Invalidate by ASID match.
Definition tlbi_op.hh:253
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:173
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:180
DTLBIASID(TranslationRegime _target_regime, bool _secure, uint16_t _asid)
Definition tlbi_op.hh:255
Data TLB Invalidate by VA.
Definition tlbi_op.hh:347
DTLBIMVA(TranslationRegime _target_regime, bool _secure, Addr _addr, uint16_t _asid)
Definition tlbi_op.hh:349
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:284
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:290
Instruction TLB Invalidate All.
Definition tlbi_op.hh:140
ITLBIALL(TranslationRegime _target_regime, bool _secure)
Definition tlbi_op.hh:142
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:79
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:72
Instruction TLB Invalidate by ASID match.
Definition tlbi_op.hh:240
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:160
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:167
ITLBIASID(TranslationRegime _target_regime, bool _secure, uint16_t _asid)
Definition tlbi_op.hh:242
Instruction TLB Invalidate by VA.
Definition tlbi_op.hh:333
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:272
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:278
ITLBIMVA(TranslationRegime _target_regime, bool _secure, Addr _addr, uint16_t _asid)
Definition tlbi_op.hh:335
Implementaton of AArch64 TLBI ALLE(1,2,3)(IS) instructions.
Definition tlbi_op.hh:166
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:98
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:110
bool stage2Flush() const override
Return true if the TLBI op needs to flush stage2 entries, Defaulting to false in the TLBIOp abstract ...
Definition tlbi_op.hh:177
TLBIALLEL(TranslationRegime _target_regime, bool _secure)
Definition tlbi_op.hh:168
TLBIALLEL makeStage2() const
Definition tlbi_op.hh:185
TLB Invalidate All, Non-Secure.
Definition tlbi_op.hh:266
TLBIALLN makeStage2() const
Definition tlbi_op.hh:283
bool stage2Flush() const override
Return true if the TLBI op needs to flush stage2 entries, Defaulting to false in the TLBIOp abstract ...
Definition tlbi_op.hh:277
TLBIALLN(TranslationRegime _target_regime)
Definition tlbi_op.hh:268
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:186
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:197
TLB Invalidate All.
Definition tlbi_op.hh:109
TLBIALL(TranslationRegime _target_regime, bool _secure)
Definition tlbi_op.hh:111
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:64
bool stage2Flush() const override
Return true if the TLBI op needs to flush stage2 entries, Defaulting to false in the TLBIOp abstract ...
Definition tlbi_op.hh:121
ExceptionLevel currentEL
Definition tlbi_op.hh:135
TLBIALL makeStage2() const
Definition tlbi_op.hh:129
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:49
TLB Invalidate by ASID match.
Definition tlbi_op.hh:223
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:139
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:151
TLBIASID(TranslationRegime _target_regime, bool _secure, uint16_t _asid)
Definition tlbi_op.hh:225
TLB Invalidate by Intermediate Physical Address.
Definition tlbi_op.hh:416
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:296
TLBIIPA(TranslationRegime _target_regime, bool _secure, Addr _addr, bool last_level)
Definition tlbi_op.hh:418
virtual TLBIMVAA makeStage2() const
TLBIIPA is basically a TLBIMVAA for stage2 TLBs.
Definition tlbi_op.hh:439
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.hh:426
bool stage1Flush() const override
Return true if the TLBI op needs to flush stage1 entries, Defaulting to true in the TLBIOp abstract c...
Definition tlbi_op.hh:432
TLB Invalidate by VA, All ASID.
Definition tlbi_op.hh:291
TLBIMVAA(TranslationRegime _target_regime, bool _secure, Addr _addr, bool last_level)
Definition tlbi_op.hh:295
TlbEntry::Lookup lookupGen(vmid_t vmid) const
Definition tlbi_op.cc:204
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:229
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:218
TLB Invalidate by VA.
Definition tlbi_op.hh:311
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:264
TlbEntry::Lookup lookupGen(vmid_t vmid) const
Definition tlbi_op.cc:237
TLBIMVA(TranslationRegime _target_regime, bool _secure, Addr _addr, uint16_t _asid, bool last_level)
Definition tlbi_op.hh:316
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:253
void broadcast(ThreadContext *tc)
Broadcast the TLB Invalidate operation to all TLBs in the Arm system.
Definition tlbi_op.hh:73
virtual bool stage1Flush() const
Return true if the TLBI op needs to flush stage1 entries, Defaulting to true in the TLBIOp abstract c...
Definition tlbi_op.hh:87
TranslationRegime targetRegime
Definition tlbi_op.hh:104
virtual bool match(TlbEntry *entry, vmid_t curr_vmid) const =0
virtual bool stage2Flush() const
Return true if the TLBI op needs to flush stage2 entries, Defaulting to false in the TLBIOp abstract ...
Definition tlbi_op.hh:98
TLBIOp(TranslationRegime _target_regime, bool _secure)
Definition tlbi_op.hh:60
virtual void operator()(ThreadContext *tc)
Definition tlbi_op.hh:65
virtual ~TLBIOp()
Definition tlbi_op.hh:64
TLB Range Invalidate by VA, All ASIDs.
Definition tlbi_op.hh:476
TLBIRIPA(TranslationRegime _target_regime, bool _secure, RegVal val, bool last_level)
Definition tlbi_op.hh:478
virtual TLBIMVAA makeStage2() const
TLBIIPA is basically a TLBIMVAA for stage2 TLBs.
Definition tlbi_op.hh:485
TLB Range Invalidate by VA, All ASIDs.
Definition tlbi_op.hh:463
TLBIRMVAA(TranslationRegime _target_regime, bool _secure, RegVal val, bool last_level)
Definition tlbi_op.hh:465
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:323
TLB Range Invalidate by VA.
Definition tlbi_op.hh:450
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:307
TLBIRMVA(TranslationRegime _target_regime, bool _secure, RegVal val, uint16_t _asid, bool last_level)
Definition tlbi_op.hh:452
Bitfield< 36, 0 > baseAddr
Definition tlbi_op.hh:374
Addr startAddress() const
Definition tlbi_op.hh:389
bool resTLBIttl(uint8_t tg, uint8_t ttl) const
Definition tlbi_op.hh:401
BitUnion64(RangeData) Bitfield< 47
Addr rangeSize() const
Definition tlbi_op.hh:395
Bitfield< 43, 39 > num
Definition tlbi_op.hh:372
bool valid() const
Is the range valid? This mainly depends on the specified translation granule.
Definition tlbi_op.hh:366
Bitfield< 38, 37 > ttl
Definition tlbi_op.hh:373
TLBIRange(RegVal val)
Definition tlbi_op.hh:384
Bitfield< 45, 44 > scale
Definition tlbi_op.hh:371
Implementaton of AArch64 TLBI VMALLE1(IS)/VMALLS112E1(IS) instructions.
Definition tlbi_op.hh:194
TLBIVMALL makeStage2() const
Definition tlbi_op.hh:212
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition tlbi_op.cc:131
TLBIVMALL(TranslationRegime _target_regime, bool _secure, bool _stage2)
Definition tlbi_op.hh:196
void operator()(ThreadContext *tc) override
Definition tlbi_op.cc:117
bool stage2Flush() const override
Return true if the TLBI op needs to flush stage2 entries, Defaulting to false in the TLBIOp abstract ...
Definition tlbi_op.hh:206
Threads threads
Definition system.hh:310
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual System * getSystemPtr()=0
constexpr uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition bitfield.hh:129
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
uint16_t vmid_t
Definition types.hh:57
Bitfield< 63 > val
Definition misc.hh:804
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t RegVal
Definition types.hh:173
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0