gem5  v22.1.0.0
tlbi_op.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2022 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 #include "arch/arm/tlbi_op.hh"
39 
40 #include "arch/arm/mmu.hh"
41 #include "cpu/checker/cpu.hh"
42 
43 namespace gem5
44 {
45 
46 namespace ArmISA {
47 
48 void
50 {
51  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
52  inHost = (hcr.tge == 1 && hcr.e2h == 1);
53  el2Enabled = EL2Enabled(tc);
54  currentEL = currEL(tc);
55 
56  getMMUPtr(tc)->flush(*this);
57 
58  // If CheckerCPU is connected, need to notify it of a flush
59  CheckerCPU *checker = tc->getCheckerCpuPtr();
60  if (checker) {
61  getMMUPtr(checker)->flush(*this);
62  }
63 }
64 
65 bool
67 {
68  return te->valid && secureLookup == !te->nstid &&
69  (te->vmid == vmid || el2Enabled) &&
70  te->checkELMatch(targetEL, inHost);
71 }
72 
73 void
75 {
76  el2Enabled = EL2Enabled(tc);
77  getMMUPtr(tc)->iflush(*this);
78 }
79 
80 bool
82 {
83  return TLBIALL::match(te, vmid) && (te->type & TypeTLB::instruction);
84 }
85 
86 void
88 {
89  el2Enabled = EL2Enabled(tc);
90  getMMUPtr(tc)->dflush(*this);
91 }
92 
93 bool
95 {
96  return TLBIALL::match(te, vmid) && (te->type & TypeTLB::data);
97 }
98 
99 void
101 {
102  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
103  inHost = (hcr.tge == 1 && hcr.e2h == 1);
104  getMMUPtr(tc)->flush(*this);
105 
106  // If CheckerCPU is connected, need to notify it of a flush
107  CheckerCPU *checker = tc->getCheckerCpuPtr();
108  if (checker) {
109  getMMUPtr(checker)->flush(*this);
110  }
111 }
112 
113 bool
115 {
116  return te->valid && secureLookup == !te->nstid &&
117  te->checkELMatch(targetEL, inHost);
118 }
119 
120 void
122 {
123  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
124  inHost = (hcr.tge == 1 && hcr.e2h == 1);
125  el2Enabled = EL2Enabled(tc);
126 
127  getMMUPtr(tc)->flush(*this);
128 
129  // If CheckerCPU is connected, need to notify it of a flush
130  CheckerCPU *checker = tc->getCheckerCpuPtr();
131  if (checker) {
132  getMMUPtr(checker)->flush(*this);
133  }
134 }
135 
136 bool
138 {
139  return te->valid && secureLookup == !te->nstid &&
140  te->checkELMatch(targetEL, inHost) &&
141  (te->vmid == vmid || !el2Enabled || (!stage2Flush() && inHost));
142 }
143 
144 void
146 {
147  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
148  inHost = (hcr.tge == 1 && hcr.e2h == 1);
149  el2Enabled = EL2Enabled(tc);
150 
151  getMMUPtr(tc)->flushStage1(*this);
152  CheckerCPU *checker = tc->getCheckerCpuPtr();
153  if (checker) {
154  getMMUPtr(checker)->flushStage1(*this);
155  }
156 }
157 
158 bool
160 {
161  return te->valid && te->asid == asid &&
162  secureLookup == !te->nstid &&
163  te->checkELMatch(targetEL, inHost) &&
164  (te->vmid == vmid || !el2Enabled || inHost);
165 }
166 
167 void
169 {
170  el2Enabled = EL2Enabled(tc);
171  getMMUPtr(tc)->iflush(*this);
172 }
173 
174 bool
176 {
177  return TLBIASID::match(te, vmid) && (te->type & TypeTLB::instruction);
178 }
179 
180 void
182 {
183  el2Enabled = EL2Enabled(tc);
184  getMMUPtr(tc)->dflush(*this);
185 }
186 
187 bool
189 {
190  return TLBIASID::match(te, vmid) && (te->type & TypeTLB::data);
191 }
192 
193 void
195 {
196  getMMUPtr(tc)->flush(*this);
197 
198  CheckerCPU *checker = tc->getCheckerCpuPtr();
199  if (checker) {
200  getMMUPtr(checker)->flush(*this);
201  }
202 }
203 
204 bool
206 {
207  return te->valid && te->nstid &&
208  te->isHyp == (targetEL == EL2) &&
209  te->checkELMatch(targetEL, false);
210 }
211 
212 void
214 {
215  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
216  inHost = (hcr.tge == 1 && hcr.e2h == 1);
217  getMMUPtr(tc)->flushStage1(*this);
218 
219  CheckerCPU *checker = tc->getCheckerCpuPtr();
220  if (checker) {
221  getMMUPtr(checker)->flushStage1(*this);
222  }
223 }
224 
225 bool
227 {
228  TlbEntry::Lookup lookup_data;
229  lookup_data.va = sext<56>(addr);
230  lookup_data.ignoreAsn = true;
231  lookup_data.vmid = vmid;
232  lookup_data.hyp = targetEL == EL2;
233  lookup_data.secure = secureLookup;
234  lookup_data.functional = true;
235  lookup_data.targetEL = targetEL;
236  lookup_data.inHost = inHost;
237  lookup_data.mode = BaseMMU::Read;
238 
239  return te->match(lookup_data) && (!lastLevel || !te->partial);
240 }
241 
242 void
244 {
245  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
246  inHost = (hcr.tge == 1 && hcr.e2h == 1);
247  getMMUPtr(tc)->flushStage1(*this);
248 
249  CheckerCPU *checker = tc->getCheckerCpuPtr();
250  if (checker) {
251  getMMUPtr(checker)->flushStage1(*this);
252  }
253 }
254 
255 bool
257 {
258  TlbEntry::Lookup lookup_data;
259  lookup_data.va = sext<56>(addr);
260  lookup_data.asn = asid;
261  lookup_data.ignoreAsn = false;
262  lookup_data.vmid = vmid;
263  lookup_data.hyp = targetEL == EL2;
264  lookup_data.secure = secureLookup;
265  lookup_data.functional = true;
266  lookup_data.targetEL = targetEL;
267  lookup_data.inHost = inHost;
268  lookup_data.mode = BaseMMU::Read;
269 
270  return te->match(lookup_data) && (!lastLevel || !te->partial);
271 }
272 
273 void
275 {
276  getMMUPtr(tc)->iflush(*this);
277 }
278 
279 bool
281 {
282  return TLBIMVA::match(te, vmid) && (te->type & TypeTLB::instruction);
283 }
284 
285 void
287 {
288  getMMUPtr(tc)->dflush(*this);
289 }
290 
291 bool
293 {
294  return TLBIMVA::match(te, vmid) && (te->type & TypeTLB::data);
295 }
296 
297 void
299 {
301 
302  CheckerCPU *checker = tc->getCheckerCpuPtr();
303  if (checker) {
304  getMMUPtr(checker)->flushStage2(makeStage2());
305  }
306 }
307 
308 } // namespace ArmISA
309 } // namespace gem5
const char data[]
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:87
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:94
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:181
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:188
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:286
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:292
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:81
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:74
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:168
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:175
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:274
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:280
void flushStage2(const OP &tlbi_op)
Definition: mmu.hh:330
void iflush(const OP &tlbi_op)
Definition: mmu.hh:338
void flushStage1(const OP &tlbi_op)
Definition: mmu.hh:315
void flush(const OP &tlbi_op)
Definition: mmu.hh:302
void dflush(const OP &tlbi_op)
Definition: mmu.hh:350
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:100
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:114
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:194
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:205
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:66
ExceptionLevel currentEL
Definition: tlbi_op.hh:136
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:49
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:145
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:159
TLBIMVAA makeStage2() const
TLBIIPA is basically a TLBIMVAA for stage2 TLBs.
Definition: tlbi_op.hh:396
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:298
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:226
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:213
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:256
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:243
ExceptionLevel targetEL
Definition: tlbi_op.hh:104
bool match(TlbEntry *entry, vmid_t curr_vmid) const override
Definition: tlbi_op.cc:137
void operator()(ThreadContext *tc) override
Definition: tlbi_op.cc:121
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:211
CheckerCPU class.
Definition: cpu.hh:85
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual CheckerCPU * getCheckerCpuPtr()=0
Bitfield< 30 > te
Definition: misc_types.hh:344
MMU * getMMUPtr(T *tc)
Definition: mmu.hh:516
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
Definition: utility.cc:124
bool EL2Enabled(ThreadContext *tc)
Definition: utility.cc:260
@ MISCREG_HCR_EL2
Definition: misc.hh:591
uint16_t vmid_t
Definition: types.hh:57
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
The file contains the definition of a set of TLB Invalidate Instructions.

Generated on Wed Dec 21 2022 10:22:27 for gem5 by doxygen 1.9.1