gem5  v20.1.0.0
tlb.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2013, 2016-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  * Copyright (c) 2001-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #include "arch/arm/tlb.hh"
42 
43 #include <memory>
44 #include <string>
45 #include <vector>
46 
47 #include "arch/arm/faults.hh"
48 #include "arch/arm/isa.hh"
49 #include "arch/arm/pagetable.hh"
50 #include "arch/arm/self_debug.hh"
52 #include "arch/arm/stage2_mmu.hh"
53 #include "arch/arm/system.hh"
54 #include "arch/arm/table_walker.hh"
55 #include "arch/arm/utility.hh"
56 #include "base/inifile.hh"
57 #include "base/str.hh"
58 #include "base/trace.hh"
59 #include "cpu/base.hh"
60 #include "cpu/thread_context.hh"
61 #include "debug/Checkpoint.hh"
62 #include "debug/TLB.hh"
63 #include "debug/TLBVerbose.hh"
64 #include "mem/packet_access.hh"
65 #include "mem/page_table.hh"
66 #include "mem/request.hh"
67 #include "params/ArmTLB.hh"
68 #include "sim/full_system.hh"
69 #include "sim/process.hh"
70 #include "sim/pseudo_inst.hh"
71 
72 using namespace std;
73 using namespace ArmISA;
74 
75 TLB::TLB(const ArmTLBParams *p)
76  : BaseTLB(p), table(new TlbEntry[p->size]), size(p->size),
77  isStage2(p->is_stage2), stage2Req(false), stage2DescReq(false), _attr(0),
78  directToStage2(false), tableWalker(p->walker), stage2Tlb(NULL),
79  stage2Mmu(NULL), test(nullptr), stats(this), rangeMRU(1),
80  aarch64(false), aarch64EL(EL0), isPriv(false), isSecure(false),
81  isHyp(false), asid(0), vmid(0), hcr(0), dacr(0),
82  miscRegValid(false), miscRegContext(0), curTranType(NormalTran)
83 {
84  const ArmSystem *sys = dynamic_cast<const ArmSystem *>(p->sys);
85 
86  tableWalker->setTlb(this);
87 
88  // Cache system-level properties
92 
93  if (sys)
94  m5opRange = sys->m5opRange();
95 }
96 
98 {
99  delete[] table;
100 }
101 
102 void
104 {
105  if (stage2Mmu && !isStage2)
107 }
108 
109 void
111 {
112  stage2Mmu = m;
113  tableWalker->setMMU(m, requestor_id);
114 }
115 
116 bool
118 {
119  updateMiscReg(tc);
120 
121  if (directToStage2) {
122  assert(stage2Tlb);
123  return stage2Tlb->translateFunctional(tc, va, pa);
124  }
125 
126  TlbEntry *e = lookup(va, asid, vmid, isHyp, isSecure, true, false,
127  aarch64 ? aarch64EL : EL1, false);
128  if (!e)
129  return false;
130  pa = e->pAddr(va);
131  return true;
132 }
133 
134 Fault
136  ThreadContext *tc, Mode mode) const
137 {
138  const Addr paddr = req->getPaddr();
139 
140  if (m5opRange.contains(paddr)) {
141  uint8_t func;
143  req->setLocalAccessor(
144  [func, mode](ThreadContext *tc, PacketPtr pkt) -> Cycles
145  {
146  uint64_t ret;
147  PseudoInst::pseudoInst<PseudoInstABI>(tc, func, ret);
148  if (mode == Read)
149  pkt->setLE(ret);
150  return Cycles(1);
151  }
152  );
153  }
154 
155  return NoFault;
156 }
157 
158 TlbEntry*
159 TLB::lookup(Addr va, uint16_t asn, uint8_t vmid, bool hyp, bool secure,
160  bool functional, bool ignore_asn, ExceptionLevel target_el,
161  bool in_host)
162 {
163 
164  TlbEntry *retval = NULL;
165 
166  // Maintaining LRU array
167  int x = 0;
168  while (retval == NULL && x < size) {
169  if ((!ignore_asn && table[x].match(va, asn, vmid, hyp, secure, false,
170  target_el, in_host)) ||
171  (ignore_asn && table[x].match(va, vmid, hyp, secure, target_el,
172  in_host))) {
173  // We only move the hit entry ahead when the position is higher
174  // than rangeMRU
175  if (x > rangeMRU && !functional) {
176  TlbEntry tmp_entry = table[x];
177  for (int i = x; i > 0; i--)
178  table[i] = table[i - 1];
179  table[0] = tmp_entry;
180  retval = &table[0];
181  } else {
182  retval = &table[x];
183  }
184  break;
185  }
186  ++x;
187  }
188 
189  DPRINTF(TLBVerbose, "Lookup %#x, asn %#x -> %s vmn 0x%x hyp %d secure %d "
190  "ppn %#x size: %#x pa: %#x ap:%d ns:%d nstid:%d g:%d asid: %d "
191  "el: %d\n",
192  va, asn, retval ? "hit" : "miss", vmid, hyp, secure,
193  retval ? retval->pfn : 0, retval ? retval->size : 0,
194  retval ? retval->pAddr(va) : 0, retval ? retval->ap : 0,
195  retval ? retval->ns : 0, retval ? retval->nstid : 0,
196  retval ? retval->global : 0, retval ? retval->asid : 0,
197  retval ? retval->el : 0);
198 
199  return retval;
200 }
201 
202 // insert a new TLB entry
203 void
205 {
206  DPRINTF(TLB, "Inserting entry into TLB with pfn:%#x size:%#x vpn: %#x"
207  " asid:%d vmid:%d N:%d global:%d valid:%d nc:%d xn:%d"
208  " ap:%#x domain:%#x ns:%d nstid:%d isHyp:%d\n", entry.pfn,
209  entry.size, entry.vpn, entry.asid, entry.vmid, entry.N,
210  entry.global, entry.valid, entry.nonCacheable, entry.xn,
211  entry.ap, static_cast<uint8_t>(entry.domain), entry.ns, entry.nstid,
212  entry.isHyp);
213 
214  if (table[size - 1].valid)
215  DPRINTF(TLB, " - Replacing Valid entry %#x, asn %d vmn %d ppn %#x "
216  "size: %#x ap:%d ns:%d nstid:%d g:%d isHyp:%d el: %d\n",
217  table[size-1].vpn << table[size-1].N, table[size-1].asid,
218  table[size-1].vmid, table[size-1].pfn << table[size-1].N,
219  table[size-1].size, table[size-1].ap, table[size-1].ns,
220  table[size-1].nstid, table[size-1].global, table[size-1].isHyp,
221  table[size-1].el);
222 
223  //inserting to MRU position and evicting the LRU one
224 
225  for (int i = size - 1; i > 0; --i)
226  table[i] = table[i-1];
227  table[0] = entry;
228 
229  stats.inserts++;
230  ppRefills->notify(1);
231 }
232 
233 void
235 {
236  int x = 0;
237  TlbEntry *te;
238  DPRINTF(TLB, "Current TLB contents:\n");
239  while (x < size) {
240  te = &table[x];
241  if (te->valid)
242  DPRINTF(TLB, " * %s\n", te->print());
243  ++x;
244  }
245 }
246 
247 void
248 TLB::flushAllSecurity(bool secure_lookup, ExceptionLevel target_el,
249  bool ignore_el, bool in_host)
250 {
251  DPRINTF(TLB, "Flushing all TLB entries (%s lookup)\n",
252  (secure_lookup ? "secure" : "non-secure"));
253  int x = 0;
254  TlbEntry *te;
255  while (x < size) {
256  te = &table[x];
257  const bool el_match = ignore_el ?
258  true : te->checkELMatch(target_el, in_host);
259  if (te->valid && secure_lookup == !te->nstid &&
260  (te->vmid == vmid || secure_lookup) && el_match) {
261 
262  DPRINTF(TLB, " - %s\n", te->print());
263  te->valid = false;
265  }
266  ++x;
267  }
268 
269  stats.flushTlb++;
270 
271  // If there's a second stage TLB (and we're not it) then flush it as well
272  // if we're currently in hyp mode
273  if (!isStage2 && isHyp) {
274  stage2Tlb->flushAllSecurity(secure_lookup, EL1, true, false);
275  }
276 }
277 
278 void
279 TLB::flushAllNs(ExceptionLevel target_el, bool ignore_el)
280 {
281  bool hyp = target_el == EL2;
282 
283  DPRINTF(TLB, "Flushing all NS TLB entries (%s lookup)\n",
284  (hyp ? "hyp" : "non-hyp"));
285  int x = 0;
286  TlbEntry *te;
287  while (x < size) {
288  te = &table[x];
289  const bool el_match = ignore_el ?
290  true : te->checkELMatch(target_el, false);
291 
292  if (te->valid && te->nstid && te->isHyp == hyp && el_match) {
293 
294  DPRINTF(TLB, " - %s\n", te->print());
296  te->valid = false;
297  }
298  ++x;
299  }
300 
301  stats.flushTlb++;
302 
303  // If there's a second stage TLB (and we're not it) then flush it as well
304  if (!isStage2 && !hyp) {
305  stage2Tlb->flushAllNs(EL1, true);
306  }
307 }
308 
309 void
310 TLB::flushMvaAsid(Addr mva, uint64_t asn, bool secure_lookup,
311  ExceptionLevel target_el, bool in_host)
312 {
313  DPRINTF(TLB, "Flushing TLB entries with mva: %#x, asid: %#x "
314  "(%s lookup)\n", mva, asn, (secure_lookup ?
315  "secure" : "non-secure"));
316  _flushMva(mva, asn, secure_lookup, false, target_el, in_host);
318 }
319 
320 void
321 TLB::flushAsid(uint64_t asn, bool secure_lookup, ExceptionLevel target_el,
322  bool in_host)
323 {
324  DPRINTF(TLB, "Flushing TLB entries with asid: %#x (%s lookup)\n", asn,
325  (secure_lookup ? "secure" : "non-secure"));
326 
327  int x = 0 ;
328  TlbEntry *te;
329 
330  while (x < size) {
331  te = &table[x];
332  if (te->valid && te->asid == asn && secure_lookup == !te->nstid &&
333  (te->vmid == vmid || secure_lookup) &&
334  te->checkELMatch(target_el, in_host)) {
335 
336  te->valid = false;
337  DPRINTF(TLB, " - %s\n", te->print());
339  }
340  ++x;
341  }
343 }
344 
345 void
346 TLB::flushMva(Addr mva, bool secure_lookup, ExceptionLevel target_el,
347  bool in_host) {
348 
349  DPRINTF(TLB, "Flushing TLB entries with mva: %#x (%s lookup)\n", mva,
350  (secure_lookup ? "secure" : "non-secure"));
351  _flushMva(mva, 0xbeef, secure_lookup, true, target_el, in_host);
352  stats.flushTlbMva++;
353 }
354 
355 void
356 TLB::_flushMva(Addr mva, uint64_t asn, bool secure_lookup,
357  bool ignore_asn, ExceptionLevel target_el, bool in_host)
358 {
359  TlbEntry *te;
360  // D5.7.2: Sign-extend address to 64 bits
361  mva = sext<56>(mva);
362 
363  bool hyp = target_el == EL2;
364 
365  te = lookup(mva, asn, vmid, hyp, secure_lookup, false, ignore_asn,
366  target_el, in_host);
367  while (te != NULL) {
368  if (secure_lookup == !te->nstid) {
369  DPRINTF(TLB, " - %s\n", te->print());
370  te->valid = false;
372  }
373  te = lookup(mva, asn, vmid, hyp, secure_lookup, false, ignore_asn,
374  target_el, in_host);
375  }
376 }
377 
378 void
379 TLB::flushIpaVmid(Addr ipa, bool secure_lookup, ExceptionLevel target_el)
380 {
381  assert(!isStage2);
382  stage2Tlb->_flushMva(ipa, 0xbeef, secure_lookup, true, target_el, false);
383 }
384 
385 void
387 {
388  // We might have unserialized something or switched CPUs, so make
389  // sure to re-read the misc regs.
390  miscRegValid = false;
391 }
392 
393 void
395 {
396  TLB *otlb = dynamic_cast<TLB*>(_otlb);
397  /* Make sure we actually have a valid type */
398  if (otlb) {
399  _attr = otlb->_attr;
400  haveLPAE = otlb->haveLPAE;
402  stage2Req = otlb->stage2Req;
404 
405  /* Sync the stage2 MMU if they exist in both
406  * the old CPU and the new
407  */
408  if (!isStage2 &&
409  stage2Tlb && otlb->stage2Tlb) {
411  }
412  } else {
413  panic("Incompatible TLB type!");
414  }
415 }
416 
418  : Stats::Group(parent),
419  ADD_STAT(instHits,"ITB inst hits"),
420  ADD_STAT(instMisses, "ITB inst misses"),
421  ADD_STAT(readHits, "DTB read hits"),
422  ADD_STAT(readMisses, "DTB read misses"),
423  ADD_STAT(writeHits, "DTB write hits"),
424  ADD_STAT(writeMisses, "DTB write misses"),
425  ADD_STAT(inserts, "Number of times an entry is inserted into the TLB"),
426  ADD_STAT(flushTlb, "Number of times complete TLB was flushed"),
427  ADD_STAT(flushTlbMva, "Number of times TLB was flushed by MVA"),
428  ADD_STAT(flushTlbMvaAsid, "Number of times TLB was flushed by MVA & ASID"),
429  ADD_STAT(flushTlbAsid, "Number of times TLB was flushed by ASID"),
430  ADD_STAT(flushedEntries, "Number of entries that have been flushed"
431  " from TLB"),
432  ADD_STAT(alignFaults, "Number of TLB faults due to alignment"
433  " restrictions"),
434  ADD_STAT(prefetchFaults, "Number of TLB faults due to prefetch"),
435  ADD_STAT(domainFaults, "Number of TLB faults due to domain restrictions"),
436  ADD_STAT(permsFaults, "Number of TLB faults due to permissions"
437  " restrictions"),
438  ADD_STAT(readAccesses, "DTB read accesses", readHits + readMisses),
439  ADD_STAT(writeAccesses, "DTB write accesses", writeHits + writeMisses),
440  ADD_STAT(instAccesses, "ITB inst accesses", instHits + instMisses),
441  ADD_STAT(hits, "Total TLB (inst and data) hits",
442  readHits + writeHits + instHits),
443  ADD_STAT(misses, "Total TLB (inst and data) misses",
444  readMisses + writeMisses + instMisses),
445  ADD_STAT(accesses, "Total TLB (inst and data) accesses",
446  readAccesses + writeAccesses + instAccesses)
447 {
448 }
449 
450 void
452 {
453  ppRefills.reset(new ProbePoints::PMU(getProbeManager(), "Refills"));
454 }
455 
456 Fault
458  Translation *translation, bool &delay, bool timing)
459 {
460  updateMiscReg(tc);
461  Addr vaddr_tainted = req->getVaddr();
462  Addr vaddr = 0;
463  if (aarch64)
464  vaddr = purifyTaggedAddr(vaddr_tainted, tc, aarch64EL, (TCR)ttbcr,
465  mode==Execute);
466  else
467  vaddr = vaddr_tainted;
468  Request::Flags flags = req->getFlags();
469 
470  bool is_fetch = (mode == Execute);
471  bool is_write = (mode == Write);
472 
473  if (!is_fetch) {
474  if (sctlr.a || !(flags & AllowUnaligned)) {
475  if (vaddr & mask(flags & AlignmentMask)) {
476  // LPAE is always disabled in SE mode
477  return std::make_shared<DataAbort>(
478  vaddr_tainted,
482  }
483  }
484  }
485 
486  Addr paddr;
487  Process *p = tc->getProcessPtr();
488 
489  if (!p->pTable->translate(vaddr, paddr))
490  return std::make_shared<GenericPageTableFault>(vaddr_tainted);
491  req->setPaddr(paddr);
492 
493  return finalizePhysical(req, tc, mode);
494 }
495 
496 Fault
498 {
499  // a data cache maintenance instruction that operates by MVA does
500  // not generate a Data Abort exeception due to a Permission fault
501  if (req->isCacheMaintenance()) {
502  return NoFault;
503  }
504 
505  Addr vaddr = req->getVaddr(); // 32-bit don't have to purify
506  Request::Flags flags = req->getFlags();
507  bool is_fetch = (mode == Execute);
508  bool is_write = (mode == Write);
509  bool is_priv = isPriv && !(flags & UserMode);
510 
511  // Get the translation type from the actuall table entry
512  ArmFault::TranMethod tranMethod = te->longDescFormat ? ArmFault::LpaeTran
514 
515  // If this is the second stage of translation and the request is for a
516  // stage 1 page table walk then we need to check the HCR.PTW bit. This
517  // allows us to generate a fault if the request targets an area marked
518  // as a device or strongly ordered.
519  if (isStage2 && req->isPTWalk() && hcr.ptw &&
520  (te->mtype != TlbEntry::MemoryType::Normal)) {
521  return std::make_shared<DataAbort>(
522  vaddr, te->domain, is_write,
523  ArmFault::PermissionLL + te->lookupLevel,
524  isStage2, tranMethod);
525  }
526 
527  // Generate an alignment fault for unaligned data accesses to device or
528  // strongly ordered memory
529  if (!is_fetch) {
530  if (te->mtype != TlbEntry::MemoryType::Normal) {
531  if (vaddr & mask(flags & AlignmentMask)) {
532  stats.alignFaults++;
533  return std::make_shared<DataAbort>(
536  tranMethod);
537  }
538  }
539  }
540 
541  if (te->nonCacheable) {
542  // Prevent prefetching from I/O devices.
543  if (req->isPrefetch()) {
544  // Here we can safely use the fault status for the short
545  // desc. format in all cases
546  return std::make_shared<PrefetchAbort>(
548  isStage2, tranMethod);
549  }
550  }
551 
552  if (!te->longDescFormat) {
553  switch ((dacr >> (static_cast<uint8_t>(te->domain) * 2)) & 0x3) {
554  case 0:
556  DPRINTF(TLB, "TLB Fault: Data abort on domain. DACR: %#x"
557  " domain: %#x write:%d\n", dacr,
558  static_cast<uint8_t>(te->domain), is_write);
559  if (is_fetch) {
560  // Use PC value instead of vaddr because vaddr might
561  // be aligned to cache line and should not be the
562  // address reported in FAR
563  return std::make_shared<PrefetchAbort>(
564  req->getPC(),
565  ArmFault::DomainLL + te->lookupLevel,
566  isStage2, tranMethod);
567  } else
568  return std::make_shared<DataAbort>(
569  vaddr, te->domain, is_write,
570  ArmFault::DomainLL + te->lookupLevel,
571  isStage2, tranMethod);
572  case 1:
573  // Continue with permissions check
574  break;
575  case 2:
576  panic("UNPRED domain\n");
577  case 3:
578  return NoFault;
579  }
580  }
581 
582  // The 'ap' variable is AP[2:0] or {AP[2,1],1b'0}, i.e. always three bits
583  uint8_t ap = te->longDescFormat ? te->ap << 1 : te->ap;
584  uint8_t hap = te->hap;
585 
586  if (sctlr.afe == 1 || te->longDescFormat)
587  ap |= 1;
588 
589  bool abt;
590  bool isWritable = true;
591  // If this is a stage 2 access (eg for reading stage 1 page table entries)
592  // then don't perform the AP permissions check, we stil do the HAP check
593  // below.
594  if (isStage2) {
595  abt = false;
596  } else {
597  switch (ap) {
598  case 0:
599  DPRINTF(TLB, "Access permissions 0, checking rs:%#x\n",
600  (int)sctlr.rs);
601  if (!sctlr.xp) {
602  switch ((int)sctlr.rs) {
603  case 2:
604  abt = is_write;
605  break;
606  case 1:
607  abt = is_write || !is_priv;
608  break;
609  case 0:
610  case 3:
611  default:
612  abt = true;
613  break;
614  }
615  } else {
616  abt = true;
617  }
618  break;
619  case 1:
620  abt = !is_priv;
621  break;
622  case 2:
623  abt = !is_priv && is_write;
624  isWritable = is_priv;
625  break;
626  case 3:
627  abt = false;
628  break;
629  case 4:
630  panic("UNPRED premissions\n");
631  case 5:
632  abt = !is_priv || is_write;
633  isWritable = false;
634  break;
635  case 6:
636  case 7:
637  abt = is_write;
638  isWritable = false;
639  break;
640  default:
641  panic("Unknown permissions %#x\n", ap);
642  }
643  }
644 
645  bool hapAbt = is_write ? !(hap & 2) : !(hap & 1);
646  bool xn = te->xn || (isWritable && sctlr.wxn) ||
647  (ap == 3 && sctlr.uwxn && is_priv);
648  if (is_fetch && (abt || xn ||
649  (te->longDescFormat && te->pxn && is_priv) ||
650  (isSecure && te->ns && scr.sif))) {
651  stats.permsFaults++;
652  DPRINTF(TLB, "TLB Fault: Prefetch abort on permission check. AP:%d "
653  "priv:%d write:%d ns:%d sif:%d sctlr.afe: %d \n",
654  ap, is_priv, is_write, te->ns, scr.sif,sctlr.afe);
655  // Use PC value instead of vaddr because vaddr might be aligned to
656  // cache line and should not be the address reported in FAR
657  return std::make_shared<PrefetchAbort>(
658  req->getPC(),
659  ArmFault::PermissionLL + te->lookupLevel,
660  isStage2, tranMethod);
661  } else if (abt | hapAbt) {
662  stats.permsFaults++;
663  DPRINTF(TLB, "TLB Fault: Data abort on permission check. AP:%d priv:%d"
664  " write:%d\n", ap, is_priv, is_write);
665  return std::make_shared<DataAbort>(
666  vaddr, te->domain, is_write,
667  ArmFault::PermissionLL + te->lookupLevel,
668  isStage2 | !abt, tranMethod);
669  }
670  return NoFault;
671 }
672 
673 
674 Fault
676  ThreadContext *tc)
677 {
678  assert(aarch64);
679 
680  // A data cache maintenance instruction that operates by VA does
681  // not generate a Permission fault unless:
682  // * It is a data cache invalidate (dc ivac) which requires write
683  // permissions to the VA, or
684  // * It is executed from EL0
685  if (req->isCacheClean() && aarch64EL != EL0 && !isStage2) {
686  return NoFault;
687  }
688 
689  Addr vaddr_tainted = req->getVaddr();
690  Addr vaddr = purifyTaggedAddr(vaddr_tainted, tc, aarch64EL, (TCR)ttbcr,
691  mode==Execute);
692 
693  Request::Flags flags = req->getFlags();
694  bool is_fetch = (mode == Execute);
695  // Cache clean operations require read permissions to the specified VA
696  bool is_write = !req->isCacheClean() && mode == Write;
697  bool is_atomic = req->isAtomic();
698  bool is_priv M5_VAR_USED = isPriv && !(flags & UserMode);
699 
701 
702  // If this is the second stage of translation and the request is for a
703  // stage 1 page table walk then we need to check the HCR.PTW bit. This
704  // allows us to generate a fault if the request targets an area marked
705  // as a device or strongly ordered.
706  if (isStage2 && req->isPTWalk() && hcr.ptw &&
707  (te->mtype != TlbEntry::MemoryType::Normal)) {
708  return std::make_shared<DataAbort>(
709  vaddr_tainted, te->domain, is_write,
710  ArmFault::PermissionLL + te->lookupLevel,
712  }
713 
714  // Generate an alignment fault for unaligned accesses to device or
715  // strongly ordered memory
716  if (!is_fetch) {
717  if (te->mtype != TlbEntry::MemoryType::Normal) {
718  if (vaddr & mask(flags & AlignmentMask)) {
719  stats.alignFaults++;
720  return std::make_shared<DataAbort>(
721  vaddr_tainted,
723  is_atomic ? false : is_write,
726  }
727  }
728  }
729 
730  if (te->nonCacheable) {
731  // Prevent prefetching from I/O devices.
732  if (req->isPrefetch()) {
733  // Here we can safely use the fault status for the short
734  // desc. format in all cases
735  return std::make_shared<PrefetchAbort>(
736  vaddr_tainted,
739  }
740  }
741 
742  uint8_t ap = 0x3 & (te->ap); // 2-bit access protection field
743  bool grant = false;
744 
745  bool wxn = sctlr.wxn;
746  uint8_t xn = te->xn;
747  uint8_t pxn = te->pxn;
748  bool r = (!is_write && !is_fetch);
749  bool w = is_write;
750  bool x = is_fetch;
751 
752  if (ArmSystem::haveEL(tc, EL3) && isSecure && te->ns && scr.sif)
753  xn = true;
754 
755  // grant_read is used for faults from an atomic instruction that
756  // both reads and writes from a memory location. From a ISS point
757  // of view they count as read if a read to that address would have
758  // generated the fault; they count as writes otherwise
759  bool grant_read = true;
760  DPRINTF(TLBVerbose, "Checking permissions: ap:%d, xn:%d, pxn:%d, r:%d, "
761  "w:%d, x:%d, is_priv: %d, wxn: %d\n", ap, xn,
762  pxn, r, w, x, is_priv, wxn);
763 
764  if (isStage2) {
765  assert(ArmSystem::haveVirtualization(tc) && aarch64EL != EL2);
766  // In stage 2 we use the hypervisor access permission bits.
767  // The following permissions are described in ARM DDI 0487A.f
768  // D4-1802
769  uint8_t hap = 0x3 & te->hap;
770  grant_read = hap & 0x1;
771  if (is_fetch) {
772  // sctlr.wxn overrides the xn bit
773  grant = !wxn && !xn;
774  } else if (is_atomic) {
775  grant = r && w;
776  grant_read = r;
777  } else if (is_write) {
778  grant = hap & 0x2;
779  } else { // is_read
780  grant = grant_read;
781  }
782  } else {
783  switch (aarch64EL) {
784  case EL0:
785  {
786  grant_read = ap & 0x1;
787  uint8_t perm = (ap << 2) | (xn << 1) | pxn;
788  switch (perm) {
789  case 0:
790  case 1:
791  case 8:
792  case 9:
793  grant = x;
794  break;
795  case 4:
796  case 5:
797  grant = r || w || (x && !wxn);
798  break;
799  case 6:
800  case 7:
801  grant = r || w;
802  break;
803  case 12:
804  case 13:
805  grant = r || x;
806  break;
807  case 14:
808  case 15:
809  grant = r;
810  break;
811  default:
812  grant = false;
813  }
814  }
815  break;
816  case EL1:
817  {
818  if (checkPAN(tc, ap, req, mode)) {
819  grant = false;
820  grant_read = false;
821  break;
822  }
823 
824  uint8_t perm = (ap << 2) | (xn << 1) | pxn;
825  switch (perm) {
826  case 0:
827  case 2:
828  grant = r || w || (x && !wxn);
829  break;
830  case 1:
831  case 3:
832  case 4:
833  case 5:
834  case 6:
835  case 7:
836  // regions that are writeable at EL0 should not be
837  // executable at EL1
838  grant = r || w;
839  break;
840  case 8:
841  case 10:
842  case 12:
843  case 14:
844  grant = r || x;
845  break;
846  case 9:
847  case 11:
848  case 13:
849  case 15:
850  grant = r;
851  break;
852  default:
853  grant = false;
854  }
855  }
856  break;
857  case EL2:
858  if (hcr.e2h && checkPAN(tc, ap, req, mode)) {
859  grant = false;
860  grant_read = false;
861  break;
862  }
864  case EL3:
865  {
866  uint8_t perm = (ap & 0x2) | xn;
867  switch (perm) {
868  case 0:
869  grant = r || w || (x && !wxn);
870  break;
871  case 1:
872  grant = r || w;
873  break;
874  case 2:
875  grant = r || x;
876  break;
877  case 3:
878  grant = r;
879  break;
880  default:
881  grant = false;
882  }
883  }
884  break;
885  }
886  }
887 
888  if (!grant) {
889  if (is_fetch) {
890  stats.permsFaults++;
891  DPRINTF(TLB, "TLB Fault: Prefetch abort on permission check. "
892  "AP:%d priv:%d write:%d ns:%d sif:%d "
893  "sctlr.afe: %d\n",
894  ap, is_priv, is_write, te->ns, scr.sif, sctlr.afe);
895  // Use PC value instead of vaddr because vaddr might be aligned to
896  // cache line and should not be the address reported in FAR
897  return std::make_shared<PrefetchAbort>(
898  req->getPC(),
899  ArmFault::PermissionLL + te->lookupLevel,
901  } else {
902  stats.permsFaults++;
903  DPRINTF(TLB, "TLB Fault: Data abort on permission check. AP:%d "
904  "priv:%d write:%d\n", ap, is_priv, is_write);
905  return std::make_shared<DataAbort>(
906  vaddr_tainted, te->domain,
907  (is_atomic && !grant_read) ? false : is_write,
908  ArmFault::PermissionLL + te->lookupLevel,
910  }
911  }
912 
913  return NoFault;
914 }
915 
916 bool
917 TLB::checkPAN(ThreadContext *tc, uint8_t ap, const RequestPtr &req, Mode mode)
918 {
919  // The PAN bit has no effect on:
920  // 1) Instruction accesses.
921  // 2) Data Cache instructions other than DC ZVA
922  // 3) Address translation instructions, other than ATS1E1RP and
923  // ATS1E1WP when ARMv8.2-ATS1E1 is implemented. (Unimplemented in
924  // gem5)
925  // 4) Unprivileged instructions (Unimplemented in gem5)
926  AA64MMFR1 mmfr1 = tc->readMiscReg(MISCREG_ID_AA64MMFR1_EL1);
927  if (mmfr1.pan && cpsr.pan && (ap & 0x1) && mode != Execute &&
928  (!req->isCacheMaintenance() ||
929  (req->getFlags() & Request::CACHE_BLOCK_ZERO))) {
930  return true;
931  } else {
932  return false;
933  }
934 }
935 
936 Fault
938  TLB::ArmTranslationType tranType, Addr vaddr, bool long_desc_format)
939 {
940  bool is_fetch = (mode == Execute);
941  bool is_atomic = req->isAtomic();
942  req->setPaddr(vaddr);
943  // When the MMU is off the security attribute corresponds to the
944  // security state of the processor
945  if (isSecure)
946  req->setFlags(Request::SECURE);
947 
948  if (aarch64) {
949  bool selbit = bits(vaddr, 55);
950  TCR tcr1 = tc->readMiscReg(MISCREG_TCR_EL1);
951  int topbit = computeAddrTop(tc, selbit, is_fetch, tcr1, currEL(tc));
952  int addr_sz = bits(vaddr, topbit, MaxPhysAddrRange);
953  if (addr_sz != 0){
954  Fault f;
955  if (is_fetch)
956  f = std::make_shared<PrefetchAbort>(vaddr,
958  else
959  f = std::make_shared<DataAbort>( vaddr,
961  is_atomic ? false : mode==Write,
963  return f;
964  }
965  }
966 
967  // @todo: double check this (ARM ARM issue C B3.2.1)
968  if (long_desc_format || sctlr.tre == 0 || nmrr.ir0 == 0 ||
969  nmrr.or0 == 0 || prrr.tr0 != 0x2) {
970  if (!req->isCacheMaintenance()) {
971  req->setFlags(Request::UNCACHEABLE);
972  }
973  req->setFlags(Request::STRICT_ORDER);
974  }
975 
976  // Set memory attributes
977  TlbEntry temp_te;
978  temp_te.ns = !isSecure;
979  bool dc = (HaveVirtHostExt(tc)
980  && hcr.e2h == 1 && hcr.tge == 1) ? 0: hcr.dc;
981  bool i_cacheability = sctlr.i && !sctlr.m;
982  if (isStage2 || !dc || isSecure ||
983  (isHyp && !(tranType & S1CTran))) {
984 
985  temp_te.mtype = is_fetch ? TlbEntry::MemoryType::Normal
987  temp_te.innerAttrs = i_cacheability? 0x2: 0x0;
988  temp_te.outerAttrs = i_cacheability? 0x2: 0x0;
989  temp_te.shareable = true;
990  temp_te.outerShareable = true;
991  } else {
993  temp_te.innerAttrs = 0x3;
994  temp_te.outerAttrs = 0x3;
995  temp_te.shareable = false;
996  temp_te.outerShareable = false;
997  }
998  temp_te.setAttributes(long_desc_format);
999  DPRINTF(TLBVerbose, "(No MMU) setting memory attributes: shareable: "
1000  "%d, innerAttrs: %d, outerAttrs: %d, isStage2: %d\n",
1001  temp_te.shareable, temp_te.innerAttrs, temp_te.outerAttrs,
1002  isStage2);
1003  setAttr(temp_te.attributes);
1004 
1006 }
1007 
1008 Fault
1010  Translation *translation, bool &delay, bool timing,
1011  bool functional, Addr vaddr,
1012  ArmFault::TranMethod tranMethod)
1013 {
1014  TlbEntry *te = NULL;
1015  bool is_fetch = (mode == Execute);
1016  TlbEntry mergeTe;
1017 
1018  Request::Flags flags = req->getFlags();
1019  Addr vaddr_tainted = req->getVaddr();
1020 
1021  Fault fault = getResultTe(&te, req, tc, mode, translation, timing,
1022  functional, &mergeTe);
1023  // only proceed if we have a valid table entry
1024  if ((te == NULL) && (fault == NoFault)) delay = true;
1025 
1026  // If we have the table entry transfer some of the attributes to the
1027  // request that triggered the translation
1028  if (te != NULL) {
1029  // Set memory attributes
1030  DPRINTF(TLBVerbose,
1031  "Setting memory attributes: shareable: %d, innerAttrs: %d, "
1032  "outerAttrs: %d, mtype: %d, isStage2: %d\n",
1033  te->shareable, te->innerAttrs, te->outerAttrs,
1034  static_cast<uint8_t>(te->mtype), isStage2);
1035  setAttr(te->attributes);
1036 
1037  if (te->nonCacheable && !req->isCacheMaintenance())
1038  req->setFlags(Request::UNCACHEABLE);
1039 
1040  // Require requests to be ordered if the request goes to
1041  // strongly ordered or device memory (i.e., anything other
1042  // than normal memory requires strict order).
1043  if (te->mtype != TlbEntry::MemoryType::Normal)
1044  req->setFlags(Request::STRICT_ORDER);
1045 
1046  Addr pa = te->pAddr(vaddr);
1047  req->setPaddr(pa);
1048 
1049  if (isSecure && !te->ns) {
1050  req->setFlags(Request::SECURE);
1051  }
1052  if (!is_fetch && fault == NoFault &&
1053  (vaddr & mask(flags & AlignmentMask)) &&
1054  (te->mtype != TlbEntry::MemoryType::Normal)) {
1055  // Unaligned accesses to Device memory should always cause an
1056  // abort regardless of sctlr.a
1057  stats.alignFaults++;
1058  bool is_write = (mode == Write);
1059  return std::make_shared<DataAbort>(
1060  vaddr_tainted,
1063  tranMethod);
1064  }
1065 
1066  // Check for a trickbox generated address fault
1067  if (fault == NoFault)
1068  fault = testTranslation(req, mode, te->domain);
1069  }
1070 
1071  if (fault == NoFault) {
1072  // Don't try to finalize a physical address unless the
1073  // translation has completed (i.e., there is a table entry).
1074  return te ? finalizePhysical(req, tc, mode) : NoFault;
1075  } else {
1076  return fault;
1077  }
1078 }
1079 
1080 Fault
1082  Translation *translation, bool &delay, bool timing,
1083  TLB::ArmTranslationType tranType, bool functional)
1084 {
1085  // No such thing as a functional timing access
1086  assert(!(timing && functional));
1087 
1088  updateMiscReg(tc, tranType);
1089 
1090  Addr vaddr_tainted = req->getVaddr();
1091  Addr vaddr = 0;
1092  if (aarch64)
1093  vaddr = purifyTaggedAddr(vaddr_tainted, tc, aarch64EL, (TCR)ttbcr,
1094  mode==Execute);
1095  else
1096  vaddr = vaddr_tainted;
1097  Request::Flags flags = req->getFlags();
1098 
1099  bool is_fetch = (mode == Execute);
1100  bool is_write = (mode == Write);
1101  bool long_desc_format = aarch64 || longDescFormatInUse(tc);
1102  ArmFault::TranMethod tranMethod = long_desc_format ? ArmFault::LpaeTran
1104 
1105  DPRINTF(TLBVerbose,
1106  "CPSR is priv:%d UserMode:%d secure:%d S1S2NsTran:%d\n",
1107  isPriv, flags & UserMode, isSecure, tranType & S1S2NsTran);
1108 
1109  DPRINTF(TLB, "translateFs addr %#x, mode %d, st2 %d, scr %#x sctlr %#x "
1110  "flags %#lx tranType 0x%x\n", vaddr_tainted, mode, isStage2,
1111  scr, sctlr, flags, tranType);
1112 
1113  if ((req->isInstFetch() && (!sctlr.i)) ||
1114  ((!req->isInstFetch()) && (!sctlr.c))){
1115  if (!req->isCacheMaintenance()) {
1116  req->setFlags(Request::UNCACHEABLE);
1117  }
1118  req->setFlags(Request::STRICT_ORDER);
1119  }
1120  if (!is_fetch) {
1121  if (sctlr.a || !(flags & AllowUnaligned)) {
1122  if (vaddr & mask(flags & AlignmentMask)) {
1123  stats.alignFaults++;
1124  return std::make_shared<DataAbort>(
1125  vaddr_tainted,
1128  tranMethod);
1129  }
1130  }
1131  }
1132 
1133  bool vm = hcr.vm;
1134  if (HaveVirtHostExt(tc) && hcr.e2h == 1 && hcr.tge ==1)
1135  vm = 0;
1136  else if (hcr.dc == 1)
1137  vm = 1;
1138 
1139  Fault fault = NoFault;
1140  // If guest MMU is off or hcr.vm=0 go straight to stage2
1141  if ((isStage2 && !vm) || (!isStage2 && !sctlr.m)) {
1142  fault = translateMmuOff(tc, req, mode, tranType, vaddr,
1143  long_desc_format);
1144  } else {
1145  DPRINTF(TLBVerbose, "Translating %s=%#x context=%d\n",
1146  isStage2 ? "IPA" : "VA", vaddr_tainted, asid);
1147  // Translation enabled
1148  fault = translateMmuOn(tc, req, mode, translation, delay, timing,
1149  functional, vaddr, tranMethod);
1150  }
1151 
1152  // Check for Debug Exceptions
1154 
1155  if (sd->enabled() && fault == NoFault) {
1156  fault = sd->testDebug(tc, req, mode);
1157  }
1158 
1159  return fault;
1160 }
1161 
1162 Fault
1164  TLB::ArmTranslationType tranType)
1165 {
1166  updateMiscReg(tc, tranType);
1167 
1168  if (directToStage2) {
1169  assert(stage2Tlb);
1170  return stage2Tlb->translateAtomic(req, tc, mode, tranType);
1171  }
1172 
1173  bool delay = false;
1174  Fault fault;
1175  if (FullSystem)
1176  fault = translateFs(req, tc, mode, NULL, delay, false, tranType);
1177  else
1178  fault = translateSe(req, tc, mode, NULL, delay, false);
1179  assert(!delay);
1180  return fault;
1181 }
1182 
1183 Fault
1185  TLB::ArmTranslationType tranType)
1186 {
1187  updateMiscReg(tc, tranType);
1188 
1189  if (directToStage2) {
1190  assert(stage2Tlb);
1191  return stage2Tlb->translateFunctional(req, tc, mode, tranType);
1192  }
1193 
1194  bool delay = false;
1195  Fault fault;
1196  if (FullSystem)
1197  fault = translateFs(req, tc, mode, NULL, delay, false, tranType, true);
1198  else
1199  fault = translateSe(req, tc, mode, NULL, delay, false);
1200  assert(!delay);
1201  return fault;
1202 }
1203 
1204 void
1206  Translation *translation, Mode mode, TLB::ArmTranslationType tranType)
1207 {
1208  updateMiscReg(tc, tranType);
1209 
1210  if (directToStage2) {
1211  assert(stage2Tlb);
1212  stage2Tlb->translateTiming(req, tc, translation, mode, tranType);
1213  return;
1214  }
1215 
1216  assert(translation);
1217 
1218  translateComplete(req, tc, translation, mode, tranType, isStage2);
1219 }
1220 
1221 Fault
1223  Translation *translation, Mode mode, TLB::ArmTranslationType tranType,
1224  bool callFromS2)
1225 {
1226  bool delay = false;
1227  Fault fault;
1228  if (FullSystem)
1229  fault = translateFs(req, tc, mode, translation, delay, true, tranType);
1230  else
1231  fault = translateSe(req, tc, mode, translation, delay, true);
1232  DPRINTF(TLBVerbose, "Translation returning delay=%d fault=%d\n", delay, fault !=
1233  NoFault);
1234  // If we have a translation, and we're not in the middle of doing a stage
1235  // 2 translation tell the translation that we've either finished or its
1236  // going to take a while. By not doing this when we're in the middle of a
1237  // stage 2 translation we prevent marking the translation as delayed twice,
1238  // one when the translation starts and again when the stage 1 translation
1239  // completes.
1240 
1241  if (translation && (callFromS2 || !stage2Req || req->hasPaddr() ||
1242  fault != NoFault)) {
1243  if (!delay)
1244  translation->finish(fault, req, tc, mode);
1245  else
1246  translation->markDelayed();
1247  }
1248  return fault;
1249 }
1250 
1251 Port *
1253 {
1254  return &stage2Mmu->getDMAPort();
1255 }
1256 
1257 void
1259 {
1260  // check if the regs have changed, or the translation mode is different.
1261  // NOTE: the tran type doesn't affect stage 2 TLB's as they only handle
1262  // one type of translation anyway
1263  if (miscRegValid && miscRegContext == tc->contextId() &&
1264  ((tranType == curTranType) || isStage2)) {
1265  return;
1266  }
1267 
1268  DPRINTF(TLBVerbose, "TLB variables changed!\n");
1269  cpsr = tc->readMiscReg(MISCREG_CPSR);
1270 
1271  // Dependencies: SCR/SCR_EL3, CPSR
1272  isSecure = ArmISA::isSecure(tc) &&
1273  !(tranType & HypMode) && !(tranType & S1S2NsTran);
1274 
1275  aarch64EL = tranTypeEL(cpsr, tranType);
1276  aarch64 = isStage2 ?
1277  ELIs64(tc, EL2) :
1278  ELIs64(tc, aarch64EL == EL0 ? EL1 : aarch64EL);
1279 
1281  if (aarch64) { // AArch64
1282  // determine EL we need to translate in
1283  switch (aarch64EL) {
1284  case EL0:
1285  if (HaveVirtHostExt(tc) && hcr.tge == 1 && hcr.e2h == 1) {
1286  // VHE code for EL2&0 regime
1289  uint64_t ttbr_asid = ttbcr.a1 ?
1292  asid = bits(ttbr_asid,
1293  (haveLargeAsid64 && ttbcr.as) ? 63 : 55, 48);
1294 
1295  } else {
1298  uint64_t ttbr_asid = ttbcr.a1 ?
1301  asid = bits(ttbr_asid,
1302  (haveLargeAsid64 && ttbcr.as) ? 63 : 55, 48);
1303 
1304  }
1305  break;
1306  case EL1:
1307  {
1310  uint64_t ttbr_asid = ttbcr.a1 ?
1313  asid = bits(ttbr_asid,
1314  (haveLargeAsid64 && ttbcr.as) ? 63 : 55, 48);
1315  }
1316  break;
1317  case EL2:
1320  if (hcr.e2h == 1) {
1321  // VHE code for EL2&0 regime
1322  uint64_t ttbr_asid = ttbcr.a1 ?
1325  asid = bits(ttbr_asid,
1326  (haveLargeAsid64 && ttbcr.as) ? 63 : 55, 48);
1327  } else {
1328  asid = -1;
1329  }
1330  break;
1331  case EL3:
1334  asid = -1;
1335  break;
1336  }
1337 
1339  isPriv = aarch64EL != EL0;
1340  if (haveVirtualization) {
1341  vmid = bits(tc->readMiscReg(MISCREG_VTTBR_EL2), 55, 48);
1342  isHyp = aarch64EL == EL2;
1343  isHyp |= tranType & HypMode;
1344  isHyp &= (tranType & S1S2NsTran) == 0;
1345  isHyp &= (tranType & S1CTran) == 0;
1346  bool vm = hcr.vm;
1347  if (HaveVirtHostExt(tc) && hcr.e2h == 1 && hcr.tge ==1) {
1348  vm = 0;
1349  }
1350 
1351  if (hcr.e2h == 1 && (aarch64EL == EL2
1352  || (hcr.tge ==1 && aarch64EL == EL0))) {
1353  isHyp = true;
1354  directToStage2 = false;
1355  stage2Req = false;
1356  stage2DescReq = false;
1357  } else {
1358  // Work out if we should skip the first stage of translation and go
1359  // directly to stage 2. This value is cached so we don't have to
1360  // compute it for every translation.
1361  bool sec = !isSecure || (isSecure && IsSecureEL2Enabled(tc));
1362  stage2Req = isStage2 ||
1363  (vm && !isHyp && sec &&
1364  !(tranType & S1CTran) && (aarch64EL < EL2) &&
1365  !(tranType & S1E1Tran)); // <--- FIX THIS HACK
1366  stage2DescReq = isStage2 || (vm && !isHyp && sec &&
1367  (aarch64EL < EL2));
1368  directToStage2 = !isStage2 && stage2Req && !sctlr.m;
1369  }
1370  } else {
1371  vmid = 0;
1372  isHyp = false;
1373  directToStage2 = false;
1374  stage2Req = false;
1375  stage2DescReq = false;
1376  }
1377  } else { // AArch32
1379  !isSecure));
1381  !isSecure));
1382  scr = tc->readMiscReg(MISCREG_SCR);
1383  isPriv = cpsr.mode != MODE_USER;
1384  if (longDescFormatInUse(tc)) {
1385  uint64_t ttbr_asid = tc->readMiscReg(
1387  MISCREG_TTBR0,
1388  tc, !isSecure));
1389  asid = bits(ttbr_asid, 55, 48);
1390  } else { // Short-descriptor translation table format in use
1391  CONTEXTIDR context_id = tc->readMiscReg(snsBankedIndex(
1393  asid = context_id.asid;
1394  }
1396  !isSecure));
1398  !isSecure));
1400  !isSecure));
1401  hcr = tc->readMiscReg(MISCREG_HCR);
1402 
1403  if (haveVirtualization) {
1404  vmid = bits(tc->readMiscReg(MISCREG_VTTBR), 55, 48);
1405  isHyp = cpsr.mode == MODE_HYP;
1406  isHyp |= tranType & HypMode;
1407  isHyp &= (tranType & S1S2NsTran) == 0;
1408  isHyp &= (tranType & S1CTran) == 0;
1409  if (isHyp) {
1411  }
1412  // Work out if we should skip the first stage of translation and go
1413  // directly to stage 2. This value is cached so we don't have to
1414  // compute it for every translation.
1415  bool sec = !isSecure || (isSecure && IsSecureEL2Enabled(tc));
1416  stage2Req = hcr.vm && !isStage2 && !isHyp && sec &&
1417  !(tranType & S1CTran);
1418  stage2DescReq = hcr.vm && !isStage2 && !isHyp && sec;
1419  directToStage2 = stage2Req && !sctlr.m;
1420  } else {
1421  vmid = 0;
1422  stage2Req = false;
1423  isHyp = false;
1424  directToStage2 = false;
1425  stage2DescReq = false;
1426  }
1427  }
1428  miscRegValid = true;
1429  miscRegContext = tc->contextId();
1430  curTranType = tranType;
1431 }
1432 
1435 {
1436  switch (type) {
1437  case S1E0Tran:
1438  case S12E0Tran:
1439  return EL0;
1440 
1441  case S1E1Tran:
1442  case S12E1Tran:
1443  return EL1;
1444 
1445  case S1E2Tran:
1446  return EL2;
1447 
1448  case S1E3Tran:
1449  return EL3;
1450 
1451  case NormalTran:
1452  case S1CTran:
1453  case S1S2NsTran:
1454  case HypMode:
1455  return currEL(cpsr);
1456 
1457  default:
1458  panic("Unknown translation mode!\n");
1459  }
1460 }
1461 
1462 Fault
1464  Translation *translation, bool timing, bool functional,
1465  bool is_secure, TLB::ArmTranslationType tranType)
1466 {
1467  // In a 2-stage system, the IPA->PA translation can be started via this
1468  // call so make sure the miscRegs are correct.
1469  if (isStage2) {
1470  updateMiscReg(tc, tranType);
1471  }
1472  bool is_fetch = (mode == Execute);
1473  bool is_write = (mode == Write);
1474 
1475  Addr vaddr_tainted = req->getVaddr();
1476  Addr vaddr = 0;
1477  ExceptionLevel target_el = aarch64 ? aarch64EL : EL1;
1478  if (aarch64) {
1479  vaddr = purifyTaggedAddr(vaddr_tainted, tc, target_el, (TCR)ttbcr,
1480  mode==Execute);
1481  } else {
1482  vaddr = vaddr_tainted;
1483  }
1484  *te = lookup(vaddr, asid, vmid, isHyp, is_secure, false, false, target_el,
1485  false);
1486  if (*te == NULL) {
1487  if (req->isPrefetch()) {
1488  // if the request is a prefetch don't attempt to fill the TLB or go
1489  // any further with the memory access (here we can safely use the
1490  // fault status for the short desc. format in all cases)
1492  return std::make_shared<PrefetchAbort>(
1493  vaddr_tainted, ArmFault::PrefetchTLBMiss, isStage2);
1494  }
1495 
1496  if (is_fetch)
1497  stats.instMisses++;
1498  else if (is_write)
1499  stats.writeMisses++;
1500  else
1501  stats.readMisses++;
1502 
1503  // start translation table walk, pass variables rather than
1504  // re-retreaving in table walker for speed
1505  DPRINTF(TLB, "TLB Miss: Starting hardware table walker for %#x(%d:%d)\n",
1506  vaddr_tainted, asid, vmid);
1507  Fault fault;
1508  fault = tableWalker->walk(req, tc, asid, vmid, isHyp, mode,
1509  translation, timing, functional, is_secure,
1510  tranType, stage2DescReq);
1511  // for timing mode, return and wait for table walk,
1512  if (timing || fault != NoFault) {
1513  return fault;
1514  }
1515 
1516  *te = lookup(vaddr, asid, vmid, isHyp, is_secure, false, false,
1517  target_el, false);
1518  if (!*te)
1519  printTlb();
1520  assert(*te);
1521  } else {
1522  if (is_fetch)
1523  stats.instHits++;
1524  else if (is_write)
1525  stats.writeHits++;
1526  else
1527  stats.readHits++;
1528  }
1529  return NoFault;
1530 }
1531 
1532 Fault
1534  ThreadContext *tc, Mode mode,
1535  Translation *translation, bool timing, bool functional,
1536  TlbEntry *mergeTe)
1537 {
1538  Fault fault;
1539 
1540  if (isStage2) {
1541  // We are already in the stage 2 TLB. Grab the table entry for stage
1542  // 2 only. We are here because stage 1 translation is disabled.
1543  TlbEntry *s2Te = NULL;
1544  // Get the stage 2 table entry
1545  fault = getTE(&s2Te, req, tc, mode, translation, timing, functional,
1547  // Check permissions of stage 2
1548  if ((s2Te != NULL) && (fault == NoFault)) {
1549  if (aarch64)
1550  fault = checkPermissions64(s2Te, req, mode, tc);
1551  else
1552  fault = checkPermissions(s2Te, req, mode);
1553  }
1554  *te = s2Te;
1555  return fault;
1556  }
1557 
1558  TlbEntry *s1Te = NULL;
1559 
1560  Addr vaddr_tainted = req->getVaddr();
1561 
1562  // Get the stage 1 table entry
1563  fault = getTE(&s1Te, req, tc, mode, translation, timing, functional,
1565  // only proceed if we have a valid table entry
1566  if ((s1Te != NULL) && (fault == NoFault)) {
1567  // Check stage 1 permissions before checking stage 2
1568  if (aarch64)
1569  fault = checkPermissions64(s1Te, req, mode, tc);
1570  else
1571  fault = checkPermissions(s1Te, req, mode);
1572  if (stage2Req & (fault == NoFault)) {
1573  Stage2LookUp *s2Lookup = new Stage2LookUp(this, stage2Tlb, *s1Te,
1574  req, translation, mode, timing, functional, isSecure,
1575  curTranType);
1576  fault = s2Lookup->getTe(tc, mergeTe);
1577  if (s2Lookup->isComplete()) {
1578  *te = mergeTe;
1579  // We've finished with the lookup so delete it
1580  delete s2Lookup;
1581  } else {
1582  // The lookup hasn't completed, so we can't delete it now. We
1583  // get round this by asking the object to self delete when the
1584  // translation is complete.
1585  s2Lookup->setSelfDelete();
1586  }
1587  } else {
1588  // This case deals with an S1 hit (or bypass), followed by
1589  // an S2 hit-but-perms issue
1590  if (isStage2) {
1591  DPRINTF(TLBVerbose, "s2TLB: reqVa %#x, reqPa %#x, fault %p\n",
1592  vaddr_tainted, req->hasPaddr() ? req->getPaddr() : ~0, fault);
1593  if (fault != NoFault) {
1594  ArmFault *armFault = reinterpret_cast<ArmFault *>(fault.get());
1595  armFault->annotate(ArmFault::S1PTW, false);
1596  armFault->annotate(ArmFault::OVA, vaddr_tainted);
1597  }
1598  }
1599  *te = s1Te;
1600  }
1601  }
1602  return fault;
1603 }
1604 
1605 void
1607 {
1608  if (!_ti) {
1609  test = nullptr;
1610  } else {
1611  TlbTestInterface *ti(dynamic_cast<TlbTestInterface *>(_ti));
1612  fatal_if(!ti, "%s is not a valid ARM TLB tester\n", _ti->name());
1613  test = ti;
1614  }
1615 }
1616 
1617 Fault
1620 {
1621  if (!test || !req->hasSize() || req->getSize() == 0 ||
1622  req->isCacheMaintenance()) {
1623  return NoFault;
1624  } else {
1625  return test->translationCheck(req, isPriv, mode, domain);
1626  }
1627 }
1628 
1629 Fault
1631  TlbEntry::DomainType domain, LookupLevel lookup_level)
1632 {
1633  if (!test) {
1634  return NoFault;
1635  } else {
1636  return test->walkCheck(pa, size, va, is_secure, isPriv, mode,
1637  domain, lookup_level);
1638  }
1639 }
1640 
1641 
1642 ArmISA::TLB *
1643 ArmTLBParams::create()
1644 {
1645  return new ArmISA::TLB(this);
1646 }
ArmISA::SelfDebug
Definition: self_debug.hh:273
ArmISA::TLB::flushIpaVmid
void flushIpaVmid(Addr ipa, bool secure_lookup, ExceptionLevel target_el)
Invalidate all entries in the stage 2 TLB that match the given ipa and the current VMID.
Definition: tlb.cc:379
BaseTLB::Translation::finish
virtual void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, Mode mode)=0
ArmISA::TableWalker::walk
Fault walk(const RequestPtr &req, ThreadContext *tc, uint16_t asid, uint8_t _vmid, bool _isHyp, TLB::Mode mode, TLB::Translation *_trans, bool timing, bool functional, bool secure, TLB::ArmTranslationType tranType, bool _stage2Req)
Definition: table_walker.cc:189
ArmISA::TLB::flushAllSecurity
void flushAllSecurity(bool secure_lookup, ExceptionLevel target_el, bool ignore_el=false, bool in_host=false)
Reset the entire TLB.
Definition: tlb.cc:248
ArmISA::LookupLevel
LookupLevel
Definition: pagetable.hh:72
ArmISA::ns
Bitfield< 0 > ns
Definition: miscregs_types.hh:328
ArmISA::TLB::TlbStats::instMisses
Stats::Scalar instMisses
Definition: tlb.hh:168
ArmISA::MODE_HYP
@ MODE_HYP
Definition: types.hh:642
ArmISA::computeAddrTop
int computeAddrTop(ThreadContext *tc, bool selbit, bool isInstr, TCR tcr, ExceptionLevel el)
Definition: utility.cc:513
ArmISA::Stage2MMU::stage2Tlb
TLB * stage2Tlb() const
Definition: stage2_mmu.hh:121
ArmISA::TLB::ttbcr
TTBCR ttbcr
Definition: tlb.hh:419
ArmISA::EL2
@ EL2
Definition: types.hh:624
ArmISA::TLB::setTestInterface
void setTestInterface(SimObject *ti)
Definition: tlb.cc:1606
ArmISA::TLB::UserMode
@ UserMode
Definition: tlb.hh:115
ArmISA::MISCREG_TTBR0
@ MISCREG_TTBR0
Definition: miscregs.hh:248
ArmISA::HaveVirtHostExt
bool HaveVirtHostExt(ThreadContext *tc)
Definition: utility.cc:326
ArmISA::TlbEntry::global
bool global
Definition: pagetable.hh:123
MipsISA::ti
Bitfield< 30 > ti
Definition: pra_constants.hh:176
BaseTLB::Read
@ Read
Definition: tlb.hh:57
ArmISA::TLB::isStage2
bool isStage2
Definition: tlb.hh:147
MipsISA::pfn
Bitfield< 29, 6 > pfn
Definition: pra_constants.hh:55
ArmISA::ArmFault::VmsaTran
@ VmsaTran
Definition: faults.hh:149
ArmISA::TlbEntry::ap
uint8_t ap
Definition: pagetable.hh:113
ArmISA::TLB::translateFs
Fault translateFs(const RequestPtr &req, ThreadContext *tc, Mode mode, Translation *translation, bool &delay, bool timing, ArmTranslationType tranType, bool functional=false)
Definition: tlb.cc:1081
ArmISA::TLB::lookup
TlbEntry * lookup(Addr vpn, uint16_t asn, uint8_t vmid, bool hyp, bool secure, bool functional, bool ignore_asn, ExceptionLevel target_el, bool in_host)
Lookup an entry in the TLB.
Definition: tlb.cc:159
ArmISA::TLB::translateSe
Fault translateSe(const RequestPtr &req, ThreadContext *tc, Mode mode, Translation *translation, bool &delay, bool timing)
Definition: tlb.cc:457
ArmISA::TLB::translateMmuOn
Fault translateMmuOn(ThreadContext *tc, const RequestPtr &req, Mode mode, Translation *translation, bool &delay, bool timing, bool functional, Addr vaddr, ArmFault::TranMethod tranMethod)
Definition: tlb.cc:1009
ArmISA::TLB::ArmTranslationType
ArmTranslationType
Definition: tlb.hh:118
ArmISA::TLB::printTlb
void printTlb() const
Definition: tlb.cc:234
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
Process
Definition: process.hh:65
ArmISA::EL0
@ EL0
Definition: types.hh:622
test
Definition: test.h:38
ArmISA::TLB::finalizePhysical
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:135
ArmISA::TlbEntry::N
uint8_t N
Definition: pagetable.hh:110
ArmISA::TlbEntry::el
ExceptionLevel el
Definition: pagetable.hh:131
ArmISA::TableWalker::haveLPAE
bool haveLPAE() const
Definition: table_walker.hh:896
Flags< FlagsType >
System::m5opRange
const AddrRange & m5opRange() const
Range used by memory-mapped m5 pseudo-ops if enabled.
Definition: system.hh:585
ArmISA::snsBankedIndex
int snsBankedIndex(MiscRegIndex reg, ThreadContext *tc)
Definition: miscregs.cc:1311
ArmISA::TLB::TlbStats::prefetchFaults
Stats::Scalar prefetchFaults
Definition: tlb.hh:180
ArmISA::TLB::TlbStats::flushTlbAsid
Stats::Scalar flushTlbAsid
Definition: tlb.hh:177
ArmISA::TLB::TlbStats::domainFaults
Stats::Scalar domainFaults
Definition: tlb.hh:181
pagetable.hh
ArmISA::MISCREG_TTBR0_EL1
@ MISCREG_TTBR0_EL1
Definition: miscregs.hh:589
ArmISA::ArmFault::AlignmentFault
@ AlignmentFault
Definition: faults.hh:93
ArmISA::currEL
static ExceptionLevel currEL(const ThreadContext *tc)
Definition: utility.hh:143
ArmISA::TLB::size
int size
Definition: tlb.hh:146
ArmISA::MISCREG_VTTBR_EL2
@ MISCREG_VTTBR_EL2
Definition: miscregs.hh:597
ArmISA::TlbTestInterface
Definition: tlb.hh:64
ArmISA::ArmFault::S1PTW
@ S1PTW
Definition: faults.hh:130
ArmISA::TLB::TlbStats::flushTlb
Stats::Scalar flushTlb
Definition: tlb.hh:174
ArmISA::TableWalker::haveLargeAsid64
bool haveLargeAsid64() const
Definition: table_walker.hh:898
ArmISA::ArmFault::PrefetchUncacheable
@ PrefetchUncacheable
Definition: faults.hh:113
ArmISA::te
Bitfield< 30 > te
Definition: miscregs_types.hh:334
type
uint8_t type
Definition: inet.hh:421
BaseTLB::Mode
Mode
Definition: tlb.hh:57
ProbePointArg
ProbePointArg generates a point for the class of Arg.
Definition: thermal_domain.hh:50
ArmISA::TLB::sctlr
SCTLR sctlr
Definition: tlb.hh:414
ArmISA::TLB::TlbStats::writeMisses
Stats::Scalar writeMisses
Definition: tlb.hh:172
ArmISA::TLB::HypMode
@ HypMode
Definition: tlb.hh:121
ArmISA::TLB::setAttr
void setAttr(uint64_t attr)
Accessor functions for memory attributes for last accessed TLB entry.
Definition: tlb.hh:343
ArmISA::TLB::drainResume
void drainResume() override
Resume execution after a successful drain.
Definition: tlb.cc:386
AddrRange::contains
bool contains(const Addr &a) const
Determine if the range contains an address.
Definition: addr_range.hh:435
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
ArmISA::TLB::stats
ArmISA::TLB::TlbStats stats
tlb.hh
ArmISA::TlbEntry::ns
bool ns
Definition: pagetable.hh:127
ArmISA::EL3
@ EL3
Definition: types.hh:625
PseudoInst::decodeAddrOffset
static void decodeAddrOffset(Addr offset, uint8_t &func)
Definition: pseudo_inst.hh:81
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
ArmISA::TLB::table
TlbEntry * table
Definition: tlb.hh:145
ArmISA::MISCREG_TCR_EL2
@ MISCREG_TCR_EL2
Definition: miscregs.hh:596
ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
ArmISA::TLB::S1S2NsTran
@ S1S2NsTran
Definition: tlb.hh:124
ArmISA::TLB::TlbStats::flushTlbMva
Stats::Scalar flushTlbMva
Definition: tlb.hh:175
ArmISA::TLB::TlbStats::permsFaults
Stats::Scalar permsFaults
Definition: tlb.hh:182
stage2_mmu.hh
ArmISA::TLB::nmrr
NMRR nmrr
Definition: tlb.hh:423
system.hh
ArmISA::TLB::haveVirtualization
bool haveVirtualization
Definition: tlb.hh:432
ArmISA::Stage2LookUp::isComplete
bool isComplete() const
Definition: stage2_lookup.hh:94
ArmISA::Stage2MMU
Definition: stage2_mmu.hh:50
table_walker.hh
ArmISA::TLB::TlbStats::readMisses
Stats::Scalar readMisses
Definition: tlb.hh:170
ArmISA
Definition: ccregs.hh:41
ArmISA::MISCREG_TCR_EL3
@ MISCREG_TCR_EL3
Definition: miscregs.hh:602
ArmSystem::haveVirtualization
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Definition: system.hh:170
ArmISA::TLB::stage2DescReq
bool stage2DescReq
Definition: tlb.hh:152
request.hh
BaseTLB
Definition: tlb.hh:50
ArmISA::TLB::miscRegContext
ContextID miscRegContext
Definition: tlb.hh:427
ArmISA::ELIs64
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:377
ArmISA::TLB::stage2Req
bool stage2Req
Definition: tlb.hh:148
ArmISA::TLB::_flushMva
void _flushMva(Addr mva, uint64_t asn, bool secure_lookup, bool ignore_asn, ExceptionLevel target_el, bool in_host)
Remove any entries that match both a va and asn.
Definition: tlb.cc:356
ArmISA::IsSecureEL2Enabled
bool IsSecureEL2Enabled(ThreadContext *tc)
Definition: utility.cc:355
ArmISA::aarch64
Bitfield< 34 > aarch64
Definition: types.hh:90
str.hh
ArmISA::TLB::translateMmuOff
Fault translateMmuOff(ThreadContext *tc, const RequestPtr &req, Mode mode, TLB::ArmTranslationType tranType, Addr vaddr, bool long_desc_format)
Definition: tlb.cc:937
ArmISA::TLB::_attr
uint64_t _attr
Definition: tlb.hh:153
ArmISA::TlbEntry::innerAttrs
uint8_t innerAttrs
Definition: pagetable.hh:111
RequestorID
uint16_t RequestorID
Definition: request.hh:85
ArmISA::TLB::checkPermissions64
Fault checkPermissions64(TlbEntry *te, const RequestPtr &req, Mode mode, ThreadContext *tc)
Definition: tlb.cc:675
ArmISA::TLB::S1CTran
@ S1CTran
Definition: tlb.hh:120
pseudo_inst.hh
ArmISA::TLB::regProbePoints
void regProbePoints() override
Register probe points for this object.
Definition: tlb.cc:451
Request::STRICT_ORDER
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
Definition: request.hh:124
ArmISA::TLB::curTranType
ArmTranslationType curTranType
Definition: tlb.hh:428
ArmISA::TLB::S12E0Tran
@ S12E0Tran
Definition: tlb.hh:133
ArmISA::MISCREG_CONTEXTIDR
@ MISCREG_CONTEXTIDR
Definition: miscregs.hh:393
ArmISA::ArmFault::annotate
virtual void annotate(AnnotationIDs id, uint64_t val)
Definition: faults.hh:233
Request::CACHE_BLOCK_ZERO
@ CACHE_BLOCK_ZERO
This is a write that is targeted and zeroing an entire cache block.
Definition: request.hh:132
ArmISA::ArmFault::LpaeTran
@ LpaeTran
Definition: faults.hh:148
ArmISA::TLB::TlbStats::TlbStats
TlbStats(Stats::Group *parent)
Definition: tlb.cc:417
ArmISA::TlbEntry::attributes
uint64_t attributes
Definition: pagetable.hh:101
ArmISA::TLB::stage2Tlb
TLB * stage2Tlb
Definition: tlb.hh:158
Request::SECURE
@ SECURE
The request targets the secure memory space.
Definition: request.hh:173
ArmISA::TLB::AllowUnaligned
@ AllowUnaligned
Definition: tlb.hh:113
ArmISA::TLB::TlbStats::writeHits
Stats::Scalar writeHits
Definition: tlb.hh:171
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ArmISA::TLB::~TLB
virtual ~TLB()
Definition: tlb.cc:97
ArmISA::Stage2MMU::getDMAPort
DmaPort & getDMAPort()
Get the port that ultimately belongs to the stage-two MMU, but is used by the two table walkers,...
Definition: stage2_mmu.hh:112
MipsISA::w
Bitfield< 0 > w
Definition: pra_constants.hh:278
ArmISA::ArmFault
Definition: faults.hh:60
ArmISA::TLB::S1E2Tran
@ S1E2Tran
Definition: tlb.hh:131
ArmISA::TlbEntry::mtype
MemoryType mtype
Definition: pagetable.hh:117
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
ArmISA::MISCREG_HCR
@ MISCREG_HCR
Definition: miscregs.hh:242
ADD_STAT
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition: group.hh:67
ArmISA::TLB::TlbStats::inserts
Stats::Scalar inserts
Definition: tlb.hh:173
ArmISA::TLB::aarch64EL
ExceptionLevel aarch64EL
Definition: tlb.hh:413
ArmISA::TlbEntry::MemoryType::StronglyOrdered
@ StronglyOrdered
ArmISA::ExceptionLevel
ExceptionLevel
Definition: types.hh:621
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
MipsISA::vaddr
vaddr
Definition: pra_constants.hh:275
ArmISA::TLB::flushMva
void flushMva(Addr mva, bool secure_lookup, ExceptionLevel target_el, bool in_host=false)
Remove all entries that match the va regardless of asn.
Definition: tlb.cc:346
ArmISA::ArmFault::AddressSizeLL
@ AddressSizeLL
Definition: faults.hh:107
ArmISA::MaxPhysAddrRange
const unsigned MaxPhysAddrRange
Definition: pagetable.hh:54
ArmISA::MISCREG_ID_AA64MMFR1_EL1
@ MISCREG_ID_AA64MMFR1_EL1
Definition: miscregs.hh:562
isa.hh
ArmISA::Stage2LookUp
Definition: stage2_lookup.hh:55
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
MipsISA::r
r
Definition: pra_constants.hh:95
ArmISA::MISCREG_TCR_EL1
@ MISCREG_TCR_EL1
Definition: miscregs.hh:593
process.hh
stage2_lookup.hh
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
ArmISA::TLB::isSecure
bool isSecure
Definition: tlb.hh:417
ArmISA::el
Bitfield< 3, 2 > el
Definition: miscregs_types.hh:69
ArmISA::TlbEntry::pfn
Addr pfn
Definition: pagetable.hh:98
ArmISA::TLB::S1E0Tran
@ S1E0Tran
Definition: tlb.hh:129
ArmISA::MISCREG_TTBCR
@ MISCREG_TTBCR
Definition: miscregs.hh:254
ArmISA::TLB::isHyp
bool isHyp
Definition: tlb.hh:418
ArmISA::sd
Bitfield< 4 > sd
Definition: miscregs_types.hh:768
ArmISA::TLB::AlignmentMask
@ AlignmentMask
Definition: tlb.hh:104
BaseTLB::Translation
Definition: tlb.hh:59
ArmISA::TLB::checkPermissions
Fault checkPermissions(TlbEntry *te, const RequestPtr &req, Mode mode)
Definition: tlb.cc:497
M5_FALLTHROUGH
#define M5_FALLTHROUGH
Definition: compiler.hh:84
ThreadContext::contextId
virtual ContextID contextId() const =0
ArmISA::TLB::tranTypeEL
static ExceptionLevel tranTypeEL(CPSR cpsr, ArmTranslationType type)
Determine the EL to use for the purpose of a translation given a specific translation type.
Definition: tlb.cc:1434
ArmISA::TlbEntry::shareable
bool shareable
Definition: pagetable.hh:137
ArmISA::TlbEntry::pAddr
Addr pAddr(Addr va) const
Definition: pagetable.hh:236
ArmISA::TLB::rangeMRU
int rangeMRU
Definition: tlb.hh:195
ArmISA::MISCREG_TTBR0_EL2
@ MISCREG_TTBR0_EL2
Definition: miscregs.hh:595
ArmISA::TableWalker::haveVirtualization
bool haveVirtualization() const
Definition: table_walker.hh:897
RiscvISA::perm
Bitfield< 3, 1 > perm
Definition: pagetable.hh:68
ArmISA::MISCREG_DACR
@ MISCREG_DACR
Definition: miscregs.hh:259
Request::UNCACHEABLE
@ UNCACHEABLE
The request is to an uncacheable address.
Definition: request.hh:114
ArmISA::TlbEntry::setAttributes
void setAttributes(bool lpae)
Definition: pagetable.hh:284
inifile.hh
ArmISA::TlbEntry::vmid
uint8_t vmid
Definition: pagetable.hh:109
ArmISA::TLB::TlbStats::flushedEntries
Stats::Scalar flushedEntries
Definition: tlb.hh:178
RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:69
ArmISA::TLB::vmid
uint8_t vmid
Definition: tlb.hh:421
ArmISA::longDescFormatInUse
bool longDescFormatInUse(ThreadContext *tc)
Definition: utility.cc:229
faults.hh
ArmISA::MISCREG_HCR_EL2
@ MISCREG_HCR_EL2
Definition: miscregs.hh:578
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
ArmISA::MISCREG_TTBR1_EL1
@ MISCREG_TTBR1_EL1
Definition: miscregs.hh:591
ArmISA::TLB::haveLargeAsid64
bool haveLargeAsid64
Definition: tlb.hh:433
ArmISA::TLB::checkPAN
bool checkPAN(ThreadContext *tc, uint8_t ap, const RequestPtr &req, Mode mode)
Definition: tlb.cc:917
ArmISA::TLB::testWalk
Fault testWalk(Addr pa, Addr size, Addr va, bool is_secure, Mode mode, TlbEntry::DomainType domain, LookupLevel lookup_level)
Definition: tlb.cc:1630
ArmISA::TlbEntry::outerAttrs
uint8_t outerAttrs
Definition: pagetable.hh:112
ArmISA::EL1
@ EL1
Definition: types.hh:623
ArmISA::TLB::scr
SCR scr
Definition: tlb.hh:415
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ArmISA::TLB::tableWalker
TableWalker * tableWalker
Definition: tlb.hh:157
ArmISA::purifyTaggedAddr
Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, TCR tcr, bool isInstr)
Removes the tag from tagged addresses if that mode is enabled.
Definition: utility.cc:558
ArmISA::TLB::dacr
uint32_t dacr
Definition: tlb.hh:425
ArmISA::TLB::miscRegValid
bool miscRegValid
Definition: tlb.hh:426
ArmISA::TLB::flushAsid
void flushAsid(uint64_t asn, bool secure_lookup, ExceptionLevel target_el, bool in_host=false)
Remove any entries that match the asn.
Definition: tlb.cc:321
ArmISA::MISCREG_HSCTLR
@ MISCREG_HSCTLR
Definition: miscregs.hh:240
ArmISA::TLB::prrr
PRRR prrr
Definition: tlb.hh:422
packet_access.hh
ArmISA::Stage2LookUp::getTe
Fault getTe(ThreadContext *tc, TlbEntry *destTe)
Definition: stage2_lookup.cc:54
utility.hh
SimObject::getProbeManager
ProbeManager * getProbeManager()
Get the probe manager for this object.
Definition: sim_object.cc:117
full_system.hh
ArmISA::MISCREG_NMRR
@ MISCREG_NMRR
Definition: miscregs.hh:369
ArmISA::wxn
Bitfield< 19 > wxn
Definition: miscregs_types.hh:355
ArmISA::TLB::updateMiscReg
void updateMiscReg(ThreadContext *tc, ArmTranslationType tranType=NormalTran)
Definition: tlb.cc:1258
ArmISA::TLB::flushMvaAsid
void flushMvaAsid(Addr mva, uint64_t asn, bool secure_lookup, ExceptionLevel target_el, bool in_host=false)
Remove any entries that match both a va and asn.
Definition: tlb.cc:310
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
ArmISA::TLB::aarch64
bool aarch64
Definition: tlb.hh:412
ArmISA::MISCREG_TTBR1
@ MISCREG_TTBR1
Definition: miscregs.hh:251
ArmISA::ISA::getSelfDebug
SelfDebug * getSelfDebug() const
Definition: isa.hh:476
ArmISA::TLB::isPriv
bool isPriv
Definition: tlb.hh:416
ArmISA::asid
asid
Definition: miscregs_types.hh:611
ArmISA::TLB
Definition: tlb.hh:100
ArmISA::TLB::stage2Mmu
Stage2MMU * stage2Mmu
Definition: tlb.hh:159
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
BaseTLB::Write
@ Write
Definition: tlb.hh:57
ArmISA::MISCREG_PRRR
@ MISCREG_PRRR
Definition: miscregs.hh:363
ArmSystem
Definition: system.hh:59
ArmISA::TLB::haveLPAE
bool haveLPAE
Definition: tlb.hh:431
ArmISA::MISCREG_SCR_EL3
@ MISCREG_SCR_EL3
Definition: miscregs.hh:585
ArmISA::TableWalker::setMMU
void setMMU(Stage2MMU *m, RequestorID requestor_id)
Definition: table_walker.cc:100
ArmISA::TlbEntry::DomainType
DomainType
Definition: pagetable.hh:90
ArmISA::ArmFault::OVA
@ OVA
Definition: faults.hh:131
ArmISA::TlbEntry
Definition: pagetable.hh:81
ArmISA::TLB::asid
uint16_t asid
Definition: tlb.hh:420
ArmISA::TlbEntry::nstid
bool nstid
Definition: pagetable.hh:129
BaseTLB::Translation::markDelayed
virtual void markDelayed()=0
Signal that the translation has been delayed due to a hw page table walk.
ArmISA::MISCREG_CPSR
@ MISCREG_CPSR
Definition: miscregs.hh:57
ArmISA::TLB::S1E1Tran
@ S1E1Tran
Definition: tlb.hh:130
ArmISA::TlbEntry::xn
bool xn
Definition: pagetable.hh:141
ArmISA::TLB::flushAllNs
void flushAllNs(ExceptionLevel target_el, bool ignore_el=false)
Remove all entries in the non secure world, depending on whether they were allocated in hyp mode or n...
Definition: tlb.cc:279
AddrRange::start
Addr start() const
Get the start address of the range.
Definition: addr_range.hh:314
base.hh
ArmISA::ArmFault::PermissionLL
@ PermissionLL
Definition: faults.hh:100
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
ArmISA::TLB::cpsr
CPSR cpsr
Definition: tlb.hh:411
ArmISA::TLB::init
void init() override
setup all the back pointers
Definition: tlb.cc:103
ArmISA::domain
Bitfield< 7, 4 > domain
Definition: miscregs_types.hh:418
ArmISA::TLB::ppRefills
ProbePoints::PMUUPtr ppRefills
PMU probe for TLB refills.
Definition: tlb.hh:193
ArmISA::TLB::takeOverFrom
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.cc:394
ArmISA::TlbEntry::domain
DomainType domain
Definition: pagetable.hh:115
ArmISA::ArmFault::TranMethod
TranMethod
Definition: faults.hh:146
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
ArmISA::ArmFault::DomainLL
@ DomainLL
Definition: faults.hh:99
Stats::Group
Statistics container.
Definition: group.hh:83
ArmISA::TlbEntry::outerShareable
bool outerShareable
Definition: pagetable.hh:138
ThreadContext::readMiscReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
ArmISA::TLB::TlbStats::readHits
Stats::Scalar readHits
Definition: tlb.hh:169
ArmISA::TlbEntry::size
Addr size
Definition: pagetable.hh:99
addr
ip6_addr_t addr
Definition: inet.hh:423
ArmSystem::haveEL
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:135
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
ArmISA::TlbEntry::vpn
Addr vpn
Definition: pagetable.hh:100
Packet::setLE
void setLE(T v)
Set the value in the data pointer to v as little endian.
Definition: packet_access.hh:105
ArmISA::TLB::directToStage2
bool directToStage2
Definition: tlb.hh:154
ArmISA::TLB::translateAtomic
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode, ArmTranslationType tranType)
Definition: tlb.cc:1163
Stats
Definition: statistics.cc:61
ArmISA::TLB::getTableWalkerPort
Port * getTableWalkerPort() override
Get the table walker port.
Definition: tlb.cc:1252
ArmISA::TlbEntry::asid
uint16_t asid
Definition: pagetable.hh:108
trace.hh
ArmISA::TlbEntry::MemoryType::Normal
@ Normal
ArmISA::MISCREG_TTBR1_EL2
@ MISCREG_TTBR1_EL2
Definition: miscregs.hh:812
ArmISA::vm
Bitfield< 0 > vm
Definition: miscregs_types.hh:281
ArmISA::MISCREG_SCTLR
@ MISCREG_SCTLR
Definition: miscregs.hh:229
ArmISA::TLB::testTranslation
Fault testTranslation(const RequestPtr &req, Mode mode, TlbEntry::DomainType domain)
Definition: tlb.cc:1618
ArmISA::pa
Bitfield< 39, 12 > pa
Definition: miscregs_types.hh:650
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
self_debug.hh
ArmISA::TLB::getTE
Fault getTE(TlbEntry **te, const RequestPtr &req, ThreadContext *tc, Mode mode, Translation *translation, bool timing, bool functional, bool is_secure, ArmTranslationType tranType)
Definition: tlb.cc:1463
ArmISA::TLB::S1E3Tran
@ S1E3Tran
Definition: tlb.hh:132
ArmISA::TLB::getResultTe
Fault getResultTe(TlbEntry **te, const RequestPtr &req, ThreadContext *tc, Mode mode, Translation *translation, bool timing, bool functional, TlbEntry *mergeTe)
Definition: tlb.cc:1533
ArmISA::MODE_USER
@ MODE_USER
Definition: types.hh:636
ArmISA::TLB::setMMU
void setMMU(Stage2MMU *m, RequestorID requestor_id)
Definition: tlb.cc:110
ArmISA::TLB::TlbStats::instHits
Stats::Scalar instHits
Definition: tlb.hh:167
ArmISA::MISCREG_SCTLR_EL3
@ MISCREG_SCTLR_EL3
Definition: miscregs.hh:583
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
page_table.hh
ArmISA::TableWalker::setTlb
void setTlb(TLB *_tlb)
Definition: table_walker.hh:913
ArmISA::TLB::TlbStats::alignFaults
Stats::Scalar alignFaults
Definition: tlb.hh:179
BaseTLB::Execute
@ Execute
Definition: tlb.hh:57
ArmISA::Stage2LookUp::setSelfDelete
void setSelfDelete()
Definition: stage2_lookup.hh:92
ArmISA::TLB::m5opRange
AddrRange m5opRange
Definition: tlb.hh:435
ArmISA::TlbEntry::nonCacheable
bool nonCacheable
Definition: pagetable.hh:134
ArmISA::MISCREG_SCR
@ MISCREG_SCR
Definition: miscregs.hh:237
ArmISA::TLB::S12E1Tran
@ S12E1Tran
Definition: tlb.hh:134
ArmISA::ArmFault::PrefetchTLBMiss
@ PrefetchTLBMiss
Definition: faults.hh:112
ArmISA::TlbEntry::valid
bool valid
Definition: pagetable.hh:124
ArmISA::MISCREG_SCTLR_EL2
@ MISCREG_SCTLR_EL2
Definition: miscregs.hh:576
ArmISA::TLB::TlbStats::flushTlbMvaAsid
Stats::Scalar flushTlbMvaAsid
Definition: tlb.hh:176
ArmISA::TlbEntry::isHyp
bool isHyp
Definition: pagetable.hh:122
ArmISA::TlbEntry::DomainType::NoAccess
@ NoAccess
ArmISA::MISCREG_VTTBR
@ MISCREG_VTTBR
Definition: miscregs.hh:442
ArmISA::TLB::translateFunctional
bool translateFunctional(ThreadContext *tc, Addr vaddr, Addr &paddr)
Do a functional lookup on the TLB (for debugging) and don't modify any internal state.
Definition: tlb.cc:117
thread_context.hh
ArmISA::TLB::translateComplete
Fault translateComplete(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, ArmTranslationType tranType, bool callFromS2)
Definition: tlb.cc:1222
ArmISA::TLB::translateTiming
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode, ArmTranslationType tranType)
Definition: tlb.cc:1205
ArmISA::va
Bitfield< 8 > va
Definition: miscregs_types.hh:272
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711
ArmISA::MISCREG_SCTLR_EL1
@ MISCREG_SCTLR_EL1
Definition: miscregs.hh:571
ArmISA::isSecure
bool isSecure(ThreadContext *tc)
Definition: utility.cc:174
ArmISA::m
Bitfield< 0 > m
Definition: miscregs_types.hh:389
ArmISA::TLB::NormalTran
@ NormalTran
Definition: tlb.hh:119
ArmISA::dc
Bitfield< 12 > dc
Definition: miscregs_types.hh:269
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
ArmISA::TLB::hcr
HCR hcr
Definition: tlb.hh:424
ArmISA::f
Bitfield< 6 > f
Definition: miscregs_types.hh:64
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75
ArmISA::TLB::insert
void insert(Addr vaddr, TlbEntry &pte)
Definition: tlb.cc:204
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17