gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
utility.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2014, 2016-2020 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/isa_traits.hh"
44 #include "arch/arm/system.hh"
45 #include "arch/arm/tlb.hh"
46 #include "cpu/base.hh"
47 #include "cpu/checker/cpu.hh"
48 #include "cpu/thread_context.hh"
49 #include "mem/port_proxy.hh"
50 #include "sim/full_system.hh"
51 
52 namespace ArmISA
53 {
54 
55 uint64_t
56 getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
57 {
58  if (!FullSystem) {
59  panic("getArgument() only implemented for full system mode.\n");
60  M5_DUMMY_RETURN
61  }
62 
63  if (fp)
64  panic("getArgument(): Floating point arguments not implemented\n");
65 
66  if (inAArch64(tc)) {
67  if (size == (uint16_t)(-1))
68  size = sizeof(uint64_t);
69 
70  if (number < 8 /*NumArgumentRegs64*/) {
71  return tc->readIntReg(number);
72  } else {
73  panic("getArgument(): No support reading stack args for AArch64\n");
74  }
75  } else {
76  if (size == (uint16_t)(-1))
77  // todo: should this not be sizeof(uint32_t) rather?
78  size = ArmISA::MachineBytes;
79 
80  if (number < NumArgumentRegs) {
81  // If the argument is 64 bits, it must be in an even regiser
82  // number. Increment the number here if it isn't even.
83  if (size == sizeof(uint64_t)) {
84  if ((number % 2) != 0)
85  number++;
86  // Read the two halves of the data. Number is inc here to
87  // get the second half of the 64 bit reg.
88  uint64_t tmp;
89  tmp = tc->readIntReg(number++);
90  tmp |= tc->readIntReg(number) << 32;
91  return tmp;
92  } else {
93  return tc->readIntReg(number);
94  }
95  } else {
97  PortProxy &vp = tc->getVirtProxy();
98  uint64_t arg;
99  if (size == sizeof(uint64_t)) {
100  // If the argument is even it must be aligned
101  if ((number % 2) != 0)
102  number++;
103  arg = vp.read<uint64_t>(sp +
104  (number-NumArgumentRegs) * sizeof(uint32_t));
105  // since two 32 bit args == 1 64 bit arg, increment number
106  number++;
107  } else {
108  arg = vp.read<uint32_t>(sp +
109  (number-NumArgumentRegs) * sizeof(uint32_t));
110  }
111  return arg;
112  }
113  }
114  panic("getArgument() should always return\n");
115 }
116 
117 static void
119 {
120  auto src_mode = RenameMode<ArmISA::ISA>::mode(src->pcState());
121 
122  // The way vector registers are copied (VecReg vs VecElem) is relevant
123  // in the O3 model only.
124  if (src_mode == Enums::Full) {
125  for (auto idx = 0; idx < NumVecRegs; idx++)
126  dest->setVecRegFlat(idx, src->readVecRegFlat(idx));
127  } else {
128  for (auto idx = 0; idx < NumVecRegs; idx++)
129  for (auto elem_idx = 0; elem_idx < NumVecElemPerVecReg; elem_idx++)
130  dest->setVecElemFlat(
131  idx, elem_idx, src->readVecElemFlat(idx, elem_idx));
132  }
133 }
134 
135 void
137 {
138  for (int i = 0; i < NumIntRegs; i++)
139  dest->setIntRegFlat(i, src->readIntRegFlat(i));
140 
141  for (int i = 0; i < NumFloatRegs; i++)
142  dest->setFloatRegFlat(i, src->readFloatRegFlat(i));
143 
144  for (int i = 0; i < NumCCRegs; i++)
145  dest->setCCReg(i, src->readCCReg(i));
146 
147  for (int i = 0; i < NumMiscRegs; i++)
149 
150  copyVecRegs(src, dest);
151 
152  // setMiscReg "with effect" will set the misc register mapping correctly.
153  // e.g. updateRegMap(val)
155 
156  // Copy over the PC State
157  dest->pcState(src->pcState());
158 
159  // Invalidate the tlb misc register cache
160  dynamic_cast<TLB *>(dest->getITBPtr())->invalidateMiscReg();
161  dynamic_cast<TLB *>(dest->getDTBPtr())->invalidateMiscReg();
162 }
163 
164 void
166 {
167  if (tc->readMiscReg(MISCREG_SEV_MAILBOX) == 0) {
168  // Post Interrupt and wake cpu if needed
169  tc->getCpuPtr()->postInterrupt(tc->threadId(), INT_SEV, 0);
170  }
171 }
172 
173 bool
175 {
176  SCR scr = inAArch64(tc) ? tc->readMiscReg(MISCREG_SCR_EL3) :
179  scr, tc->readMiscReg(MISCREG_CPSR));
180 }
181 
182 inline bool
184 {
185  SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
186  return ArmSystem::haveEL(tc, EL3) && scr.ns == 0;
187 }
188 
189 bool
191 {
192  CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
193  return opModeIs64((OperatingMode) (uint8_t) cpsr.mode);
194 }
195 
196 bool
198 {
199  TTBCR ttbcr = tc->readMiscReg(MISCREG_TTBCR);
200  return ArmSystem::haveLPAE(tc) && ttbcr.eae;
201 }
202 
203 RegVal
205 {
206  const ExceptionLevel current_el = currEL(tc);
207 
208  const bool is_secure = isSecureBelowEL3(tc);
209 
210  switch (current_el) {
211  case EL0:
212  // Note: in MsrMrs instruction we read the register value before
213  // checking access permissions. This means that EL0 entry must
214  // be part of the table even if MPIDR is not accessible in user
215  // mode.
216  warn_once("Trying to read MPIDR at EL0\n");
218  case EL1:
219  if (ArmSystem::haveEL(tc, EL2) && !is_secure)
220  return tc->readMiscReg(MISCREG_VMPIDR_EL2);
221  else
222  return getMPIDR(arm_sys, tc);
223  case EL2:
224  case EL3:
225  return getMPIDR(arm_sys, tc);
226  default:
227  panic("Invalid EL for reading MPIDR register\n");
228  }
229 }
230 
231 RegVal
233 {
234  // Multiprocessor Affinity Register MPIDR from Cortex(tm)-A15 Technical
235  // Reference Manual
236  //
237  // bit 31 - Multi-processor extensions available
238  // bit 30 - Uni-processor system
239  // bit 24 - Multi-threaded cores
240  // bit 11-8 - Cluster ID
241  // bit 1-0 - CPU ID
242  //
243  // We deliberately extend both the Cluster ID and CPU ID fields to allow
244  // for simulation of larger systems
245  assert((0 <= tc->cpuId()) && (tc->cpuId() < 256));
246  assert(tc->socketId() < 65536);
247 
248  RegVal mpidr = 0x80000000;
249 
250  if (!arm_sys->multiProc)
251  replaceBits(mpidr, 30, 1);
252 
253  if (arm_sys->multiThread)
254  replaceBits(mpidr, 24, 1);
255 
256  // Get Affinity numbers
257  mpidr |= getAffinity(arm_sys, tc);
258  return mpidr;
259 }
260 
261 static RegVal
263 {
264  return arm_sys->multiThread ? tc->socketId() << 16 : 0;
265 }
266 
267 static RegVal
269 {
270  return arm_sys->multiThread ? tc->cpuId() << 8 : tc->socketId() << 8;
271 }
272 
273 static RegVal
275 {
276  return arm_sys->multiThread ? tc->threadId() : tc->cpuId();
277 }
278 
279 RegVal
281 {
282  return getAff2(arm_sys, tc) | getAff1(arm_sys, tc) | getAff0(arm_sys, tc);
283 }
284 
285 bool
287 {
288  AA64MMFR1 id_aa64mmfr1 = tc->readMiscReg(MISCREG_ID_AA64MMFR1_EL1);
289  return id_aa64mmfr1.vh;
290 }
291 
294 {
295 
296  SCR scr = tc->readMiscReg(MISCREG_SCR);
297  if (el != EL0)
298  return el;
299  else if (ArmSystem::haveEL(tc, EL3) && ELIs32(tc, EL3) && scr.ns == 0)
300  return EL3;
301  else if (ArmSystem::haveVirtualization(tc) && ELIsInHost(tc, el))
302  return EL2;
303  else
304  return EL1;
305 }
306 
307 bool
309 {
310  AA64PFR0 id_aa64pfr0 = tc->readMiscReg(MISCREG_ID_AA64PFR0_EL1);
311  return id_aa64pfr0.sel2;
312 }
313 
314 bool
316 {
317  SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
318  if (ArmSystem::haveEL(tc, EL2) && HaveSecureEL2Ext(tc)) {
319  if (ArmSystem::haveEL(tc, EL3))
320  return !ELIs32(tc, EL3) && scr.eel2;
321  else
322  return inSecureState(tc);
323  }
324  return false;
325 }
326 
327 bool
329 {
330  SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
331  return ArmSystem::haveEL(tc, EL2) &&
332  (!ArmSystem::haveEL(tc, EL3) || scr.ns || IsSecureEL2Enabled(tc));
333 }
334 
335 bool
337 {
338  return !ELIs32(tc, el);
339 }
340 
341 bool
343 {
344  bool known, aarch32;
345  std::tie(known, aarch32) = ELUsingAArch32K(tc, el);
346  panic_if(!known, "EL state is UNKNOWN");
347  return aarch32;
348 }
349 
350 bool
352 {
353  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
354  return ((IsSecureEL2Enabled(tc) || !isSecureBelowEL3(tc)) &&
355  HaveVirtHostExt(tc) && !ELIs32(tc, EL2) && hcr.e2h == 1 &&
356  (el == EL2 || (el == EL0 && hcr.tge == 1)));
357 }
358 
361 {
362  // Return true if the specified EL is in aarch32 state.
363  const bool have_el3 = ArmSystem::haveSecurity(tc);
364  const bool have_el2 = ArmSystem::haveVirtualization(tc);
365 
366  panic_if(el == EL2 && !have_el2, "Asking for EL2 when it doesn't exist");
367  panic_if(el == EL3 && !have_el3, "Asking for EL3 when it doesn't exist");
368 
369  bool known, aarch32;
370  known = aarch32 = false;
371  if (ArmSystem::highestELIs64(tc) && ArmSystem::highestEL(tc) == el) {
372  // Target EL is the highest one in a system where
373  // the highest is using AArch64.
374  known = true; aarch32 = false;
375  } else if (!ArmSystem::highestELIs64(tc)) {
376  // All ELs are using AArch32:
377  known = true; aarch32 = true;
378  } else {
379  SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
380  bool aarch32_below_el3 = (have_el3 && scr.rw == 0);
381 
382  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
383  bool aarch32_at_el1 = (aarch32_below_el3
384  || (have_el2
385  && !isSecureBelowEL3(tc) && hcr.rw == 0));
386 
387  // Only know if EL0 using AArch32 from PSTATE
388  if (el == EL0 && !aarch32_at_el1) {
389  // EL0 controlled by PSTATE
390  CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
391 
392  known = (currEL(tc) == EL0);
393  aarch32 = (cpsr.width == 1);
394  } else {
395  known = true;
396  aarch32 = (aarch32_below_el3 && el != EL3)
397  || (aarch32_at_el1 && (el == EL0 || el == EL1) );
398  }
399  }
400 
401  return std::make_pair(known, aarch32);
402 }
403 
404 bool
406 {
407  switch (currEL(tc)) {
408  case EL3:
409  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL3)).ee;
410  case EL2:
411  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL2)).ee;
412  case EL1:
413  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL1)).ee;
414  case EL0:
415  return ((SCTLR) tc->readMiscRegNoEffect(MISCREG_SCTLR_EL1)).e0e;
416  default:
417  panic("Invalid exception level");
418  break;
419  }
420 }
421 
422 bool
424 {
425  return unknownMode32(mode) || !ArmSystem::haveEL(tc, opModeToEL(mode));
426 }
427 
428 bool
430 {
431  return unknownMode(mode) || !ArmSystem::haveEL(tc, opModeToEL(mode));
432 }
433 
434 int
435 computeAddrTop(ThreadContext *tc, bool selbit, bool isInstr,
436  TCR tcr, ExceptionLevel el)
437 {
438  bool tbi = false;
439  bool tbid = false;
440  ExceptionLevel regime = s1TranslationRegime(tc, el);
441  if (ELIs32(tc, regime)) {
442  return 31;
443  } else {
444  switch (regime) {
445  case EL1:
446  {
447  //TCR tcr = tc->readMiscReg(MISCREG_TCR_EL1);
448  tbi = selbit? tcr.tbi1 : tcr.tbi0;
449  tbid = selbit? tcr.tbid1 : tcr.tbid0;
450  break;
451  }
452  case EL2:
453  {
454  TCR tcr = tc->readMiscReg(MISCREG_TCR_EL2);
455  if (ArmSystem::haveVirtualization(tc) && ELIsInHost(tc, el)) {
456  tbi = selbit? tcr.tbi1 : tcr.tbi0;
457  tbid = selbit? tcr.tbid1 : tcr.tbid0;
458  } else {
459  tbi = tcr.tbi;
460  tbid = tcr.tbid;
461  }
462  break;
463  }
464  case EL3:
465  {
466  TCR tcr = tc->readMiscReg(MISCREG_TCR_EL3);
467  tbi = tcr.tbi;
468  tbid = tcr.tbid;
469  break;
470  }
471  default:
472  break;
473  }
474 
475  }
476  int res = (tbi && (!tbid || !isInstr))? 55: 63;
477  return res;
478 }
479 Addr
481  TCR tcr, bool isInstr)
482 {
483  bool selbit = bits(addr, 55);
484 // TCR tcr = tc->readMiscReg(MISCREG_TCR_EL1);
485  int topbit = computeAddrTop(tc, selbit, isInstr, tcr, el);
486 
487  if (topbit == 63) {
488  return addr;
489  } else if (selbit && (el == EL1 || el == EL0 || ELIsInHost(tc, el))) {
490  uint64_t mask = ((uint64_t)0x1 << topbit) -1;
491  addr = addr | ~mask;
492  } else {
493  addr = bits(addr, topbit, 0);
494  }
495  return addr; // Nothing to do if this is not a tagged address
496 }
497 
498 Addr
500  bool isInstr)
501 {
502 
503  TCR tcr = tc->readMiscReg(MISCREG_TCR_EL1);
504  return purifyTaggedAddr(addr, tc, el, tcr, isInstr);
505 }
506 
507 Addr
509 {
510  return addr & ~(PageBytes - 1);
511 }
512 
513 Addr
515 {
516  return (addr + PageBytes - 1) & ~(PageBytes - 1);
517 }
518 
519 Fault
520 mcrMrc15Trap(const MiscRegIndex miscReg, ExtMachInst machInst,
521  ThreadContext *tc, uint32_t imm)
522 {
524  if (mcrMrc15TrapToHyp(miscReg, tc, imm, &ec))
525  return std::make_shared<HypervisorTrap>(machInst, imm, ec);
526  return AArch64AArch32SystemAccessTrap(miscReg, machInst, tc, imm, ec);
527 }
528 
529 bool
530 mcrMrc15TrapToHyp(const MiscRegIndex miscReg, ThreadContext *tc, uint32_t iss,
532 {
533  bool isRead;
534  uint32_t crm;
535  IntRegIndex rt;
536  uint32_t crn;
537  uint32_t opc1;
538  uint32_t opc2;
539  bool trapToHype = false;
540 
541  const CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
542  const HCR hcr = tc->readMiscReg(MISCREG_HCR);
543  const SCR scr = tc->readMiscReg(MISCREG_SCR);
544  const HDCR hdcr = tc->readMiscReg(MISCREG_HDCR);
545  const HSTR hstr = tc->readMiscReg(MISCREG_HSTR);
546  const HCPTR hcptr = tc->readMiscReg(MISCREG_HCPTR);
547 
548  if (!inSecureState(scr, cpsr) && (cpsr.mode != MODE_HYP)) {
549  mcrMrcIssExtract(iss, isRead, crm, rt, crn, opc1, opc2);
550  trapToHype = ((uint32_t) hstr) & (1 << crn);
551  trapToHype |= hdcr.tpm && (crn == 9) && (crm >= 12);
552  trapToHype |= hcr.tidcp && (
553  ((crn == 9) && ((crm <= 2) || ((crm >= 5) && (crm <= 8)))) ||
554  ((crn == 10) && ((crm <= 1) || (crm == 4) || (crm == 8))) ||
555  ((crn == 11) && ((crm <= 8) || (crm == 15))) );
556 
557  if (!trapToHype) {
558  switch (unflattenMiscReg(miscReg)) {
559  case MISCREG_CPACR:
560  trapToHype = hcptr.tcpac;
561  break;
562  case MISCREG_REVIDR:
563  case MISCREG_TCMTR:
564  case MISCREG_TLBTR:
565  case MISCREG_AIDR:
566  trapToHype = hcr.tid1;
567  break;
568  case MISCREG_CTR:
569  case MISCREG_CCSIDR:
570  case MISCREG_CLIDR:
571  case MISCREG_CSSELR:
572  trapToHype = hcr.tid2;
573  break;
574  case MISCREG_ID_PFR0:
575  case MISCREG_ID_PFR1:
576  case MISCREG_ID_DFR0:
577  case MISCREG_ID_AFR0:
578  case MISCREG_ID_MMFR0:
579  case MISCREG_ID_MMFR1:
580  case MISCREG_ID_MMFR2:
581  case MISCREG_ID_MMFR3:
582  case MISCREG_ID_ISAR0:
583  case MISCREG_ID_ISAR1:
584  case MISCREG_ID_ISAR2:
585  case MISCREG_ID_ISAR3:
586  case MISCREG_ID_ISAR4:
587  case MISCREG_ID_ISAR5:
588  trapToHype = hcr.tid3;
589  break;
590  case MISCREG_DCISW:
591  case MISCREG_DCCSW:
592  case MISCREG_DCCISW:
593  trapToHype = hcr.tsw;
594  break;
595  case MISCREG_DCIMVAC:
596  case MISCREG_DCCIMVAC:
597  case MISCREG_DCCMVAC:
598  trapToHype = hcr.tpc;
599  break;
600  case MISCREG_ICIMVAU:
601  case MISCREG_ICIALLU:
602  case MISCREG_ICIALLUIS:
603  case MISCREG_DCCMVAU:
604  trapToHype = hcr.tpu;
605  break;
606  case MISCREG_TLBIALLIS:
607  case MISCREG_TLBIMVAIS:
608  case MISCREG_TLBIASIDIS:
609  case MISCREG_TLBIMVAAIS:
610  case MISCREG_TLBIMVALIS:
611  case MISCREG_TLBIMVAALIS:
612  case MISCREG_DTLBIALL:
613  case MISCREG_ITLBIALL:
614  case MISCREG_DTLBIMVA:
615  case MISCREG_ITLBIMVA:
616  case MISCREG_DTLBIASID:
617  case MISCREG_ITLBIASID:
618  case MISCREG_TLBIMVAA:
619  case MISCREG_TLBIALL:
620  case MISCREG_TLBIMVA:
621  case MISCREG_TLBIMVAL:
622  case MISCREG_TLBIMVAAL:
623  case MISCREG_TLBIASID:
624  trapToHype = hcr.ttlb;
625  break;
626  case MISCREG_ACTLR:
627  trapToHype = hcr.tac;
628  break;
629  case MISCREG_SCTLR:
630  case MISCREG_TTBR0:
631  case MISCREG_TTBR1:
632  case MISCREG_TTBCR:
633  case MISCREG_DACR:
634  case MISCREG_DFSR:
635  case MISCREG_IFSR:
636  case MISCREG_DFAR:
637  case MISCREG_IFAR:
638  case MISCREG_ADFSR:
639  case MISCREG_AIFSR:
640  case MISCREG_PRRR:
641  case MISCREG_NMRR:
642  case MISCREG_MAIR0:
643  case MISCREG_MAIR1:
644  case MISCREG_CONTEXTIDR:
645  trapToHype = hcr.tvm & !isRead;
646  break;
647  case MISCREG_PMCR:
648  trapToHype = hdcr.tpmcr;
649  break;
650  // GICv3 regs
651  case MISCREG_ICC_SGI0R:
652  {
653  auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
654  if (isa->haveGICv3CpuIfc())
655  trapToHype = hcr.fmo;
656  }
657  break;
658  case MISCREG_ICC_SGI1R:
659  case MISCREG_ICC_ASGI1R:
660  {
661  auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
662  if (isa->haveGICv3CpuIfc())
663  trapToHype = hcr.imo;
664  }
665  break;
667  // CNTFRQ may be trapped only on reads
668  // CNTPCT and CNTVCT are read-only
669  if (MISCREG_CNTFRQ <= miscReg && miscReg <= MISCREG_CNTVCT &&
670  !isRead)
671  break;
672  trapToHype = isGenericTimerHypTrap(miscReg, tc, ec);
673  break;
674  // No default action needed
675  default:
676  break;
677  }
678  }
679  }
680  return trapToHype;
681 }
682 
683 
684 bool
685 mcrMrc14TrapToHyp(const MiscRegIndex miscReg, HCR hcr, CPSR cpsr, SCR scr,
686  HDCR hdcr, HSTR hstr, HCPTR hcptr, uint32_t iss)
687 {
688  bool isRead;
689  uint32_t crm;
690  IntRegIndex rt;
691  uint32_t crn;
692  uint32_t opc1;
693  uint32_t opc2;
694  bool trapToHype = false;
695 
696  if (!inSecureState(scr, cpsr) && (cpsr.mode != MODE_HYP)) {
697  mcrMrcIssExtract(iss, isRead, crm, rt, crn, opc1, opc2);
698  inform("trap check M:%x N:%x 1:%x 2:%x hdcr %x, hcptr %x, hstr %x\n",
699  crm, crn, opc1, opc2, hdcr, hcptr, hstr);
700  trapToHype = hdcr.tda && (opc1 == 0);
701  trapToHype |= hcptr.tta && (opc1 == 1);
702  if (!trapToHype) {
703  switch (unflattenMiscReg(miscReg)) {
704  case MISCREG_DBGOSLSR:
705  case MISCREG_DBGOSLAR:
706  case MISCREG_DBGOSDLR:
707  case MISCREG_DBGPRCR:
708  trapToHype = hdcr.tdosa;
709  break;
710  case MISCREG_DBGDRAR:
711  case MISCREG_DBGDSAR:
712  trapToHype = hdcr.tdra;
713  break;
714  case MISCREG_JIDR:
715  trapToHype = hcr.tid0;
716  break;
717  case MISCREG_JOSCR:
718  case MISCREG_JMCR:
719  trapToHype = hstr.tjdbx;
720  break;
721  case MISCREG_TEECR:
722  case MISCREG_TEEHBR:
723  trapToHype = hstr.ttee;
724  break;
725  // No default action needed
726  default:
727  break;
728  }
729  }
730  }
731  return trapToHype;
732 }
733 
734 Fault
735 mcrrMrrc15Trap(const MiscRegIndex miscReg, ExtMachInst machInst,
736  ThreadContext *tc, uint32_t imm)
737 {
739  if (mcrrMrrc15TrapToHyp(miscReg, tc, imm, &ec))
740  return std::make_shared<HypervisorTrap>(machInst, imm, ec);
741  return AArch64AArch32SystemAccessTrap(miscReg, machInst, tc, imm, ec);
742 }
743 
744 bool
746  uint32_t iss, ExceptionClass *ec)
747 {
748  uint32_t crm;
749  IntRegIndex rt;
750  uint32_t crn;
751  uint32_t opc1;
752  uint32_t opc2;
753  bool isRead;
754  bool trapToHype = false;
755 
756  const CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
757  const HCR hcr = tc->readMiscReg(MISCREG_HCR);
758  const SCR scr = tc->readMiscReg(MISCREG_SCR);
759  const HSTR hstr = tc->readMiscReg(MISCREG_HSTR);
760 
761  if (!inSecureState(scr, cpsr) && (cpsr.mode != MODE_HYP)) {
762  // This is technically the wrong function, but we can re-use it for
763  // the moment because we only need one field, which overlaps with the
764  // mcrmrc layout
765  mcrMrcIssExtract(iss, isRead, crm, rt, crn, opc1, opc2);
766  trapToHype = ((uint32_t) hstr) & (1 << crm);
767 
768  if (!trapToHype) {
769  switch (unflattenMiscReg(miscReg)) {
770  case MISCREG_SCTLR:
771  case MISCREG_TTBR0:
772  case MISCREG_TTBR1:
773  case MISCREG_TTBCR:
774  case MISCREG_DACR:
775  case MISCREG_DFSR:
776  case MISCREG_IFSR:
777  case MISCREG_DFAR:
778  case MISCREG_IFAR:
779  case MISCREG_ADFSR:
780  case MISCREG_AIFSR:
781  case MISCREG_PRRR:
782  case MISCREG_NMRR:
783  case MISCREG_MAIR0:
784  case MISCREG_MAIR1:
785  case MISCREG_CONTEXTIDR:
786  trapToHype = hcr.tvm & !isRead;
787  break;
789  // CNTFRQ may be trapped only on reads
790  // CNTPCT and CNTVCT are read-only
791  if (MISCREG_CNTFRQ <= miscReg && miscReg <= MISCREG_CNTVCT &&
792  !isRead)
793  break;
794  trapToHype = isGenericTimerHypTrap(miscReg, tc, ec);
795  break;
796  // No default action needed
797  default:
798  break;
799  }
800  }
801  }
802  return trapToHype;
803 }
804 
805 Fault
807  ExtMachInst machInst, ThreadContext *tc,
808  uint32_t imm, ExceptionClass ec)
809 {
810  if (currEL(tc) <= EL1 && !ELIs32(tc, EL1) &&
812  return std::make_shared<SupervisorTrap>(machInst, imm, ec);
813  if (currEL(tc) <= EL2 && EL2Enabled(tc) && !ELIs32(tc, EL2) &&
815  return std::make_shared<HypervisorTrap>(machInst, imm, ec);
816  return NoFault;
817 }
818 
819 bool
821  ThreadContext *tc)
822 {
823  switch (miscReg) {
825  return currEL(tc) == EL0 &&
827  default:
828  break;
829  }
830  return false;
831 }
832 
833 bool
836 {
837  if (currEL(tc) <= EL2 && EL2Enabled(tc) && ELIs32(tc, EL2)) {
838  switch (miscReg) {
840  if (currEL(tc) == EL0 &&
841  isGenericTimerCommonEL0HypTrap(miscReg, tc, ec))
842  return true;
843  switch (miscReg) {
844  case MISCREG_CNTPCT:
846  return currEL(tc) <= EL1 &&
847  isGenericTimerPhysHypTrap(miscReg, tc, ec);
848  default:
849  break;
850  }
851  break;
852  default:
853  break;
854  }
855  }
856  return false;
857 }
858 
859 bool
862 {
863  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
864  bool trap_cond = condGenericTimerSystemAccessTrapEL1(miscReg, tc);
865  if (ELIs32(tc, EL1) && trap_cond && hcr.tge) {
866  // As per the architecture, this hyp trap should have uncategorized
867  // exception class
868  if (ec)
869  *ec = EC_UNKNOWN;
870  return true;
871  }
872  return false;
873 }
874 
875 bool
878 {
879  return condGenericTimerPhysHypTrap(miscReg, tc);
880 }
881 
882 bool
884 {
885  const CNTHCTL cnthctl = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
886  switch (miscReg) {
887  case MISCREG_CNTPCT:
888  return !cnthctl.el1pcten;
890  return !cnthctl.el1pcen;
891  default:
892  break;
893  }
894  return false;
895 }
896 
897 bool
899  ThreadContext *tc)
900 {
901  switch (miscReg) {
904  {
905  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
906  bool trap_cond = condGenericTimerSystemAccessTrapEL1(miscReg, tc);
907  return !(EL2Enabled(tc) && hcr.e2h && hcr.tge) && trap_cond &&
908  !(EL2Enabled(tc) && !ELIs32(tc, EL2) && hcr.tge);
909  }
910  default:
911  break;
912  }
913  return false;
914 }
915 
916 bool
918  ThreadContext *tc)
919 {
920  const CNTKCTL cntkctl = tc->readMiscReg(MISCREG_CNTKCTL_EL1);
921  switch (miscReg) {
922  case MISCREG_CNTFRQ:
923  case MISCREG_CNTFRQ_EL0:
924  return !cntkctl.el0pcten && !cntkctl.el0vcten;
925  case MISCREG_CNTPCT:
926  case MISCREG_CNTPCT_EL0:
927  return !cntkctl.el0pcten;
928  case MISCREG_CNTVCT:
929  case MISCREG_CNTVCT_EL0:
930  return !cntkctl.el0vcten;
933  return !cntkctl.el0pten;
936  return !cntkctl.el0vten;
937  default:
938  break;
939  }
940  return false;
941 }
942 
943 bool
945  ThreadContext *tc)
946 {
947  switch (miscReg) {
949  return currEL(tc) <= EL1 &&
951  default:
952  break;
953  }
954  return false;
955 }
956 
957 bool
959  ThreadContext *tc)
960 {
961  switch (miscReg) {
964  if (currEL(tc) == EL0 &&
966  return true;
967  switch (miscReg) {
968  case MISCREG_CNTPCT:
969  case MISCREG_CNTPCT_EL0:
972  return (currEL(tc) == EL0 &&
974  (currEL(tc) == EL1 &&
976  case MISCREG_CNTVCT:
977  case MISCREG_CNTVCT_EL0:
980  return isGenericTimerVirtSystemAccessTrapEL2(miscReg, tc);
981  default:
982  break;
983  }
984  break;
985  default:
986  break;
987  }
988  return false;
989 }
990 
991 bool
993  ThreadContext *tc)
994 {
995  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
996  bool trap_cond_el1 = condGenericTimerSystemAccessTrapEL1(miscReg, tc);
997  bool trap_cond_el2 = condGenericTimerCommonEL0SystemAccessTrapEL2(miscReg,
998  tc);
999  return (!ELIs32(tc, EL1) && !hcr.e2h && trap_cond_el1 && hcr.tge) ||
1000  (ELIs32(tc, EL1) && trap_cond_el1 && hcr.tge) ||
1001  (hcr.e2h && hcr.tge && trap_cond_el2);
1002 }
1003 
1004 bool
1006  ThreadContext *tc)
1007 {
1008  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1009  bool trap_cond_0 = condGenericTimerPhysEL1SystemAccessTrapEL2(miscReg, tc);
1010  bool trap_cond_1 = condGenericTimerCommonEL1SystemAccessTrapEL2(miscReg,
1011  tc);
1012  switch (miscReg) {
1013  case MISCREG_CNTPCT:
1014  case MISCREG_CNTPCT_EL0:
1015  return !hcr.e2h && trap_cond_1;
1018  return (!hcr.e2h && trap_cond_0) ||
1019  (hcr.e2h && !hcr.tge && trap_cond_1);
1020  default:
1021  break;
1022  }
1023 
1024  return false;
1025 }
1026 
1027 bool
1029  ThreadContext *tc)
1030 {
1031  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1032  bool trap_cond_0 = condGenericTimerPhysEL1SystemAccessTrapEL2(miscReg, tc);
1033  bool trap_cond_1 = condGenericTimerCommonEL1SystemAccessTrapEL2(miscReg,
1034  tc);
1035  switch (miscReg) {
1036  case MISCREG_CNTPCT:
1037  case MISCREG_CNTPCT_EL0:
1038  return trap_cond_1;
1041  return (!hcr.e2h && trap_cond_0) ||
1042  (hcr.e2h && trap_cond_1);
1043  default:
1044  break;
1045  }
1046  return false;
1047 }
1048 
1049 bool
1051  ThreadContext *tc)
1052 {
1053  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1054  bool trap_cond = condGenericTimerCommonEL1SystemAccessTrapEL2(miscReg, tc);
1055  return !ELIs32(tc, EL1) && !(hcr.e2h && hcr.tge) && trap_cond;
1056 }
1057 
1058 bool
1060  ThreadContext *tc)
1061 {
1062  const CNTHCTL_E2H cnthctl = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
1063  switch (miscReg) {
1064  case MISCREG_CNTFRQ:
1065  case MISCREG_CNTFRQ_EL0:
1066  return !cnthctl.el0pcten && !cnthctl.el0vcten;
1067  case MISCREG_CNTPCT:
1068  case MISCREG_CNTPCT_EL0:
1069  return !cnthctl.el0pcten;
1070  case MISCREG_CNTVCT:
1071  case MISCREG_CNTVCT_EL0:
1072  return !cnthctl.el0vcten;
1075  return !cnthctl.el0pten;
1078  return !cnthctl.el0vten;
1079  default:
1080  break;
1081  }
1082  return false;
1083 }
1084 
1085 bool
1087  ThreadContext *tc)
1088 {
1089  const AA64MMFR0 mmfr0 = tc->readMiscRegNoEffect(MISCREG_ID_AA64MMFR0_EL1);
1090  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1091  const RegVal cnthctl_val = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
1092  const CNTHCTL cnthctl = cnthctl_val;
1093  const CNTHCTL_E2H cnthctl_e2h = cnthctl_val;
1094  switch (miscReg) {
1095  case MISCREG_CNTPCT:
1096  case MISCREG_CNTPCT_EL0:
1097  return hcr.e2h ? !cnthctl_e2h.el1pcten : !cnthctl.el1pcten;
1098  case MISCREG_CNTVCT:
1099  case MISCREG_CNTVCT_EL0:
1100  if (!mmfr0.ecv)
1101  return false;
1102  else
1103  return hcr.e2h ? cnthctl_e2h.el1tvct : cnthctl.el1tvct;
1106  return hcr.e2h ? !cnthctl_e2h.el1pten : false;
1109  if (!mmfr0.ecv)
1110  return false;
1111  else
1112  return hcr.e2h ? cnthctl_e2h.el1tvt : cnthctl.el1tvt;
1113  default:
1114  break;
1115  }
1116  return false;
1117 }
1118 
1119 bool
1121  ThreadContext *tc)
1122 {
1123  const CNTHCTL cnthctl = tc->readMiscReg(MISCREG_CNTHCTL_EL2);
1124  return !cnthctl.el1pcen;
1125 }
1126 
1127 bool
1129  ThreadContext *tc)
1130 {
1131  switch (miscReg) {
1133  {
1134  const SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
1135  return currEL(tc) == EL1 && !scr.ns && !scr.st;
1136  }
1137  default:
1138  break;
1139  }
1140  return false;
1141 }
1142 
1143 bool
1144 decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int &regIdx,
1145  CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
1146 {
1148  bool ok = true;
1149 
1150  // R mostly indicates if its a int register or a misc reg, we override
1151  // below if the few corner cases
1152  isIntReg = !r;
1153  // Loosely based on ARM ARM issue C section B9.3.10
1154  if (r) {
1155  switch (sysM)
1156  {
1157  case 0xE:
1158  regIdx = MISCREG_SPSR_FIQ;
1159  mode = MODE_FIQ;
1160  break;
1161  case 0x10:
1162  regIdx = MISCREG_SPSR_IRQ;
1163  mode = MODE_IRQ;
1164  break;
1165  case 0x12:
1166  regIdx = MISCREG_SPSR_SVC;
1167  mode = MODE_SVC;
1168  break;
1169  case 0x14:
1170  regIdx = MISCREG_SPSR_ABT;
1171  mode = MODE_ABORT;
1172  break;
1173  case 0x16:
1174  regIdx = MISCREG_SPSR_UND;
1175  mode = MODE_UNDEFINED;
1176  break;
1177  case 0x1C:
1178  regIdx = MISCREG_SPSR_MON;
1179  mode = MODE_MON;
1180  break;
1181  case 0x1E:
1182  regIdx = MISCREG_SPSR_HYP;
1183  mode = MODE_HYP;
1184  break;
1185  default:
1186  ok = false;
1187  break;
1188  }
1189  } else {
1190  int sysM4To3 = bits(sysM, 4, 3);
1191 
1192  if (sysM4To3 == 0) {
1193  mode = MODE_USER;
1194  regIdx = intRegInMode(mode, bits(sysM, 2, 0) + 8);
1195  } else if (sysM4To3 == 1) {
1196  mode = MODE_FIQ;
1197  regIdx = intRegInMode(mode, bits(sysM, 2, 0) + 8);
1198  } else if (sysM4To3 == 3) {
1199  if (bits(sysM, 1) == 0) {
1200  mode = MODE_MON;
1201  regIdx = intRegInMode(mode, 14 - bits(sysM, 0));
1202  } else {
1203  mode = MODE_HYP;
1204  if (bits(sysM, 0) == 1) {
1205  regIdx = intRegInMode(mode, 13); // R13 in HYP
1206  } else {
1207  isIntReg = false;
1208  regIdx = MISCREG_ELR_HYP;
1209  }
1210  }
1211  } else { // Other Banked registers
1212  int sysM2 = bits(sysM, 2);
1213  int sysM1 = bits(sysM, 1);
1214 
1215  mode = (OperatingMode) ( ((sysM2 || sysM1) << 0) |
1216  (1 << 1) |
1217  ((sysM2 && !sysM1) << 2) |
1218  ((sysM2 && sysM1) << 3) |
1219  (1 << 4) );
1220  regIdx = intRegInMode(mode, 14 - bits(sysM, 0));
1221  // Don't flatten the register here. This is going to go through
1222  // setIntReg() which will do the flattening
1223  ok &= mode != cpsr.mode;
1224  }
1225  }
1226 
1227  // Check that the requested register is accessable from the current mode
1228  if (ok && checkSecurity && mode != cpsr.mode) {
1229  switch (cpsr.mode)
1230  {
1231  case MODE_USER:
1232  ok = false;
1233  break;
1234  case MODE_FIQ:
1235  ok &= mode != MODE_HYP;
1236  ok &= (mode != MODE_MON) || !scr.ns;
1237  break;
1238  case MODE_HYP:
1239  ok &= mode != MODE_MON;
1240  ok &= (mode != MODE_FIQ) || !nsacr.rfr;
1241  break;
1242  case MODE_IRQ:
1243  case MODE_SVC:
1244  case MODE_ABORT:
1245  case MODE_UNDEFINED:
1246  case MODE_SYSTEM:
1247  ok &= mode != MODE_HYP;
1248  ok &= (mode != MODE_MON) || !scr.ns;
1249  ok &= (mode != MODE_FIQ) || !nsacr.rfr;
1250  break;
1251  // can access everything, no further checks required
1252  case MODE_MON:
1253  break;
1254  default:
1255  panic("unknown Mode 0x%x\n", cpsr.mode);
1256  break;
1257  }
1258  }
1259  return (ok);
1260 }
1261 
1262 bool
1264 {
1265  switch (currEL(tc)) {
1266  case EL3:
1267  return ((SCTLR) tc->readMiscReg(MISCREG_SCTLR_EL3)).sa;
1268  case EL2:
1269  return ((SCTLR) tc->readMiscReg(MISCREG_SCTLR_EL2)).sa;
1270  case EL1:
1271  return ((SCTLR) tc->readMiscReg(MISCREG_SCTLR_EL1)).sa;
1272  case EL0:
1273  return ((SCTLR) tc->readMiscReg(MISCREG_SCTLR_EL1)).sa0;
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  case 0x6:
1296  case 0x7:
1297  return 48;
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  default:
1320  panic("Invalid phys. address range");
1321  }
1322 }
1323 
1324 } // namespace ArmISA
bool mcrMrc15TrapToHyp(const MiscRegIndex miscReg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
Definition: utility.cc:530
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
static RegVal getAff0(ArmSystem *arm_sys, ThreadContext *tc)
Definition: utility.cc:274
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
bool condGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1120
MiscRegIndex
Definition: miscregs.hh:56
static bool unknownMode(OperatingMode mode)
Definition: types.hh:717
Bitfield< 15, 12 > rt
Definition: types.hh:123
decltype(nullptr) constexpr NoFault
Definition: types.hh:243
IntRegIndex
Definition: intregs.hh:51
RegVal getAffinity(ArmSystem *arm_sys, ThreadContext *tc)
Retrieves MPIDR_EL1.
Definition: utility.cc:280
bool isGenericTimerVirtSystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1050
bool IsSecureEL2Enabled(ThreadContext *tc)
Definition: utility.cc:315
Bitfield< 7 > i
bool HaveVirtHostExt(ThreadContext *tc)
Definition: utility.cc:286
bool isAArch64AArch32SystemAccessTrapEL1(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:820
STL pair class.
Definition: stl.hh:58
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
Definition: system.hh:150
virtual BaseTLB * getDTBPtr()=0
uint64_t ExtMachInst
Definition: types.hh:39
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
ip6_addr_t addr
Definition: inet.hh:330
bool isGenericTimerHypTrap(const MiscRegIndex miscReg, ThreadContext *tc, ExceptionClass *ec)
Definition: utility.cc:834
virtual PortProxy & getVirtProxy()=0
Bitfield< 0 > sp
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:282
OperatingMode
Definition: types.hh:590
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
Definition: system.hh:193
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
const int NumFloatRegs
Definition: registers.hh:83
uint64_t RegVal
Definition: types.hh:166
bool mcrrMrrc15TrapToHyp(const MiscRegIndex miscReg, ThreadContext *tc, uint32_t iss, ExceptionClass *ec)
Definition: utility.cc:745
constexpr unsigned NumVecElemPerVecReg
Definition: registers.hh:66
virtual BaseCPU * getCpuPtr()=0
Definition: ccregs.hh:41
const bool multiThread
Definition: system.hh:191
static Enums::VecRegRenameMode mode(const TheISA::PCState &)
Definition: traits.hh:58
static RegVal getAff1(ArmSystem *arm_sys, ThreadContext *tc)
Definition: utility.cc:268
Bitfield< 4, 0 > mode
bool mcrMrc14TrapToHyp(const MiscRegIndex miscReg, HCR hcr, CPSR cpsr, SCR scr, HDCR hdcr, HSTR hstr, HCPTR hcptr, uint32_t iss)
Definition: utility.cc:685
virtual RegVal readCCReg(RegIndex reg_idx) const =0
const int NumMiscRegs
Definition: registers.hh:85
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:480
RegVal readMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is either returing the value of MPIDR_EL1 (by calling getMPIDR), or it is issuing a read to VMPIDR_EL2 (as it happens in virtualized systems)
Definition: utility.cc:204
static RegVal getAff2(ArmSystem *arm_sys, ThreadContext *tc)
Definition: utility.cc:262
ThreadContext is the external interface to all thread state for anything outside of the CPU...
static ExceptionLevel currEL(const ThreadContext *tc)
Definition: utility.hh:141
Fault AArch64AArch32SystemAccessTrap(const MiscRegIndex miscReg, ExtMachInst machInst, ThreadContext *tc, uint32_t imm, ExceptionClass ec)
Definition: utility.cc:806
RegVal getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
This helper function is returning the value of MPIDR_EL1.
Definition: utility.cc:232
bool isGenericTimerSystemAccessTrapEL1(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:898
ExceptionLevel
Definition: types.hh:583
static bool haveEL(ThreadContext *tc, ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:132
Bitfield< 24 > e0e
int decodePhysAddrRange64(uint8_t pa_enc)
Returns the n.
Definition: utility.cc:1281
bool HaveSecureEL2Ext(ThreadContext *tc)
Definition: utility.cc:308
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:336
bool isSecureBelowEL3(ThreadContext *tc)
Definition: utility.cc:183
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
Definition: utility.cc:1304
#define inform(...)
Definition: logging.hh:209
PortProxy Object Declaration.
bool isGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:992
Bitfield< 3, 2 > el
int computeAddrTop(ThreadContext *tc, bool selbit, bool isInstr, TCR tcr, ExceptionLevel el)
Definition: utility.cc:435
int unflattenMiscReg(int reg)
Definition: miscregs.cc:1143
bool isAArch64AArch32SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:944
bool isGenericTimerCommonEL0HypTrap(const MiscRegIndex miscReg, ThreadContext *tc, ExceptionClass *ec)
Definition: utility.cc:860
#define M5_FALLTHROUGH
Definition: compiler.hh:84
ExceptionLevel s1TranslationRegime(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:293
virtual int cpuId() const =0
bool multiProc
true if this a multiprocessor system
Definition: system.hh:147
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
Definition: utility.cc:56
const int StackPointerReg
Definition: registers.hh:114
virtual const VecElem & readVecElemFlat(RegIndex idx, const ElemIndex &elemIdx) const =0
void replaceBits(T &val, int first, int last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
Definition: bitfield.hh:156
Bitfield< 29 > tbid
bool SPAlignmentCheckEnabled(ThreadContext *tc)
Definition: utility.cc:1263
Bitfield< 3 > sa
static ExceptionLevel opModeToEL(OperatingMode mode)
Definition: types.hh:688
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:342
virtual BaseTLB * getITBPtr()=0
virtual const VecRegContainer & readVecRegFlat(RegIndex idx) const =0
virtual void setFloatRegFlat(RegIndex idx, RegVal val)=0
static void copyVecRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:118
bool condGenericTimerCommonEL0SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1059
const int NumArgumentRegs
Definition: registers.hh:107
virtual void setVecElemFlat(RegIndex idx, const ElemIndex &elemIdx, const VecElem &val)=0
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:360
virtual void setCCReg(RegIndex reg_idx, RegVal val)=0
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Definition: system.hh:159
virtual BaseISA * getIsaPtr()=0
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Addr roundPage(Addr addr)
Definition: utility.cc:514
Bitfield< 7, 0 > imm
Definition: types.hh:140
bool isGenericTimerPhysEL0SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1005
Fault mcrMrc15Trap(const MiscRegIndex miscReg, ExtMachInst machInst, ThreadContext *tc, uint32_t imm)
Definition: utility.cc:520
#define warn_once(...)
Definition: logging.hh:212
Addr truncPage(Addr addr)
Definition: utility.cc:508
Bitfield< 25 > ee
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn&#39;t already a pending event.
Definition: utility.cc:165
bool decodeMrsMsrBankedReg(uint8_t sysM, bool r, bool &isIntReg, int &regIdx, CPSR cpsr, SCR scr, NSACR nsacr, bool checkSecurity)
Definition: utility.cc:1144
bool isGenericTimerPhysHypTrap(const MiscRegIndex miscReg, ThreadContext *tc, ExceptionClass *ec)
Definition: utility.cc:876
ExceptionClass
Definition: types.hh:610
This object is a proxy for a port or other object which implements the functional response protocol...
Definition: port_proxy.hh:80
Fault mcrrMrrc15Trap(const MiscRegIndex miscReg, ExtMachInst machInst, ThreadContext *tc, uint32_t imm)
Definition: utility.cc:735
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
static bool unknownMode32(OperatingMode mode)
Definition: types.hh:743
bool longDescFormatInUse(ThreadContext *tc)
Definition: utility.cc:197
const int NumIntRegs
Definition: registers.hh:82
ExceptionLevel highestEL() const
Returns the highest implemented exception level.
Definition: system.hh:197
const int NumCCRegs
Definition: registers.hh:84
static void mcrMrcIssExtract(uint32_t iss, bool &isRead, uint32_t &crm, IntRegIndex &rt, uint32_t &crn, uint32_t &opc1, uint32_t &opc2)
Definition: utility.hh:278
virtual int threadId() const =0
bool isBigEndian64(const ThreadContext *tc)
Definition: utility.cc:405
virtual RegVal readIntRegFlat(RegIndex idx) const =0
Flat register interfaces.
virtual uint32_t socketId() const =0
const Addr PageBytes
Definition: isa_traits.hh:56
Bitfield< 7, 5 > opc2
Definition: types.hh:114
virtual void setVecRegFlat(RegIndex idx, const VecRegContainer &val)=0
Bitfield< 3, 0 > mask
Definition: types.hh:62
bool inAArch64(ThreadContext *tc)
Definition: utility.cc:190
virtual RegVal readFloatRegFlat(RegIndex idx) const =0
virtual void setIntRegFlat(RegIndex idx, RegVal val)=0
bool inSecureState(ThreadContext *tc)
Definition: utility.cc:174
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:351
T bits(T val, int first, int last)
Extract the bitfield from position &#39;first&#39; to &#39;last&#39; (inclusive) from &#39;val&#39; and right justify it...
Definition: bitfield.hh:71
bool EL2Enabled(ThreadContext *tc)
Definition: utility.cc:328
Bitfield< 19, 16 > fp
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:136
bool condGenericTimerPhysHypTrap(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:883
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:423
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:181
virtual RegVal readMiscReg(RegIndex misc_reg)=0
bool badMode(ThreadContext *tc, OperatingMode mode)
badMode is checking if the execution mode provided as an argument is valid and implemented.
Definition: utility.cc:429
bool condGenericTimerCommonEL1SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1086
std::shared_ptr< FaultBase > Fault
Definition: types.hh:238
void postInterrupt(ThreadID tid, int int_num, int index)
Definition: base.hh:234
bool condGenericTimerSystemAccessTrapEL1(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:917
static int intRegInMode(OperatingMode mode, int reg)
Definition: intregs.hh:462
const int MachineBytes
Definition: isa_traits.hh:91
Bitfield< 20 > tbi
bool isGenericTimerSystemAccessTrapEL3(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1128
bool haveLPAE() const
Returns true if this system implements the Large Physical Address Extension.
Definition: system.hh:154
bool isGenericTimerSystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:958
bool isGenericTimerPhysEL1SystemAccessTrapEL2(const MiscRegIndex miscReg, ThreadContext *tc)
Definition: utility.cc:1028
const int NumVecRegs
Definition: registers.hh:97
Bitfield< 4 > sa0

Generated on Mon Jun 8 2020 15:34:40 for gem5 by doxygen 1.8.13