gem5  v22.1.0.0
utility.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2014, 2016-2020, 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/utility.hh"
39 
40 #include <memory>
41 
42 #include "arch/arm/faults.hh"
43 #include "arch/arm/interrupts.hh"
44 #include "arch/arm/isa.hh"
45 #include "arch/arm/mmu.hh"
46 #include "arch/arm/page_size.hh"
47 #include "arch/arm/regs/cc.hh"
48 #include "arch/arm/regs/int.hh"
49 #include "arch/arm/regs/vec.hh"
50 #include "arch/arm/system.hh"
51 #include "base/compiler.hh"
52 #include "cpu/base.hh"
53 #include "cpu/checker/cpu.hh"
54 #include "cpu/thread_context.hh"
55 #include "mem/port_proxy.hh"
56 #include "sim/full_system.hh"
57 
58 namespace gem5
59 {
60 
61 namespace ArmISA
62 {
63 
64 void
66 {
67  if (tc->readMiscReg(MISCREG_SEV_MAILBOX) == 0) {
68  // Post Interrupt and wake cpu if needed
69  tc->getCpuPtr()->postInterrupt(tc->threadId(), INT_SEV, 0);
70  }
71 }
72 
73 bool
75 {
76  CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
77  if (ArmSystem::haveEL(tc, EL3) && !cpsr.width && currEL(tc) == EL3)
78  return true;
79  if (ArmSystem::haveEL(tc, EL3) && cpsr.width && cpsr.mode == MODE_MON)
80  return true;
81  else
82  return isSecureBelowEL3(tc);
83 }
84 
85 bool
87 {
88  return ArmSystem::haveEL(tc, EL3) &&
89  static_cast<SCR>(tc->readMiscRegNoEffect(MISCREG_SCR_EL3)).ns == 0;
90 }
91 
93 debugTargetFrom(ThreadContext *tc, bool secure)
94 {
95  bool route_to_el2;
96  if (ArmSystem::haveEL(tc, EL2) &&
97  (!secure || HaveExt(tc, ArmExtension::FEAT_SEL2))) {
98  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
99  const HDCR mdcr = tc->readMiscRegNoEffect(MISCREG_MDCR_EL2);
100  route_to_el2 = (mdcr.tde == 1 || hcr.tge == 1);
101  } else {
102  route_to_el2 = false;
103  }
104  ExceptionLevel target;
105  if (route_to_el2) {
106  target = EL2;
107  } else if (ArmSystem::haveEL(tc, EL3) && !ArmSystem::highestELIs64(tc)
108  && secure) {
109  target = EL3;
110  } else {
111  target = EL1;
112  }
113  return target;
114 }
115 
116 bool
118 {
119  CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
120  return opModeIs64((OperatingMode) (uint8_t) cpsr.mode);
121 }
122 
125 {
126  CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
127  return opModeToEL((OperatingMode)(uint8_t)cpsr.mode);
128 }
129 
130 bool
132 {
133  TTBCR ttbcr = tc->readMiscReg(MISCREG_TTBCR);
134  return ArmSystem::has(ArmExtension::LPAE, tc) && ttbcr.eae;
135 }
136 
137 RegVal
139 {
140  const ExceptionLevel current_el = currEL(tc);
141 
142  const bool is_secure = isSecureBelowEL3(tc);
143 
144  switch (current_el) {
145  case EL0:
146  // Note: in MsrMrs instruction we read the register value before
147  // checking access permissions. This means that EL0 entry must
148  // be part of the table even if MPIDR is not accessible in user
149  // mode.
150  warn_once("Trying to read MPIDR at EL0\n");
151  [[fallthrough]];
152  case EL1:
153  if (ArmSystem::haveEL(tc, EL2) && !is_secure)
154  return tc->readMiscReg(MISCREG_VMPIDR_EL2);
155  else
156  return getMPIDR(arm_sys, tc);
157  case EL2:
158  case EL3:
159  return getMPIDR(arm_sys, tc);
160  default:
161  panic("Invalid EL for reading MPIDR register\n");
162  }
163 }
164 
165 RegVal
167 {
168  // Multiprocessor Affinity Register MPIDR from Cortex(tm)-A15 Technical
169  // Reference Manual
170  //
171  // bit 31 - Multi-processor extensions available
172  // bit 30 - Uni-processor system
173  // bit 24 - Multi-threaded cores
174  // bit 11-8 - Cluster ID
175  // bit 1-0 - CPU ID
176  //
177  // We deliberately extend both the Cluster ID and CPU ID fields to allow
178  // for simulation of larger systems
179  assert((0 <= tc->cpuId()) && (tc->cpuId() < 256));
180  assert(tc->socketId() < 65536);
181 
182  RegVal mpidr = 0x80000000;
183 
184  if (!arm_sys->multiProc)
185  replaceBits(mpidr, 30, 1);
186 
187  if (arm_sys->multiThread)
188  replaceBits(mpidr, 24, 1);
189 
190  // Get Affinity numbers
191  mpidr |= getAffinity(arm_sys, tc);
192  return mpidr;
193 }
194 
195 static RegVal
197 {
198  return arm_sys->multiThread ? tc->socketId() : 0;
199 }
200 
201 static RegVal
203 {
204  return arm_sys->multiThread ? tc->cpuId() : tc->socketId();
205 }
206 
207 static RegVal
209 {
210  return arm_sys->multiThread ? tc->threadId() : tc->cpuId();
211 }
212 
213 Affinity
215 {
216  Affinity aff = 0;
217  aff.aff0 = getAff0(arm_sys, tc);
218  aff.aff1 = getAff1(arm_sys, tc);
219  aff.aff2 = getAff2(arm_sys, tc);
220  return aff;
221 }
222 
223 bool
224 HaveExt(ThreadContext* tc, ArmExtension ext)
225 {
226  auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
227  return isa->getRelease()->has(ext);
228 }
229 
232 {
233  if (el != EL0)
234  return el;
235  else if (ArmSystem::haveEL(tc, EL3) && ELIs32(tc, EL3) &&
236  static_cast<SCR>(
237  tc->readMiscRegNoEffect(MISCREG_SCR_EL3)).ns == 0)
238  return EL3;
239  else if (HaveExt(tc, ArmExtension::FEAT_VHE) && ELIsInHost(tc, el))
240  return EL2;
241  else
242  return EL1;
243 }
244 
245 bool
247 {
248  if (ArmSystem::haveEL(tc, EL2) && HaveExt(tc, ArmExtension::FEAT_SEL2) &&
249  !ELIs32(tc, EL2)) {
250  if (ArmSystem::haveEL(tc, EL3))
251  return !ELIs32(tc, EL3) && static_cast<SCR>(
253  else
254  return isSecure(tc);
255  }
256  return false;
257 }
258 
259 bool
261 {
262  return ArmSystem::haveEL(tc, EL2) &&
263  (!ArmSystem::haveEL(tc, EL3) || static_cast<SCR>(
265  IsSecureEL2Enabled(tc));
266 }
267 
268 bool
270 {
271  return !ELIs32(tc, el);
272 }
273 
274 bool
276 {
277  auto [known, aarch32] = ELUsingAArch32K(tc, el);
278  panic_if(!known, "EL state is UNKNOWN");
279  return aarch32;
280 }
281 
282 bool
284 {
285  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
286  return (ArmSystem::haveEL(tc, EL2) &&
287  (IsSecureEL2Enabled(tc) || !isSecureBelowEL3(tc)) &&
288  HaveExt(tc, ArmExtension::FEAT_VHE) &&
289  !ELIs32(tc, EL2) && hcr.e2h == 1 &&
290  (el == EL2 || (el == EL0 && hcr.tge == 1)));
291 }
292 
295 {
296  bool secure = isSecureBelowEL3(tc);
297  return ELStateUsingAArch32K(tc, el, secure);
298 }
299 
300 bool
302 {
303  if (!ArmSystem::haveEL(tc, el))
304  return false;
305  else if (!ArmSystem::highestELIs64(tc))
306  return true;
307  else if (ArmSystem::highestEL(tc) == el)
308  return false;
309  else if (el == EL0)
310  return true;
311  return true;
312 }
313 
316 {
317  // Return true if the specified EL is in aarch32 state.
318  const bool have_el3 = ArmSystem::haveEL(tc, EL3);
319  const bool have_el2 = ArmSystem::haveEL(tc, EL2);
320 
321  panic_if(el == EL2 && !have_el2, "Asking for EL2 when it doesn't exist");
322  panic_if(el == EL3 && !have_el3, "Asking for EL3 when it doesn't exist");
323 
324  bool known, aarch32;
325  known = aarch32 = false;
326  if (!haveAArch32EL(tc, el)) {
327  // Target EL is the highest one in a system where
328  // the highest is using AArch64.
329  known = true; aarch32 = false;
330  } else if (secure && el == EL2) {
331  known = true; aarch32 = false;
332  } else if (!ArmSystem::highestELIs64(tc)) {
333  // All ELs are using AArch32:
334  known = true; aarch32 = true;
335  } else if (ArmSystem::highestEL(tc) == el) {
336  known = true; aarch32 = false;
337  } else {
338  SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
339  bool aarch32_below_el3 = have_el3 && scr.rw == 0 &&
340  (!secure || !HaveExt(tc, ArmExtension::FEAT_SEL2) || !scr.eel2);
341 
342  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
343  bool sec_el2 = HaveExt(tc, ArmExtension::FEAT_SEL2) && scr.eel2;
344  bool aarch32_at_el1 = (aarch32_below_el3 ||
345  (have_el2 && (sec_el2 || !secure) &&
346  hcr.rw == 0 &&
347  !(hcr.e2h && hcr.tge &&
348  HaveExt(tc, ArmExtension::FEAT_VHE))));
349 
350  // Only know if EL0 using AArch32 from PSTATE
351  if (el == EL0 && !aarch32_at_el1) {
352  // EL0 controlled by PSTATE
353  CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
354  known = (currEL(tc) == EL0);
355  aarch32 = (cpsr.width == 1);
356  } else {
357  known = true;
358  aarch32 = (aarch32_below_el3 && el != EL3) ||
359  (aarch32_at_el1 && (el == EL0 || el == EL1) );
360  }
361  }
362 
363  return std::make_pair(known, aarch32);
364 }
365 
366 bool
368 {
369  auto [known, aarch32] = ELStateUsingAArch32K(tc, el, secure);
370  panic_if(!known, "EL state is UNKNOWN");
371  return aarch32;
372 }
373 
374 bool
376 {
377  switch (currEL(tc)) {
378  case EL3:
379  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL3)).ee;
380  case EL2:
381  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL2)).ee;
382  case EL1:
383  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL1)).ee;
384  case EL0:
385  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL1)).e0e;
386  default:
387  panic("Invalid exception level");
388  break;
389  }
390 }
391 
392 bool
394 {
396 }
397 
398 bool
400 {
402 }
403 
404 int
405 computeAddrTop(ThreadContext *tc, bool selbit, bool is_instr,
406  TCR tcr, ExceptionLevel el)
407 {
408  bool tbi = false;
409  bool tbid = false;
410  ExceptionLevel regime = s1TranslationRegime(tc, el);
411  if (ELIs32(tc, regime)) {
412  return 31;
413  } else {
414  switch (regime) {
415  case EL1:
416  {
417  //TCR tcr = tc->readMiscReg(MISCREG_TCR_EL1);
418  tbi = selbit? tcr.tbi1 : tcr.tbi0;
419  tbid = selbit? tcr.tbid1 : tcr.tbid0;
420  break;
421  }
422  case EL2:
423  {
424  TCR tcr = tc->readMiscReg(MISCREG_TCR_EL2);
425  if (HaveExt(tc, ArmExtension::FEAT_VHE) && ELIsInHost(tc, el)) {
426  tbi = selbit? tcr.tbi1 : tcr.tbi0;
427  tbid = selbit? tcr.tbid1 : tcr.tbid0;
428  } else {
429  tbi = tcr.tbi;
430  tbid = tcr.tbid;
431  }
432  break;
433  }
434  case EL3:
435  {
436  TCR tcr = tc->readMiscReg(MISCREG_TCR_EL3);
437  tbi = tcr.tbi;
438  tbid = tcr.tbid;
439  break;
440  }
441  default:
442  break;
443  }
444 
445  }
446  int res = (tbi && (!tbid || !is_instr))? 55: 63;
447  return res;
448 }
449 
450 Addr
452  int topbit)
453 {
454  if (topbit == 63) {
455  return addr;
456  } else if (bits(addr,55) && (el <= EL1 || ELIsInHost(tc, el))) {
457  uint64_t mask = ((uint64_t)0x1 << topbit) -1;
458  addr = addr | ~mask;
459  } else {
460  addr = bits(addr, topbit, 0);
461  }
462  return addr; // Nothing to do if this is not a tagged address
463 }
464 
465 Addr
467  TCR tcr, bool is_instr)
468 {
469  bool selbit = bits(addr, 55);
470  int topbit = computeAddrTop(tc, selbit, is_instr, tcr, el);
471 
472  return maskTaggedAddr(addr, tc, el, topbit);
473 }
474 
475 Addr
477  bool is_instr)
478 {
479 
480  TCR tcr = tc->readMiscReg(MISCREG_TCR_EL1);
481  return purifyTaggedAddr(addr, tc, el, tcr, is_instr);
482 }
483 
484 Addr
486 {
487  return addr & ~(PageBytes - 1);
488 }
489 
490 Addr
492 {
493  return (addr + PageBytes - 1) & ~(PageBytes - 1);
494 }
495 
496 Fault
497 mcrMrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst,
498  ThreadContext *tc, uint32_t imm)
499 {
501  if (mcrMrc15TrapToHyp(misc_reg, tc, imm, &ec))
502  return std::make_shared<HypervisorTrap>(mach_inst, imm, ec);
503  return AArch64AArch32SystemAccessTrap(misc_reg, mach_inst, tc, imm, ec);
504 }
505 
506 bool
507 mcrMrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss,
509 {
510  bool is_read;
511  uint32_t crm;
512  RegIndex rt;
513  uint32_t crn;
514  uint32_t opc1;
515  uint32_t opc2;
516  bool trap_to_hyp = false;
517 
518  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
519  const HDCR hdcr = tc->readMiscReg(MISCREG_HDCR);
520  const HSTR hstr = tc->readMiscReg(MISCREG_HSTR);
521  const HCPTR hcptr = tc->readMiscReg(MISCREG_HCPTR);
522 
523  if (EL2Enabled(tc) && (currEL(tc) < EL2)) {
524  mcrMrcIssExtract(iss, is_read, crm, rt, crn, opc1, opc2);
525  trap_to_hyp = ((uint32_t) hstr) & (1 << crn);
526  trap_to_hyp |= hdcr.tpm && (crn == 9) && (crm >= 12);
527  trap_to_hyp |= hcr.tidcp && (
528  ((crn == 9) && ((crm <= 2) || ((crm >= 5) && (crm <= 8)))) ||
529  ((crn == 10) && ((crm <= 1) || (crm == 4) || (crm == 8))) ||
530  ((crn == 11) && ((crm <= 8) || (crm == 15))));
531 
532  if (!trap_to_hyp) {
533  switch (unflattenMiscReg(misc_reg)) {
534  case MISCREG_CPACR:
535  trap_to_hyp = hcptr.tcpac;
536  break;
537  case MISCREG_REVIDR:
538  case MISCREG_TCMTR:
539  case MISCREG_TLBTR:
540  case MISCREG_AIDR:
541  trap_to_hyp = hcr.tid1;
542  break;
543  case MISCREG_CTR:
544  case MISCREG_CCSIDR:
545  case MISCREG_CLIDR:
546  case MISCREG_CSSELR:
547  trap_to_hyp = hcr.tid2;
548  break;
549  case MISCREG_ID_PFR0:
550  case MISCREG_ID_PFR1:
551  case MISCREG_ID_DFR0:
552  case MISCREG_ID_AFR0:
553  case MISCREG_ID_MMFR0:
554  case MISCREG_ID_MMFR1:
555  case MISCREG_ID_MMFR2:
556  case MISCREG_ID_MMFR3:
557  case MISCREG_ID_MMFR4:
558  case MISCREG_ID_ISAR0:
559  case MISCREG_ID_ISAR1:
560  case MISCREG_ID_ISAR2:
561  case MISCREG_ID_ISAR3:
562  case MISCREG_ID_ISAR4:
563  case MISCREG_ID_ISAR5:
564  case MISCREG_ID_ISAR6:
565  trap_to_hyp = hcr.tid3;
566  break;
567  case MISCREG_DCISW:
568  case MISCREG_DCCSW:
569  case MISCREG_DCCISW:
570  trap_to_hyp = hcr.tsw;
571  break;
572  case MISCREG_DCIMVAC:
573  case MISCREG_DCCIMVAC:
574  case MISCREG_DCCMVAC:
575  trap_to_hyp = hcr.tpc;
576  break;
577  case MISCREG_ICIMVAU:
578  case MISCREG_ICIALLU:
579  case MISCREG_ICIALLUIS:
580  case MISCREG_DCCMVAU:
581  trap_to_hyp = hcr.tpu;
582  break;
583  case MISCREG_TLBIALLIS:
584  case MISCREG_TLBIMVAIS:
585  case MISCREG_TLBIASIDIS:
586  case MISCREG_TLBIMVAAIS:
587  case MISCREG_TLBIMVALIS:
588  case MISCREG_TLBIMVAALIS:
589  case MISCREG_DTLBIALL:
590  case MISCREG_ITLBIALL:
591  case MISCREG_DTLBIMVA:
592  case MISCREG_ITLBIMVA:
593  case MISCREG_DTLBIASID:
594  case MISCREG_ITLBIASID:
595  case MISCREG_TLBIMVAA:
596  case MISCREG_TLBIALL:
597  case MISCREG_TLBIMVA:
598  case MISCREG_TLBIMVAL:
599  case MISCREG_TLBIMVAAL:
600  case MISCREG_TLBIASID:
601  trap_to_hyp = hcr.ttlb;
602  break;
603  case MISCREG_ACTLR:
604  trap_to_hyp = hcr.tac;
605  break;
606  case MISCREG_SCTLR:
607  case MISCREG_TTBR0:
608  case MISCREG_TTBR1:
609  case MISCREG_TTBCR:
610  case MISCREG_DACR:
611  case MISCREG_DFSR:
612  case MISCREG_IFSR:
613  case MISCREG_DFAR:
614  case MISCREG_IFAR:
615  case MISCREG_ADFSR:
616  case MISCREG_AIFSR:
617  case MISCREG_PRRR:
618  case MISCREG_NMRR:
619  case MISCREG_MAIR0:
620  case MISCREG_MAIR1:
621  case MISCREG_CONTEXTIDR:
622  trap_to_hyp = hcr.tvm & !is_read;
623  break;
624  case MISCREG_PMCR:
625  trap_to_hyp = hdcr.tpmcr;
626  break;
627  // GICv3 regs
628  case MISCREG_ICC_SGI0R:
629  trap_to_hyp = hcr.fmo;
630  break;
631  case MISCREG_ICC_SGI1R:
632  case MISCREG_ICC_ASGI1R:
633  trap_to_hyp = hcr.imo;
634  break;
636  // CNTFRQ may be trapped only on reads
637  // CNTPCT and CNTVCT are read-only
638  if (MISCREG_CNTFRQ <= misc_reg && misc_reg <= MISCREG_CNTVCT &&
639  !is_read)
640  break;
641  trap_to_hyp = isGenericTimerHypTrap(misc_reg, tc, ec);
642  break;
643  // No default action needed
644  default:
645  break;
646  }
647  }
648  }
649  return trap_to_hyp;
650 }
651 
652 
653 bool
654 mcrMrc14TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss)
655 {
656  bool is_read;
657  uint32_t crm;
658  RegIndex rt;
659  uint32_t crn;
660  uint32_t opc1;
661  uint32_t opc2;
662 
663  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
664  const HDCR hdcr = tc->readMiscReg(MISCREG_HDCR);
665  const HSTR hstr = tc->readMiscReg(MISCREG_HSTR);
666  const HCPTR hcptr = tc->readMiscReg(MISCREG_HCPTR);
667 
668  bool trap_to_hyp = false;
669 
670  if (EL2Enabled(tc) && (currEL(tc) < EL2)) {
671  mcrMrcIssExtract(iss, is_read, crm, rt, crn, opc1, opc2);
672  inform("trap check M:%x N:%x 1:%x 2:%x hdcr %x, hcptr %x, hstr %x\n",
673  crm, crn, opc1, opc2, hdcr, hcptr, hstr);
674  trap_to_hyp = hdcr.tda && (opc1 == 0);
675  trap_to_hyp |= hcptr.tta && (opc1 == 1);
676  if (!trap_to_hyp) {
677  switch (unflattenMiscReg(misc_reg)) {
678  case MISCREG_DBGOSLSR:
679  case MISCREG_DBGOSLAR:
680  case MISCREG_DBGOSDLR:
681  case MISCREG_DBGPRCR:
682  trap_to_hyp = hdcr.tdosa;
683  break;
684  case MISCREG_DBGDRAR:
685  case MISCREG_DBGDSAR:
686  trap_to_hyp = hdcr.tdra;
687  break;
688  case MISCREG_JIDR:
689  trap_to_hyp = hcr.tid0;
690  break;
691  case MISCREG_JOSCR:
692  case MISCREG_JMCR:
693  trap_to_hyp = hstr.tjdbx;
694  break;
695  case MISCREG_TEECR:
696  case MISCREG_TEEHBR:
697  trap_to_hyp = hstr.ttee;
698  break;
699  // No default action needed
700  default:
701  break;
702  }
703  }
704  }
705  return trap_to_hyp;
706 }
707 
708 Fault
709 mcrrMrrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst,
710  ThreadContext *tc, uint32_t imm)
711 {
713  if (mcrrMrrc15TrapToHyp(misc_reg, tc, imm, &ec))
714  return std::make_shared<HypervisorTrap>(mach_inst, imm, ec);
715  return AArch64AArch32SystemAccessTrap(misc_reg, mach_inst, tc, imm, ec);
716 }
717 
718 bool
720  uint32_t iss, ExceptionClass *ec)
721 {
722  uint32_t crm;
723  RegIndex rt;
724  uint32_t crn;
725  uint32_t opc1;
726  uint32_t opc2;
727  bool is_read;
728  bool trap_to_hyp = false;
729 
730  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
731  const HSTR hstr = tc->readMiscReg(MISCREG_HSTR);
732 
733  if (EL2Enabled(tc) && (currEL(tc) < EL2)) {
734  // This is technically the wrong function, but we can re-use it for
735  // the moment because we only need one field, which overlaps with the
736  // mcrmrc layout
737  mcrMrcIssExtract(iss, is_read, crm, rt, crn, opc1, opc2);
738  trap_to_hyp = ((uint32_t)hstr) & (1 << crm);
739 
740  if (!trap_to_hyp) {
741  switch (unflattenMiscReg(misc_reg)) {
742  case MISCREG_SCTLR:
743  case MISCREG_TTBR0:
744  case MISCREG_TTBR1:
745  case MISCREG_TTBCR:
746  case MISCREG_DACR:
747  case MISCREG_DFSR:
748  case MISCREG_IFSR:
749  case MISCREG_DFAR:
750  case MISCREG_IFAR:
751  case MISCREG_ADFSR:
752  case MISCREG_AIFSR:
753  case MISCREG_PRRR:
754  case MISCREG_NMRR:
755  case MISCREG_MAIR0:
756  case MISCREG_MAIR1:
757  case MISCREG_CONTEXTIDR:
758  trap_to_hyp = hcr.tvm & !is_read;
759  break;
761  // CNTFRQ may be trapped only on reads
762  // CNTPCT and CNTVCT are read-only
763  if (MISCREG_CNTFRQ <= misc_reg && misc_reg <= MISCREG_CNTVCT &&
764  !is_read) {
765  break;
766  }
767  trap_to_hyp = isGenericTimerHypTrap(misc_reg, tc, ec);
768  break;
769  // No default action needed
770  default:
771  break;
772  }
773  }
774  }
775  return trap_to_hyp;
776 }
777 
778 Fault
780  ExtMachInst mach_inst, ThreadContext *tc,
781  uint32_t imm, ExceptionClass ec)
782 {
783  if (currEL(tc) <= EL1 && !ELIs32(tc, EL1) &&
785  return std::make_shared<SupervisorTrap>(mach_inst, imm, ec);
786  if (currEL(tc) <= EL2 && EL2Enabled(tc) && !ELIs32(tc, EL2) &&
788  return std::make_shared<HypervisorTrap>(mach_inst, imm, ec);
789  return NoFault;
790 }
791 
792 bool
794  ThreadContext *tc)
795 {
796  switch (misc_reg) {
798  return currEL(tc) == EL0 &&
799  isGenericTimerSystemAccessTrapEL1(misc_reg, tc);
800  default:
801  break;
802  }
803  return false;
804 }
805 
806 bool
809 {
810  if (currEL(tc) <= EL2 && EL2Enabled(tc) && ELIs32(tc, EL2)) {
811  switch (misc_reg) {
813  if (currEL(tc) == EL0 &&
814  isGenericTimerCommonEL0HypTrap(misc_reg, tc, ec))
815  return true;
816  switch (misc_reg) {
817  case MISCREG_CNTPCT:
819  return currEL(tc) <= EL1 &&
820  isGenericTimerPhysHypTrap(misc_reg, tc, ec);
821  default:
822  break;
823  }
824  break;
825  default:
826  break;
827  }
828  }
829  return false;
830 }
831 
832 bool
835 {
836  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
837  bool trap_cond = condGenericTimerSystemAccessTrapEL1(misc_reg, tc);
838  if (ELIs32(tc, EL1) && trap_cond && hcr.tge) {
839  // As per the architecture, this hyp trap should have uncategorized
840  // exception class
841  if (ec)
843  return true;
844  }
845  return false;
846 }
847 
848 bool
851 {
852  return condGenericTimerPhysHypTrap(misc_reg, tc);
853 }
854 
855 bool
857 {
858  const CNTHCTL cnthctl = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
859  switch (misc_reg) {
860  case MISCREG_CNTPCT:
861  return !cnthctl.el1pcten;
863  return !cnthctl.el1pcen;
864  default:
865  break;
866  }
867  return false;
868 }
869 
870 bool
872  ThreadContext *tc)
873 {
874  switch (misc_reg) {
877  {
878  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
879  bool trap_cond = condGenericTimerSystemAccessTrapEL1(misc_reg, tc);
880  return !(EL2Enabled(tc) && hcr.e2h && hcr.tge) && trap_cond &&
881  !(EL2Enabled(tc) && !ELIs32(tc, EL2) && hcr.tge);
882  }
883  default:
884  break;
885  }
886  return false;
887 }
888 
889 bool
891  ThreadContext *tc)
892 {
893  const CNTKCTL cntkctl = tc->readMiscReg(MISCREG_CNTKCTL_EL1);
894  switch (misc_reg) {
895  case MISCREG_CNTFRQ:
896  case MISCREG_CNTFRQ_EL0:
897  return !cntkctl.el0pcten && !cntkctl.el0vcten;
898  case MISCREG_CNTPCT:
899  case MISCREG_CNTPCT_EL0:
900  return !cntkctl.el0pcten;
901  case MISCREG_CNTVCT:
902  case MISCREG_CNTVCT_EL0:
903  return !cntkctl.el0vcten;
906  return !cntkctl.el0pten;
909  return !cntkctl.el0vten;
910  default:
911  break;
912  }
913  return false;
914 }
915 
916 bool
918  ThreadContext *tc)
919 {
920  switch (misc_reg) {
922  return currEL(tc) <= EL1 &&
923  isGenericTimerSystemAccessTrapEL2(misc_reg, tc);
924  default:
925  break;
926  }
927  return false;
928 }
929 
930 bool
932  ThreadContext *tc)
933 {
934  switch (misc_reg) {
937  if (currEL(tc) == EL0 &&
939  return true;
940  switch (misc_reg) {
941  case MISCREG_CNTPCT:
942  case MISCREG_CNTPCT_EL0:
945  return (currEL(tc) == EL0 &&
947  (currEL(tc) == EL1 &&
949  case MISCREG_CNTVCT:
950  case MISCREG_CNTVCT_EL0:
953  return isGenericTimerVirtSystemAccessTrapEL2(misc_reg, tc);
954  default:
955  break;
956  }
957  break;
958  default:
959  break;
960  }
961  return false;
962 }
963 
964 bool
966  ThreadContext *tc)
967 {
968  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
969  bool trap_cond_el1 = condGenericTimerSystemAccessTrapEL1(misc_reg, tc);
970  bool trap_cond_el2 = condGenericTimerCommonEL0SystemAccessTrapEL2(misc_reg,
971  tc);
972  return (!ELIs32(tc, EL1) && !hcr.e2h && trap_cond_el1 && hcr.tge) ||
973  (ELIs32(tc, EL1) && trap_cond_el1 && hcr.tge) ||
974  (hcr.e2h && hcr.tge && trap_cond_el2);
975 }
976 
977 bool
979  ThreadContext *tc)
980 {
981  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
983  misc_reg, tc);
985  misc_reg, tc);
986 
987  switch (misc_reg) {
988  case MISCREG_CNTPCT:
989  case MISCREG_CNTPCT_EL0:
990  return !hcr.e2h && trap_cond_1;
993  return (!hcr.e2h && trap_cond_0) ||
994  (hcr.e2h && !hcr.tge && trap_cond_1);
995  default:
996  break;
997  }
998 
999  return false;
1000 }
1001 
1002 bool
1004  ThreadContext *tc)
1005 {
1006  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1007  bool trap_cond_0 = condGenericTimerPhysEL1SystemAccessTrapEL2(
1008  misc_reg, tc);
1010  misc_reg, tc);
1011 
1012  switch (misc_reg) {
1013  case MISCREG_CNTPCT:
1014  case MISCREG_CNTPCT_EL0:
1015  return trap_cond_1;
1018  return (!hcr.e2h && trap_cond_0) ||
1019  (hcr.e2h && trap_cond_1);
1020  default:
1021  break;
1022  }
1023  return false;
1024 }
1025 
1026 bool
1028  ThreadContext *tc)
1029 {
1030  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1032  misc_reg, tc);
1033  return !ELIs32(tc, EL1) && !(hcr.e2h && hcr.tge) && trap_cond;
1034 }
1035 
1036 bool
1038  ThreadContext *tc)
1039 {
1040  const CNTHCTL_E2H cnthctl = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
1041  switch (misc_reg) {
1042  case MISCREG_CNTFRQ:
1043  case MISCREG_CNTFRQ_EL0:
1044  return !cnthctl.el0pcten && !cnthctl.el0vcten;
1045  case MISCREG_CNTPCT:
1046  case MISCREG_CNTPCT_EL0:
1047  return !cnthctl.el0pcten;
1048  case MISCREG_CNTVCT:
1049  case MISCREG_CNTVCT_EL0:
1050  return !cnthctl.el0vcten;
1053  return !cnthctl.el0pten;
1056  return !cnthctl.el0vten;
1057  default:
1058  break;
1059  }
1060  return false;
1061 }
1062 
1063 bool
1065  ThreadContext *tc)
1066 {
1067  const AA64MMFR0 mmfr0 = tc->readMiscRegNoEffect(MISCREG_ID_AA64MMFR0_EL1);
1068  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1069  const RegVal cnthctl_val = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
1070  const CNTHCTL cnthctl = cnthctl_val;
1071  const CNTHCTL_E2H cnthctl_e2h = cnthctl_val;
1072  switch (misc_reg) {
1073  case MISCREG_CNTPCT:
1074  case MISCREG_CNTPCT_EL0:
1075  return hcr.e2h ? !cnthctl_e2h.el1pcten : !cnthctl.el1pcten;
1076  case MISCREG_CNTVCT:
1077  case MISCREG_CNTVCT_EL0:
1078  if (!mmfr0.ecv)
1079  return false;
1080  else
1081  return hcr.e2h ? cnthctl_e2h.el1tvct : cnthctl.el1tvct;
1084  return hcr.e2h ? !cnthctl_e2h.el1pten : false;
1087  if (!mmfr0.ecv)
1088  return false;
1089  else
1090  return hcr.e2h ? cnthctl_e2h.el1tvt : cnthctl.el1tvt;
1091  default:
1092  break;
1093  }
1094  return false;
1095 }
1096 
1097 bool
1099  ThreadContext *tc)
1100 {
1101  const CNTHCTL cnthctl = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
1102  return !cnthctl.el1pcen;
1103 }
1104 
1105 bool
1107  ThreadContext *tc)
1108 {
1109  switch (misc_reg) {
1111  {
1112  const SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
1113  return currEL(tc) == EL1 && !scr.ns && !scr.st;
1114  }
1115  default:
1116  break;
1117  }
1118  return false;
1119 }
1120 
1121 bool
1122 decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int &regIdx,
1123  CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
1124 {
1126  bool ok = true;
1127 
1128  // R mostly indicates if its a int register or a misc reg, we override
1129  // below if the few corner cases
1130  isIntReg = !r;
1131  // Loosely based on ARM ARM issue C section B9.3.10
1132  if (r) {
1133  switch (sysM) {
1134  case 0xE:
1135  regIdx = MISCREG_SPSR_FIQ;
1136  mode = MODE_FIQ;
1137  break;
1138  case 0x10:
1139  regIdx = MISCREG_SPSR_IRQ;
1140  mode = MODE_IRQ;
1141  break;
1142  case 0x12:
1143  regIdx = MISCREG_SPSR_SVC;
1144  mode = MODE_SVC;
1145  break;
1146  case 0x14:
1147  regIdx = MISCREG_SPSR_ABT;
1148  mode = MODE_ABORT;
1149  break;
1150  case 0x16:
1151  regIdx = MISCREG_SPSR_UND;
1152  mode = MODE_UNDEFINED;
1153  break;
1154  case 0x1C:
1155  regIdx = MISCREG_SPSR_MON;
1156  mode = MODE_MON;
1157  break;
1158  case 0x1E:
1159  regIdx = MISCREG_SPSR_HYP;
1160  mode = MODE_HYP;
1161  break;
1162  default:
1163  ok = false;
1164  break;
1165  }
1166  } else {
1167  int sysM4To3 = bits(sysM, 4, 3);
1168 
1169  if (sysM4To3 == 0) {
1170  mode = MODE_USER;
1171  regIdx = int_reg::regInMode(mode, bits(sysM, 2, 0) + 8);
1172  } else if (sysM4To3 == 1) {
1173  mode = MODE_FIQ;
1174  regIdx = int_reg::regInMode(mode, bits(sysM, 2, 0) + 8);
1175  } else if (sysM4To3 == 3) {
1176  if (bits(sysM, 1) == 0) {
1177  mode = MODE_MON;
1178  regIdx = int_reg::regInMode(mode, 14 - bits(sysM, 0));
1179  } else {
1180  mode = MODE_HYP;
1181  if (bits(sysM, 0) == 1) {
1182  regIdx = int_reg::regInMode(mode, 13); // R13 in HYP
1183  } else {
1184  isIntReg = false;
1185  regIdx = MISCREG_ELR_HYP;
1186  }
1187  }
1188  } else { // Other Banked registers
1189  int sysM2 = bits(sysM, 2);
1190  int sysM1 = bits(sysM, 1);
1191 
1192  mode = (OperatingMode)(((sysM2 || sysM1) << 0) |
1193  (1 << 1) |
1194  ((sysM2 && !sysM1) << 2) |
1195  ((sysM2 && sysM1) << 3) |
1196  (1 << 4));
1197  regIdx = int_reg::regInMode(mode, 14 - bits(sysM, 0));
1198  // Don't flatten the register here. This is going to go through
1199  // setReg() which will do the flattening
1200  ok &= mode != cpsr.mode;
1201  }
1202  }
1203 
1204  // Check that the requested register is accessable from the current mode
1205  if (ok && checkSecurity && mode != cpsr.mode) {
1206  switch (cpsr.mode) {
1207  case MODE_USER:
1208  ok = false;
1209  break;
1210  case MODE_FIQ:
1211  ok &= mode != MODE_HYP;
1212  ok &= (mode != MODE_MON) || !scr.ns;
1213  break;
1214  case MODE_HYP:
1215  ok &= mode != MODE_MON;
1216  ok &= (mode != MODE_FIQ) || !nsacr.rfr;
1217  break;
1218  case MODE_IRQ:
1219  case MODE_SVC:
1220  case MODE_ABORT:
1221  case MODE_UNDEFINED:
1222  case MODE_SYSTEM:
1223  ok &= mode != MODE_HYP;
1224  ok &= (mode != MODE_MON) || !scr.ns;
1225  ok &= (mode != MODE_FIQ) || !nsacr.rfr;
1226  break;
1227  // can access everything, no further checks required
1228  case MODE_MON:
1229  break;
1230  default:
1231  panic("unknown Mode 0x%x\n", cpsr.mode);
1232  break;
1233  }
1234  }
1235  return ok;
1236 }
1237 
1238 bool
1240 {
1241  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1242  const CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
1243 
1244  // NV Extension not implemented yet
1245  bool have_nv_ext = false;
1246  bool unpriv_el1 = currEL(tc) == EL1 &&
1247  !(ArmSystem::haveEL(tc, EL2) &&
1248  have_nv_ext && hcr.nv == 1 && hcr.nv1 == 1);
1249  bool unpriv_el2 = ArmSystem::haveEL(tc, EL2) &&
1250  HaveExt(tc, ArmExtension::FEAT_VHE) &&
1251  currEL(tc) == EL2 && hcr.e2h == 1 && hcr.tge == 1;
1252 
1253  return (unpriv_el1 || unpriv_el2) && !cpsr.uao;
1254 }
1255 
1256 bool
1258 {
1259  ExceptionLevel regime = s1TranslationRegime(tc, currEL(tc));
1260 
1261  switch (currEL(tc)) {
1262  case EL3:
1263  return ((SCTLR)tc->readMiscReg(MISCREG_SCTLR_EL3)).sa;
1264  case EL2:
1265  return ((SCTLR)tc->readMiscReg(MISCREG_SCTLR_EL2)).sa;
1266  case EL1:
1267  return ((SCTLR)tc->readMiscReg(MISCREG_SCTLR_EL1)).sa;
1268  case EL0:
1269  {
1270  SCTLR sc = (regime == EL2) ? tc->readMiscReg(MISCREG_SCTLR_EL2):
1272  return sc.sa0;
1273  }
1274  default:
1275  panic("Invalid exception level");
1276  break;
1277  }
1278 }
1279 
1280 int
1281 decodePhysAddrRange64(uint8_t pa_enc)
1282 {
1283  switch (pa_enc) {
1284  case 0x0:
1285  return 32;
1286  case 0x1:
1287  return 36;
1288  case 0x2:
1289  return 40;
1290  case 0x3:
1291  return 42;
1292  case 0x4:
1293  return 44;
1294  case 0x5:
1295  return 48;
1296  case 0x6:
1297  return 52;
1298  default:
1299  panic("Invalid phys. address range encoding");
1300  }
1301 }
1302 
1303 uint8_t
1305 {
1306  switch (pa_size) {
1307  case 32:
1308  return 0x0;
1309  case 36:
1310  return 0x1;
1311  case 40:
1312  return 0x2;
1313  case 42:
1314  return 0x3;
1315  case 44:
1316  return 0x4;
1317  case 48:
1318  return 0x5;
1319  case 52:
1320  return 0x6;
1321  default:
1322  panic("Invalid phys. address range");
1323  }
1324 }
1325 
1326 void
1328 {
1329  int ei = 0;
1330  for (int ri = 0; ri < NumVecRegs; ri++) {
1332  tc->getReg(vecRegClass[ri], &reg);
1333  for (int j = 0; j < NumVecElemPerVecReg; j++, ei++)
1334  tc->setReg(vecElemClass[ei], reg.as<VecElem>()[j]);
1335  }
1336 }
1337 
1338 void
1340 {
1341  int ei = 0;
1342  for (int ri = 0; ri < NumVecRegs; ri++) {
1344  for (int j = 0; j < NumVecElemPerVecReg; j++, ei++) {
1345  RegId elem_id = vecElemClass[ei];
1346  reg.as<VecElem>()[j] = tc->getReg(elem_id);
1347  }
1348  tc->setReg(vecRegClass[ri], &reg);
1349  }
1350 }
1351 
1352 } // namespace ArmISA
1353 } // namespace gem5
const ArmRelease * getRelease() const
Definition: isa.hh:193
bool has(ArmExtension ext) const
Definition: system.hh:76
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:184
ArmISA::ExceptionLevel highestEL() const
Returns the highest implemented exception level.
Definition: system.hh:188
bool has(ArmExtension ext) const
Definition: system.hh:155
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:131
bool multiProc
true if this a multiprocessor system
Definition: system.hh:151
void postInterrupt(ThreadID tid, int int_num, int index)
Definition: base.cc:194
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:91
const bool multiThread
Definition: system.hh:315
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual RegVal getReg(const RegId &reg) const
virtual uint32_t socketId() const =0
virtual BaseISA * getIsaPtr() const =0
virtual void setReg(const RegId &reg, RegVal val)
virtual BaseCPU * getCpuPtr()=0
virtual int threadId() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual int cpuId() const =0
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
Definition: vec_reg.hh:124
STL pair class.
Definition: stl.hh:58
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
constexpr void replaceBits(T &val, unsigned first, unsigned last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
Definition: bitfield.hh:197
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
#define warn_once(...)
Definition: logging.hh:250
#define inform(...)
Definition: logging.hh:247
static int regInMode(OperatingMode mode, int reg)
Definition: int.hh:566
bool badMode(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented.
Definition: utility.cc:399
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:275
static void mcrMrcIssExtract(uint32_t iss, bool &isRead, uint32_t &crm, RegIndex &rt, uint32_t &crn, uint32_t &opc1, uint32_t &opc2)
Definition: utility.hh:246
@ MODE_SYSTEM
Definition: types.hh:296
@ MODE_ABORT
Definition: types.hh:293
@ MODE_UNDEFINED
Definition: types.hh:295
bool isAArch64AArch32SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:917
bool isGenericTimerVirtSystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:1027
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
Definition: utility.cc:1304
Fault mcrrMrrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
Definition: utility.cc:709
void syncVecRegsToElems(ThreadContext *tc)
Definition: utility.cc:1327
Bitfield< 15, 12 > rt
Definition: types.hh:115
Fault AArch64AArch32SystemAccessTrap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm, ExceptionClass ec)
Definition: utility.cc:779
bool ELIsInHost(ThreadContext *tc, ExceptionLevel el)
Returns true if the current exception level el is executing a Host OS or an application of a Host OS ...
Definition: utility.cc:283
Bitfield< 3, 0 > mask
Definition: pcstate.hh:63
bool isGenericTimerSystemAccessTrapEL3(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:1106
ExceptionLevel debugTargetFrom(ThreadContext *tc, bool secure)
Definition: utility.cc:93
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
Definition: utility.cc:124
bool SPAlignmentCheckEnabled(ThreadContext *tc)
Definition: utility.cc:1257
bool isSecure(ThreadContext *tc)
Definition: utility.cc:74
bool haveAArch32EL(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:301
Affinity getAffinity(ArmSystem *arm_sys, ThreadContext *tc)
Retrieves MPIDR_EL1.
Definition: utility.cc:214
Fault mcrMrc15Trap(const MiscRegIndex misc_reg, ExtMachInst mach_inst, ThreadContext *tc, uint32_t imm)
Definition: utility.cc:497
Bitfield< 7, 0 > imm
Definition: types.hh:132
ExceptionLevel s1TranslationRegime(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:231
Addr maskTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, int topbit)
Definition: utility.cc:451
bool longDescFormatInUse(ThreadContext *tc)
Definition: utility.cc:131
Addr roundPage(Addr addr)
Definition: utility.cc:491
static bool unknownMode32(OperatingMode mode)
Definition: types.hh:445
bool isGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:1003
bool isAArch64AArch32SystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:793
static bool unknownMode(OperatingMode mode)
Definition: types.hh:419
bool isBigEndian64(const ThreadContext *tc)
Definition: utility.cc:375
bool isGenericTimerSystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:931
bool ELStateUsingAArch32(ThreadContext *tc, ExceptionLevel el, bool secure)
Definition: utility.cc:367
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
Definition: utility.cc:65
bool isGenericTimerCommonEL0HypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
Definition: utility.cc:833
constexpr unsigned NumVecElemPerVecReg
Definition: vec.hh:61
bool isGenericTimerPhysHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
Definition: utility.cc:849
constexpr RegClass vecElemClass
Definition: vec.hh:105
Bitfield< 7, 5 > opc2
Definition: types.hh:106
bool isGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:965
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:269
static RegVal getAff1(ArmSystem *arm_sys, ThreadContext *tc)
Definition: utility.cc:202
bool isGenericTimerSystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:871
bool condGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:1037
bool isGenericTimerHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc, ExceptionClass *ec)
Definition: utility.cc:807
bool mcrMrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
Definition: utility.cc:507
static RegVal getAff2(ArmSystem *arm_sys, ThreadContext *tc)
Definition: utility.cc:196
bool isSecureBelowEL3(ThreadContext *tc)
Definition: utility.cc:86
Bitfield< 0 > ns
Definition: misc_types.hh:338
bool isUnpriviledgeAccess(ThreadContext *tc)
Definition: utility.cc:1239
bool EL2Enabled(ThreadContext *tc)
Definition: utility.cc:260
std::pair< bool, bool > ELUsingAArch32K(ThreadContext *tc, ExceptionLevel el)
This function checks whether selected EL provided as an argument is using the AArch32 ISA.
Definition: utility.cc:294
Bitfield< 18 > eel2
Definition: misc_types.hh:319
bool IsSecureEL2Enabled(ThreadContext *tc)
Definition: utility.cc:246
Bitfield< 29 > tbid
Definition: misc_types.hh:544
int computeAddrTop(ThreadContext *tc, bool selbit, bool is_instr, TCR tcr, ExceptionLevel el)
Definition: utility.cc:405
Bitfield< 24, 0 > iss
Definition: misc_types.hh:678
Bitfield< 20 > tbi
Definition: misc_types.hh:521
const int NumVecRegs
Definition: vec.hh:83
bool mcrMrc14TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss)
Definition: utility.cc:654
bool badMode32(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented for AArch3...
Definition: utility.cc:393
bool decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int &regIdx, CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
Definition: utility.cc:1122
MiscRegIndex
Definition: misc.hh:64
@ MISCREG_DBGDRAR
Definition: misc.hh:175
@ MISCREG_DBGOSLSR
Definition: misc.hh:193
@ MISCREG_DCCISW
Definition: misc.hh:323
@ MISCREG_CNTV_CTL_EL0
Definition: misc.hh:764
@ MISCREG_SCTLR_EL2
Definition: misc.hh:589
@ MISCREG_CNTP_CTL_EL0
Definition: misc.hh:761
@ MISCREG_TLBIMVALIS
Definition: misc.hh:330
@ MISCREG_TCR_EL2
Definition: misc.hh:609
@ MISCREG_TLBIMVAALIS
Definition: misc.hh:331
@ MISCREG_SPSR_HYP
Definition: misc.hh:72
@ MISCREG_CNTFRQ
Definition: misc.hh:418
@ MISCREG_DBGDSAR
Definition: misc.hh:196
@ MISCREG_TLBIMVAAL
Definition: misc.hh:343
@ MISCREG_CNTV_TVAL
Definition: misc.hh:432
@ MISCREG_CNTPS_TVAL_EL1
Definition: misc.hh:777
@ MISCREG_HCPTR
Definition: misc.hh:256
@ MISCREG_IFAR
Definition: misc.hh:291
@ MISCREG_ID_MMFR1
Definition: misc.hh:221
@ MISCREG_SCTLR
Definition: misc.hh:240
@ MISCREG_TTBCR
Definition: misc.hh:265
@ MISCREG_CSSELR
Definition: misc.hh:235
@ MISCREG_CPACR
Definition: misc.hh:246
@ MISCREG_SCR_EL3
Definition: misc.hh:598
@ MISCREG_TLBIASIDIS
Definition: misc.hh:328
@ MISCREG_ID_ISAR6
Definition: misc.hh:231
@ MISCREG_DBGOSLAR
Definition: misc.hh:192
@ MISCREG_SPSR_SVC
Definition: misc.hh:69
@ MISCREG_TCR_EL3
Definition: misc.hh:615
@ MISCREG_HDCR
Definition: misc.hh:255
@ MISCREG_ADFSR
Definition: misc.hh:279
@ MISCREG_DTLBIMVA
Definition: misc.hh:336
@ MISCREG_TCR_EL1
Definition: misc.hh:606
@ MISCREG_CNTVCT
Definition: misc.hh:420
@ MISCREG_SPSR_UND
Definition: misc.hh:73
@ MISCREG_TCMTR
Definition: misc.hh:212
@ MISCREG_DBGOSDLR
Definition: misc.hh:194
@ MISCREG_SPSR_IRQ
Definition: misc.hh:68
@ MISCREG_ID_ISAR5
Definition: misc.hh:230
@ MISCREG_CNTPCT_EL0
Definition: misc.hh:759
@ MISCREG_SPSR_ABT
Definition: misc.hh:71
@ MISCREG_TLBIMVA
Definition: misc.hh:339
@ MISCREG_ID_ISAR4
Definition: misc.hh:229
@ MISCREG_SCTLR_EL1
Definition: misc.hh:584
@ MISCREG_PRRR
Definition: misc.hh:374
@ MISCREG_TEECR
Definition: misc.hh:203
@ MISCREG_CCSIDR
Definition: misc.hh:232
@ MISCREG_PMCR
Definition: misc.hh:356
@ MISCREG_CNTV_CTL
Definition: misc.hh:430
@ MISCREG_DFAR
Definition: misc.hh:288
@ MISCREG_JMCR
Definition: misc.hh:207
@ MISCREG_TLBIMVAL
Definition: misc.hh:342
@ MISCREG_ITLBIALL
Definition: misc.hh:332
@ MISCREG_ELR_HYP
Definition: misc.hh:74
@ MISCREG_CNTVCT_EL0
Definition: misc.hh:760
@ MISCREG_CPSR
Definition: misc.hh:65
@ MISCREG_ID_MMFR0
Definition: misc.hh:220
@ MISCREG_ID_ISAR0
Definition: misc.hh:225
@ MISCREG_CNTKCTL_EL1
Definition: misc.hh:773
@ MISCREG_CNTPCT
Definition: misc.hh:419
@ MISCREG_CNTPS_CTL_EL1
Definition: misc.hh:775
@ MISCREG_NMRR
Definition: misc.hh:380
@ MISCREG_MAIR1
Definition: misc.hh:383
@ MISCREG_SEV_MAILBOX
Definition: misc.hh:96
@ MISCREG_REVIDR
Definition: misc.hh:215
@ MISCREG_ID_MMFR3
Definition: misc.hh:223
@ MISCREG_TLBIMVAAIS
Definition: misc.hh:329
@ MISCREG_CONTEXTIDR
Definition: misc.hh:404
@ MISCREG_CNTP_TVAL_S
Definition: misc.hh:429
@ MISCREG_CNTHCTL_EL2
Definition: misc.hh:778
@ MISCREG_TEEHBR
Definition: misc.hh:205
@ MISCREG_ID_DFR0
Definition: misc.hh:218
@ MISCREG_ICC_SGI1R
Definition: misc.hh:1006
@ MISCREG_ID_AA64MMFR0_EL1
Definition: misc.hh:574
@ MISCREG_DTLBIALL
Definition: misc.hh:335
@ MISCREG_TLBIALLIS
Definition: misc.hh:326
@ MISCREG_TLBIASID
Definition: misc.hh:340
@ MISCREG_ITLBIMVA
Definition: misc.hh:333
@ MISCREG_HCR_EL2
Definition: misc.hh:591
@ MISCREG_DCIMVAC
Definition: misc.hh:307
@ MISCREG_TTBR1
Definition: misc.hh:262
@ MISCREG_ITLBIASID
Definition: misc.hh:334
@ MISCREG_AIFSR
Definition: misc.hh:282
@ MISCREG_ICIMVAU
Definition: misc.hh:303
@ MISCREG_CTR
Definition: misc.hh:211
@ MISCREG_CLIDR
Definition: misc.hh:233
@ MISCREG_MDCR_EL2
Definition: misc.hh:592
@ MISCREG_IFSR
Definition: misc.hh:276
@ MISCREG_ICIALLUIS
Definition: misc.hh:297
@ MISCREG_TLBIMVAIS
Definition: misc.hh:327
@ MISCREG_JIDR
Definition: misc.hh:204
@ MISCREG_DBGPRCR
Definition: misc.hh:195
@ MISCREG_CNTP_CTL
Definition: misc.hh:421
@ MISCREG_CNTVOFF
Definition: misc.hh:438
@ MISCREG_DCCSW
Definition: misc.hh:318
@ MISCREG_TLBTR
Definition: misc.hh:213
@ MISCREG_DCCMVAU
Definition: misc.hh:321
@ MISCREG_DTLBIASID
Definition: misc.hh:337
@ MISCREG_ID_PFR1
Definition: misc.hh:217
@ MISCREG_CNTV_TVAL_EL0
Definition: misc.hh:766
@ MISCREG_SPSR_MON
Definition: misc.hh:70
@ MISCREG_DCCIMVAC
Definition: misc.hh:322
@ MISCREG_TTBR0
Definition: misc.hh:259
@ MISCREG_DACR
Definition: misc.hh:270
@ MISCREG_JOSCR
Definition: misc.hh:206
@ MISCREG_ICIALLU
Definition: misc.hh:302
@ MISCREG_TLBIALL
Definition: misc.hh:338
@ MISCREG_SCTLR_EL3
Definition: misc.hh:596
@ MISCREG_CNTP_TVAL_EL0
Definition: misc.hh:763
@ MISCREG_ICC_SGI0R
Definition: misc.hh:1005
@ MISCREG_ID_ISAR1
Definition: misc.hh:226
@ MISCREG_AIDR
Definition: misc.hh:234
@ MISCREG_DFSR
Definition: misc.hh:273
@ MISCREG_DCISW
Definition: misc.hh:308
@ MISCREG_ID_MMFR2
Definition: misc.hh:222
@ MISCREG_VMPIDR_EL2
Definition: misc.hh:583
@ MISCREG_ICC_ASGI1R
Definition: misc.hh:980
@ MISCREG_ID_ISAR3
Definition: misc.hh:228
@ MISCREG_ID_PFR0
Definition: misc.hh:216
@ MISCREG_DCCMVAC
Definition: misc.hh:317
@ MISCREG_ID_MMFR4
Definition: misc.hh:224
@ MISCREG_CNTFRQ_EL0
Definition: misc.hh:758
@ MISCREG_ID_AFR0
Definition: misc.hh:219
@ MISCREG_TLBIMVAA
Definition: misc.hh:341
@ MISCREG_ACTLR
Definition: misc.hh:243
@ MISCREG_HSTR
Definition: misc.hh:257
@ MISCREG_ID_ISAR2
Definition: misc.hh:227
@ MISCREG_SPSR_FIQ
Definition: misc.hh:67
@ MISCREG_MAIR0
Definition: misc.hh:377
RegVal getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is returning the value of MPIDR_EL1.
Definition: utility.cc:166
void syncVecElemsToRegs(ThreadContext *tc)
Definition: utility.cc:1339
bool isGenericTimerPhysEL0SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:978
Bitfield< 3, 2 > el
Definition: misc_types.hh:73
std::pair< bool, bool > ELStateUsingAArch32K(ThreadContext *tc, ExceptionLevel el, bool secure)
Definition: utility.cc:315
bool condGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:1098
bool condGenericTimerSystemAccessTrapEL1(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:890
int unflattenMiscReg(int reg)
Definition: misc.cc:722
int decodePhysAddrRange64(uint8_t pa_enc)
Returns the n.
Definition: utility.cc:1281
const Addr PageBytes
Definition: page_size.hh:53
static ExceptionLevel opModeToEL(OperatingMode mode)
Definition: types.hh:390
RegVal readMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is either returing the value of MPIDR_EL1 (by calling getMPIDR),...
Definition: utility.cc:138
bool inAArch64(ThreadContext *tc)
Definition: utility.cc:117
bool HaveExt(ThreadContext *tc, ArmExtension ext)
Returns true if the provided ThreadContext supports the ArmExtension passed as a second argument.
Definition: utility.cc:224
Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el, TCR tcr, bool is_instr)
Removes the tag from tagged addresses if that mode is enabled.
Definition: utility.cc:466
bool condGenericTimerPhysHypTrap(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:856
static RegVal getAff0(ArmSystem *arm_sys, ThreadContext *tc)
Definition: utility.cc:208
Addr truncPage(Addr addr)
Definition: utility.cc:485
bool condGenericTimerCommonEL1SystemAccessTrapEL2(const MiscRegIndex misc_reg, ThreadContext *tc)
Definition: utility.cc:1064
Bitfield< 12 > ext
Definition: misc_types.hh:434
Bitfield< 24 > j
Definition: misc_types.hh:57
constexpr RegClass vecRegClass
Definition: vec.hh:101
uint32_t VecElem
Definition: vec.hh:63
bool mcrrMrrc15TrapToHyp(const MiscRegIndex misc_reg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
Definition: utility.cc:719
Bitfield< 1 > ri
Definition: misc.hh:125
Bitfield< 5 > r
Definition: pagetable.hh:60
Bitfield< 5, 3 > reg
Definition: types.hh:92
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
uint16_t RegIndex
Definition: types.hh:176
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t RegVal
Definition: types.hh:173
constexpr decltype(nullptr) NoFault
Definition: types.hh:253
PortProxy Object Declaration.

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