gem5  v20.1.0.0
static_inst.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2014, 2016-2020 ARM Limited
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2007-2008 The Florida State University
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
43 
44 #include "arch/arm/faults.hh"
45 #include "arch/arm/isa.hh"
46 #include "arch/arm/self_debug.hh"
47 #include "arch/arm/utility.hh"
48 #include "base/condcodes.hh"
49 #include "base/cprintf.hh"
50 #include "base/loader/symtab.hh"
51 #include "cpu/reg_class.hh"
52 
53 namespace ArmISA
54 {
55 // Shift Rm by an immediate value
56 int32_t
57 ArmStaticInst::shift_rm_imm(uint32_t base, uint32_t shamt,
58  uint32_t type, uint32_t cfval) const
59 {
60  assert(shamt < 32);
61  ArmShiftType shiftType;
62  shiftType = (ArmShiftType)type;
63 
64  switch (shiftType)
65  {
66  case LSL:
67  return base << shamt;
68  case LSR:
69  if (shamt == 0)
70  return 0;
71  else
72  return base >> shamt;
73  case ASR:
74  if (shamt == 0)
75  return (base >> 31) | -((base & (1 << 31)) >> 31);
76  else
77  return (base >> shamt) | -((base & (1 << 31)) >> shamt);
78  case ROR:
79  if (shamt == 0)
80  return (cfval << 31) | (base >> 1); // RRX
81  else
82  return (base << (32 - shamt)) | (base >> shamt);
83  default:
84  ccprintf(std::cerr, "Unhandled shift type\n");
85  exit(1);
86  break;
87  }
88  return 0;
89 }
90 
91 int64_t
92 ArmStaticInst::shiftReg64(uint64_t base, uint64_t shiftAmt,
93  ArmShiftType type, uint8_t width) const
94 {
95  shiftAmt = shiftAmt % width;
96  ArmShiftType shiftType;
97  shiftType = (ArmShiftType)type;
98 
99  switch (shiftType)
100  {
101  case LSL:
102  return base << shiftAmt;
103  case LSR:
104  if (shiftAmt == 0)
105  return base;
106  else
107  return (base & mask(width)) >> shiftAmt;
108  case ASR:
109  if (shiftAmt == 0) {
110  return base;
111  } else {
112  int sign_bit = bits(base, intWidth - 1);
113  base >>= shiftAmt;
114  base = sign_bit ? (base | ~mask(intWidth - shiftAmt)) : base;
115  return base & mask(intWidth);
116  }
117  case ROR:
118  if (shiftAmt == 0)
119  return base;
120  else
121  return (base << (width - shiftAmt)) | (base >> shiftAmt);
122  default:
123  ccprintf(std::cerr, "Unhandled shift type\n");
124  exit(1);
125  break;
126  }
127  return 0;
128 }
129 
130 int64_t
132  uint64_t shiftAmt, uint8_t width) const
133 {
134  bool sign_extend = false;
135  int len = 0;
136  switch (type) {
137  case UXTB:
138  len = 8;
139  break;
140  case UXTH:
141  len = 16;
142  break;
143  case UXTW:
144  len = 32;
145  break;
146  case UXTX:
147  len = 64;
148  break;
149  case SXTB:
150  len = 8;
151  sign_extend = true;
152  break;
153  case SXTH:
154  len = 16;
155  sign_extend = true;
156  break;
157  case SXTW:
158  len = 32;
159  sign_extend = true;
160  break;
161  case SXTX:
162  len = 64;
163  sign_extend = true;
164  break;
165  }
166  len = len <= width - shiftAmt ? len : width - shiftAmt;
167  uint64_t tmp = (uint64_t) bits(base, len - 1, 0) << shiftAmt;
168  if (sign_extend) {
169  int sign_bit = bits(tmp, len + shiftAmt - 1);
170  tmp = sign_bit ? (tmp | ~mask(len + shiftAmt)) : tmp;
171  }
172  return tmp & mask(width);
173 }
174 
175 // Shift Rm by Rs
176 int32_t
177 ArmStaticInst::shift_rm_rs(uint32_t base, uint32_t shamt,
178  uint32_t type, uint32_t cfval) const
179 {
180  enum ArmShiftType shiftType;
181  shiftType = (enum ArmShiftType) type;
182 
183  switch (shiftType)
184  {
185  case LSL:
186  if (shamt >= 32)
187  return 0;
188  else
189  return base << shamt;
190  case LSR:
191  if (shamt >= 32)
192  return 0;
193  else
194  return base >> shamt;
195  case ASR:
196  if (shamt >= 32)
197  return (base >> 31) | -((base & (1 << 31)) >> 31);
198  else
199  return (base >> shamt) | -((base & (1 << 31)) >> shamt);
200  case ROR:
201  shamt = shamt & 0x1f;
202  if (shamt == 0)
203  return base;
204  else
205  return (base << (32 - shamt)) | (base >> shamt);
206  default:
207  ccprintf(std::cerr, "Unhandled shift type\n");
208  exit(1);
209  break;
210  }
211  return 0;
212 }
213 
214 
215 // Generate C for a shift by immediate
216 bool
217 ArmStaticInst::shift_carry_imm(uint32_t base, uint32_t shamt,
218  uint32_t type, uint32_t cfval) const
219 {
220  enum ArmShiftType shiftType;
221  shiftType = (enum ArmShiftType) type;
222 
223  switch (shiftType)
224  {
225  case LSL:
226  if (shamt == 0)
227  return cfval;
228  else
229  return (base >> (32 - shamt)) & 1;
230  case LSR:
231  if (shamt == 0)
232  return (base >> 31);
233  else
234  return (base >> (shamt - 1)) & 1;
235  case ASR:
236  if (shamt == 0)
237  return (base >> 31);
238  else
239  return (base >> (shamt - 1)) & 1;
240  case ROR:
241  shamt = shamt & 0x1f;
242  if (shamt == 0)
243  return (base & 1); // RRX
244  else
245  return (base >> (shamt - 1)) & 1;
246  default:
247  ccprintf(std::cerr, "Unhandled shift type\n");
248  exit(1);
249  break;
250  }
251  return 0;
252 }
253 
254 
255 // Generate C for a shift by Rs
256 bool
257 ArmStaticInst::shift_carry_rs(uint32_t base, uint32_t shamt,
258  uint32_t type, uint32_t cfval) const
259 {
260  enum ArmShiftType shiftType;
261  shiftType = (enum ArmShiftType) type;
262 
263  if (shamt == 0)
264  return cfval;
265 
266  switch (shiftType)
267  {
268  case LSL:
269  if (shamt > 32)
270  return 0;
271  else
272  return (base >> (32 - shamt)) & 1;
273  case LSR:
274  if (shamt > 32)
275  return 0;
276  else
277  return (base >> (shamt - 1)) & 1;
278  case ASR:
279  if (shamt > 32)
280  shamt = 32;
281  return (base >> (shamt - 1)) & 1;
282  case ROR:
283  shamt = shamt & 0x1f;
284  if (shamt == 0)
285  shamt = 32;
286  return (base >> (shamt - 1)) & 1;
287  default:
288  ccprintf(std::cerr, "Unhandled shift type\n");
289  exit(1);
290  break;
291  }
292  return 0;
293 }
294 
295 void
296 ArmStaticInst::printIntReg(std::ostream &os, RegIndex reg_idx,
297  uint8_t opWidth) const
298 {
299  if (opWidth == 0)
300  opWidth = intWidth;
301  if (aarch64) {
302  if (reg_idx == INTREG_UREG0)
303  ccprintf(os, "ureg0");
304  else if (reg_idx == INTREG_SPX)
305  ccprintf(os, "%s%s", (opWidth == 32) ? "w" : "", "sp");
306  else if (reg_idx == INTREG_X31)
307  ccprintf(os, "%szr", (opWidth == 32) ? "w" : "x");
308  else
309  ccprintf(os, "%s%d", (opWidth == 32) ? "w" : "x", reg_idx);
310  } else {
311  switch (reg_idx) {
312  case PCReg:
313  ccprintf(os, "pc");
314  break;
315  case StackPointerReg:
316  ccprintf(os, "sp");
317  break;
318  case FramePointerReg:
319  ccprintf(os, "fp");
320  break;
321  case ReturnAddressReg:
322  ccprintf(os, "lr");
323  break;
324  default:
325  ccprintf(os, "r%d", reg_idx);
326  break;
327  }
328  }
329 }
330 
331 void ArmStaticInst::printPFflags(std::ostream &os, int flag) const
332 {
333  const char *flagtoprfop[]= { "PLD", "PLI", "PST", "Reserved"};
334  const char *flagtotarget[] = { "L1", "L2", "L3", "Reserved"};
335  const char *flagtopolicy[] = { "KEEP", "STRM"};
336 
337  ccprintf(os, "%s%s%s", flagtoprfop[(flag>>3)&3],
338  flagtotarget[(flag>>1)&3], flagtopolicy[flag&1]);
339 }
340 
341 void
342 ArmStaticInst::printFloatReg(std::ostream &os, RegIndex reg_idx) const
343 {
344  ccprintf(os, "f%d", reg_idx);
345 }
346 
347 void
348 ArmStaticInst::printVecReg(std::ostream &os, RegIndex reg_idx,
349  bool isSveVecReg) const
350 {
351  ccprintf(os, "%s%d", isSveVecReg ? "z" : "v", reg_idx);
352 }
353 
354 void
355 ArmStaticInst::printVecPredReg(std::ostream &os, RegIndex reg_idx) const
356 {
357  ccprintf(os, "p%d", reg_idx);
358 }
359 
360 void
361 ArmStaticInst::printCCReg(std::ostream &os, RegIndex reg_idx) const
362 {
363  ccprintf(os, "cc_%s", ArmISA::ccRegName[reg_idx]);
364 }
365 
366 void
367 ArmStaticInst::printMiscReg(std::ostream &os, RegIndex reg_idx) const
368 {
369  assert(reg_idx < NUM_MISCREGS);
370  ccprintf(os, "%s", ArmISA::miscRegName[reg_idx]);
371 }
372 
373 void
375  const std::string &suffix,
376  bool withPred,
377  bool withCond64,
378  ConditionCode cond64) const
379 {
380  os << " " << mnemonic;
381  if (withPred && !aarch64) {
382  printCondition(os, machInst.condCode);
383  os << suffix;
384  } else if (withCond64) {
385  os << ".";
386  printCondition(os, cond64);
387  os << suffix;
388  }
389  if (machInst.bigThumb)
390  os << ".w";
391  os << " ";
392 }
393 
394 void
395 ArmStaticInst::printTarget(std::ostream &os, Addr target,
396  const Loader::SymbolTable *symtab) const
397 {
398  if (symtab) {
399  auto it = symtab->findNearest(target);
400  if (it != symtab->end()) {
401  ccprintf(os, "<%s", it->name);
402  Addr delta = target - it->address;
403  if (delta)
404  ccprintf(os, "+%d>", delta);
405  else
406  ccprintf(os, ">");
407  return;
408  }
409  }
410  ccprintf(os, "%#x", target);
411 }
412 
413 void
415  unsigned code,
416  bool noImplicit) const
417 {
418  switch (code) {
419  case COND_EQ:
420  os << "eq";
421  break;
422  case COND_NE:
423  os << "ne";
424  break;
425  case COND_CS:
426  os << "cs";
427  break;
428  case COND_CC:
429  os << "cc";
430  break;
431  case COND_MI:
432  os << "mi";
433  break;
434  case COND_PL:
435  os << "pl";
436  break;
437  case COND_VS:
438  os << "vs";
439  break;
440  case COND_VC:
441  os << "vc";
442  break;
443  case COND_HI:
444  os << "hi";
445  break;
446  case COND_LS:
447  os << "ls";
448  break;
449  case COND_GE:
450  os << "ge";
451  break;
452  case COND_LT:
453  os << "lt";
454  break;
455  case COND_GT:
456  os << "gt";
457  break;
458  case COND_LE:
459  os << "le";
460  break;
461  case COND_AL:
462  // This one is implicit.
463  if (noImplicit)
464  os << "al";
465  break;
466  case COND_UC:
467  // Unconditional.
468  if (noImplicit)
469  os << "uc";
470  break;
471  default:
472  panic("Unrecognized condition code %d.\n", code);
473  }
474 }
475 
476 void
478  const Loader::SymbolTable *symtab,
479  const std::string &prefix,
480  const Addr addr,
481  const std::string &suffix) const
482 {
483  if (symtab) {
484  auto it = symtab->findNearest(addr);
485  if (it != symtab->end()) {
486  ccprintf(os, "%s%s", prefix, it->name);
487  if (it->address != addr)
488  ccprintf(os, "+%d", addr - it->address);
489  ccprintf(os, suffix);
490  }
491  }
492 }
493 
494 void
496  IntRegIndex rm,
497  bool immShift,
498  uint32_t shiftAmt,
499  IntRegIndex rs,
500  ArmShiftType type) const
501 {
502  bool firstOp = false;
503 
504  if (rm != INTREG_ZERO) {
505  printIntReg(os, rm);
506  }
507 
508  bool done = false;
509 
510  if ((type == LSR || type == ASR) && immShift && shiftAmt == 0)
511  shiftAmt = 32;
512 
513  switch (type) {
514  case LSL:
515  if (immShift && shiftAmt == 0) {
516  done = true;
517  break;
518  }
519  if (!firstOp)
520  os << ", ";
521  os << "LSL";
522  break;
523  case LSR:
524  if (!firstOp)
525  os << ", ";
526  os << "LSR";
527  break;
528  case ASR:
529  if (!firstOp)
530  os << ", ";
531  os << "ASR";
532  break;
533  case ROR:
534  if (immShift && shiftAmt == 0) {
535  if (!firstOp)
536  os << ", ";
537  os << "RRX";
538  done = true;
539  break;
540  }
541  if (!firstOp)
542  os << ", ";
543  os << "ROR";
544  break;
545  default:
546  panic("Tried to disassemble unrecognized shift type.\n");
547  }
548  if (!done) {
549  if (!firstOp)
550  os << " ";
551  if (immShift)
552  os << "#" << shiftAmt;
553  else
554  printIntReg(os, rs);
555  }
556 }
557 
558 void
559 ArmStaticInst::printExtendOperand(bool firstOperand, std::ostream &os,
561  int64_t shiftAmt) const
562 {
563  if (!firstOperand)
564  ccprintf(os, ", ");
565  printIntReg(os, rm);
566  if (type == UXTX && shiftAmt == 0)
567  return;
568  switch (type) {
569  case UXTB: ccprintf(os, ", UXTB");
570  break;
571  case UXTH: ccprintf(os, ", UXTH");
572  break;
573  case UXTW: ccprintf(os, ", UXTW");
574  break;
575  case UXTX: ccprintf(os, ", LSL");
576  break;
577  case SXTB: ccprintf(os, ", SXTB");
578  break;
579  case SXTH: ccprintf(os, ", SXTH");
580  break;
581  case SXTW: ccprintf(os, ", SXTW");
582  break;
583  case SXTX: ccprintf(os, ", SXTW");
584  break;
585  }
586  if (type == UXTX || shiftAmt)
587  ccprintf(os, " #%d", shiftAmt);
588 }
589 
590 void
591 ArmStaticInst::printDataInst(std::ostream &os, bool withImm,
592  bool immShift, bool s, IntRegIndex rd, IntRegIndex rn,
593  IntRegIndex rm, IntRegIndex rs, uint32_t shiftAmt,
594  ArmShiftType type, uint64_t imm) const
595 {
596  printMnemonic(os, s ? "s" : "");
597  bool firstOp = true;
598 
599  // Destination
600  if (rd != INTREG_ZERO) {
601  firstOp = false;
602  printIntReg(os, rd);
603  }
604 
605  // Source 1.
606  if (rn != INTREG_ZERO) {
607  if (!firstOp)
608  os << ", ";
609  firstOp = false;
610  printIntReg(os, rn);
611  }
612 
613  if (!firstOp)
614  os << ", ";
615  if (withImm) {
616  ccprintf(os, "#%ld", imm);
617  } else {
618  printShiftOperand(os, rm, immShift, shiftAmt, rs, type);
619  }
620 }
621 
622 std::string
624  const Loader::SymbolTable *symtab) const
625 {
626  std::stringstream ss;
627  printMnemonic(ss);
628  return ss.str();
629 }
630 
631 Fault
633 {
634  const auto tc = xc->tcBase();
635  const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
636  const HDCR mdcr = tc->readMiscRegNoEffect(MISCREG_MDCR_EL2);
637  if ((EL2Enabled(tc) && !ELIs32(tc, EL2) &&
638  (hcr.tge || mdcr.tde)) || !ELIs32(tc, EL1)) {
639  // Route to AArch64 Software Breakpoint
640  return std::make_shared<SoftwareBreakpoint>(machInst, imm);
641  } else {
642  // Execute AArch32 Software Breakpoint
643  return std::make_shared<PrefetchAbort>(readPC(xc),
645  false,
648  }
649 }
650 
651 Fault
653 {
654  switch (el) {
655  case EL1:
656  return std::make_shared<SupervisorTrap>(machInst, 0x1E00000,
658  case EL2:
659  return std::make_shared<HypervisorTrap>(machInst, 0x1E00000,
661  case EL3:
662  return std::make_shared<SecureMonitorTrap>(machInst, 0x1E00000,
664 
665  default:
666  panic("Illegal EL in advSIMDFPAccessTrap64\n");
667  }
668 }
669 
670 
671 Fault
673 {
674  if (currEL(tc) <= EL2 && EL2Enabled(tc)) {
675  bool trap_el2 = false;
676  CPTR cptr_en_check = tc->readMiscReg(MISCREG_CPTR_EL2);
677  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
678  if (HaveVirtHostExt(tc) && hcr.e2h == 0x1) {
679  switch (cptr_en_check.fpen) {
680  case 0:
681  case 2:
682  trap_el2 = !(currEL(tc) == EL1 && hcr.tge == 1);
683  break;
684  case 1:
685  trap_el2 = (currEL(tc) == EL0 && hcr.tge == 1);
686  break;
687  default:
688  trap_el2 = false;
689  break;
690  }
691  } else if (cptr_en_check.tfp) {
692  trap_el2 = true;
693  }
694 
695  if (trap_el2) {
696  return advSIMDFPAccessTrap64(EL2);
697  }
698  }
699 
700  if (ArmSystem::haveSecurity(tc)) {
701  CPTR cptr_en_check = tc->readMiscReg(MISCREG_CPTR_EL3);
702  if (cptr_en_check.tfp) {
703  return advSIMDFPAccessTrap64(EL3);
704  }
705  }
706 
707  return NoFault;
708 }
709 
710 Fault
712  CPSR cpsr, CPACR cpacr) const
713 {
714  const ExceptionLevel el = currEL(tc);
715  if ((el == EL0 && cpacr.fpen != 0x3) ||
716  (el == EL1 && !(cpacr.fpen & 0x1)))
717  return advSIMDFPAccessTrap64(EL1);
718 
719  return checkFPAdvSIMDTrap64(tc, cpsr);
720 }
721 
722 Fault
724  CPSR cpsr, CPACR cpacr,
725  NSACR nsacr, FPEXC fpexc,
726  bool fpexc_check, bool advsimd) const
727 {
728  const bool have_virtualization = ArmSystem::haveVirtualization(tc);
729  const bool have_security = ArmSystem::haveSecurity(tc);
730  const bool is_secure = isSecure(tc);
731  const ExceptionLevel cur_el = currEL(tc);
732 
733  if (cur_el == EL0 && ELIs64(tc, EL1))
734  return checkFPAdvSIMDEnabled64(tc, cpsr, cpacr);
735 
736  uint8_t cpacr_cp10 = cpacr.cp10;
737  bool cpacr_asedis = cpacr.asedis;
738 
739  if (have_security && !ELIs64(tc, EL3) && !is_secure) {
740  if (nsacr.nsasedis)
741  cpacr_asedis = true;
742  if (nsacr.cp10 == 0)
743  cpacr_cp10 = 0;
744  }
745 
746  if (cur_el != EL2) {
747  if (advsimd && cpacr_asedis)
748  return disabledFault();
749 
750  if ((cur_el == EL0 && cpacr_cp10 != 0x3) ||
751  (cur_el != EL0 && !(cpacr_cp10 & 0x1)))
752  return disabledFault();
753  }
754 
755  if (fpexc_check && !fpexc.en)
756  return disabledFault();
757 
758  // -- aarch32/exceptions/traps/AArch32.CheckFPAdvSIMDTrap --
759 
760  if (have_virtualization && !is_secure && ELIs64(tc, EL2))
761  return checkFPAdvSIMDTrap64(tc, cpsr);
762 
763  if (have_virtualization && !is_secure) {
764  HCPTR hcptr = tc->readMiscReg(MISCREG_HCPTR);
765  bool hcptr_cp10 = hcptr.tcp10;
766  bool hcptr_tase = hcptr.tase;
767 
768  if (have_security && !ELIs64(tc, EL3) && !is_secure) {
769  if (nsacr.nsasedis)
770  hcptr_tase = true;
771  if (nsacr.cp10)
772  hcptr_cp10 = true;
773  }
774 
775  if ((advsimd && hcptr_tase) || hcptr_cp10) {
776  const uint32_t iss = advsimd ? (1 << 5) : 0xA;
777  if (cur_el == EL2) {
778  return std::make_shared<UndefinedInstruction>(
779  machInst, iss,
781  } else {
782  return std::make_shared<HypervisorTrap>(
783  machInst, iss,
785  }
786 
787  }
788  }
789 
790  if (have_security && ELIs64(tc, EL3)) {
791  HCPTR cptr_en_check = tc->readMiscReg(MISCREG_CPTR_EL3);
792  if (cptr_en_check.tfp)
793  return advSIMDFPAccessTrap64(EL3);
794  }
795 
796  return NoFault;
797 }
798 
799 inline bool
801  ExceptionLevel tgtEl,
802  bool isWfe) const
803 {
804  bool trap = false;
805  SCTLR sctlr = ((SCTLR)tc->readMiscReg(MISCREG_SCTLR_EL1));
806  HCR hcr = ((HCR)tc->readMiscReg(MISCREG_HCR_EL2));
807  SCR scr = ((SCR)tc->readMiscReg(MISCREG_SCR_EL3));
808 
809  switch (tgtEl) {
810  case EL1:
811  trap = isWfe? !sctlr.ntwe : !sctlr.ntwi;
812  break;
813  case EL2:
814  trap = isWfe? hcr.twe : hcr.twi;
815  break;
816  case EL3:
817  trap = isWfe? scr.twe : scr.twi;
818  break;
819  default:
820  break;
821  }
822 
823  return trap;
824 }
825 
826 Fault
828  ExceptionLevel targetEL,
829  bool isWfe) const
830 {
831  // Check if target exception level is implemented.
832  assert(ArmSystem::haveEL(tc, targetEL));
833 
834  // Check for routing to AArch64: this happens if the
835  // target exception level (where the trap will be handled)
836  // is using aarch64
837  if (ELIs64(tc, targetEL)) {
838  return checkForWFxTrap64(tc, targetEL, isWfe);
839  }
840 
841  // Check if processor needs to trap at selected exception level
842  bool trap = isWFxTrapping(tc, targetEL, isWfe);
843 
844  if (trap) {
845  uint32_t iss = isWfe? 0x1E00001 : /* WFE Instruction syndrome */
846  0x1E00000; /* WFI Instruction syndrome */
847  switch (targetEL) {
848  case EL1:
849  return std::make_shared<UndefinedInstruction>(
850  machInst, iss,
852  case EL2:
853  return std::make_shared<HypervisorTrap>(machInst, iss,
855  case EL3:
856  return std::make_shared<SecureMonitorTrap>(machInst, iss,
858  default:
859  panic("Unrecognized Exception Level: %d\n", targetEL);
860  }
861  }
862 
863  return NoFault;
864 }
865 
866 Fault
868  ExceptionLevel targetEL,
869  bool isWfe) const
870 {
871  // Check if target exception level is implemented.
872  assert(ArmSystem::haveEL(tc, targetEL));
873 
874  // Check if processor needs to trap at selected exception level
875  bool trap = isWFxTrapping(tc, targetEL, isWfe);
876 
877  if (trap) {
878  uint32_t iss = isWfe? 0x1E00001 : /* WFE Instruction syndrome */
879  0x1E00000; /* WFI Instruction syndrome */
880  switch (targetEL) {
881  case EL1:
882  return std::make_shared<SupervisorTrap>(machInst, iss,
884  case EL2:
885  return std::make_shared<HypervisorTrap>(machInst, iss,
887  case EL3:
888  return std::make_shared<SecureMonitorTrap>(machInst, iss,
890  default:
891  panic("Unrecognized Exception Level: %d\n", targetEL);
892  }
893  }
894 
895  return NoFault;
896 }
897 
898 Fault
900  CPSR cpsr, SCR scr,
901  bool isWfe) const
902 {
903  Fault fault = NoFault;
904  ExceptionLevel curr_el = currEL(tc);
905 
906  if (curr_el == EL0) {
907  fault = checkForWFxTrap32(tc, EL1, isWfe);
908  }
909 
910  if ((fault == NoFault) && EL2Enabled(tc) &&
911  ((curr_el == EL0) || (curr_el == EL1))) {
912 
913  fault = checkForWFxTrap32(tc, EL2, isWfe);
914  }
915 
916  if ((fault == NoFault) &&
917  ArmSystem::haveEL(tc, EL3) && curr_el != EL3) {
918  fault = checkForWFxTrap32(tc, EL3, isWfe);
919  }
920 
921  return fault;
922 }
923 
924 Fault
926 {
927  bool setend_disabled(false);
928  ExceptionLevel pstate_el = currEL(tc);
929 
930  if (pstate_el == EL2) {
931  setend_disabled = ((SCTLR)tc->readMiscRegNoEffect(MISCREG_HSCTLR)).sed;
932  } else {
933  // Please note: in the armarm pseudocode there is a distinction
934  // whether EL1 is aarch32 or aarch64:
935  // if ELUsingAArch32(EL1) then SCTLR.SED else SCTLR[].SED;
936  // Considering that SETEND is aarch32 only, ELUsingAArch32(EL1)
937  // will always be true (hence using SCTLR.SED) except for
938  // instruction executed at EL0, and with an AArch64 EL1.
939  // In this case SCTLR_EL1 will be used. In gem5 the register is
940  // mapped to SCTLR_ns. We can safely use SCTLR and choose the
941  // appropriate bank version.
942 
943  // Get the index of the banked version of SCTLR:
944  // SCTLR_s or SCTLR_ns.
945  auto banked_sctlr = snsBankedIndex(
946  MISCREG_SCTLR, tc, !isSecure(tc));
947 
948  // SCTLR.SED bit is enabling/disabling the ue of SETEND instruction.
949  setend_disabled = ((SCTLR)tc->readMiscRegNoEffect(banked_sctlr)).sed;
950  }
951 
952  return setend_disabled ? undefinedFault32(tc, pstate_el) :
953  NoFault;
954 }
955 
956 Fault
958  ExceptionLevel pstateEL) const
959 {
960  // Even if we are running in aarch32, the fault might be dealt with in
961  // aarch64 ISA.
962  if (generalExceptionsToAArch64(tc, pstateEL)) {
963  return undefinedFault64(tc, pstateEL);
964  } else {
965  // Please note: according to the ARM ARM pseudocode we should handle
966  // the case when EL2 is aarch64 and HCR.TGE is 1 as well.
967  // However this case is already handled by the routeToHyp method in
968  // ArmFault class.
969  return std::make_shared<UndefinedInstruction>(
970  machInst, 0,
972  }
973 }
974 
975 Fault
977  ExceptionLevel pstateEL) const
978 {
979  switch (pstateEL) {
980  case EL0:
981  case EL1:
982  return std::make_shared<SupervisorTrap>(machInst, 0, EC_UNKNOWN);
983  case EL2:
984  return std::make_shared<HypervisorTrap>(machInst, 0, EC_UNKNOWN);
985  case EL3:
986  return std::make_shared<SecureMonitorTrap>(machInst, 0, EC_UNKNOWN);
987  default:
988  panic("Unrecognized Exception Level: %d\n", pstateEL);
989  break;
990  }
991 
992  return NoFault;
993 }
994 
995 Fault
997 {
998  switch (el) {
999  case EL1:
1000  return std::make_shared<SupervisorTrap>(machInst, 0, EC_TRAPPED_SVE);
1001  case EL2:
1002  return std::make_shared<HypervisorTrap>(machInst, 0, EC_TRAPPED_SVE);
1003  case EL3:
1004  return std::make_shared<SecureMonitorTrap>(machInst, 0,
1005  EC_TRAPPED_SVE);
1006 
1007  default:
1008  panic("Illegal EL in sveAccessTrap\n");
1009  }
1010 }
1011 
1012 Fault
1013 ArmStaticInst::checkSveEnabled(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
1014 {
1015  const ExceptionLevel el = (ExceptionLevel) (uint8_t) cpsr.el;
1016  // Check if access disabled in CPACR_EL1
1017  if (el <= EL1 && !ELIsInHost(tc, el)) {
1018  if ((el == EL0 && cpacr.zen == 0x1) ||
1019  (!(cpacr.zen & 0x1)))
1020  return sveAccessTrap(EL1);
1021 
1022  if ((el == EL0 && cpacr.fpen == 0x1) ||
1023  (!(cpacr.fpen & 0x1)))
1024  return advSIMDFPAccessTrap64(EL1);
1025  }
1026 
1027  // Check if access disabled in CPTR_EL2
1028  if (el <= EL2 && EL2Enabled(tc)) {
1029  CPTR cptr_en_check = tc->readMiscReg(MISCREG_CPTR_EL2);
1030  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1031  if (HaveVirtHostExt(tc) && hcr.e2h) {
1032  if (((cptr_en_check.zen & 0x1) == 0x0) ||
1033  (cptr_en_check.zen == 0x1 && el == EL0 &&
1034  hcr.tge == 0x1)) {
1035  return sveAccessTrap(EL2);
1036  }
1037  if (((cptr_en_check.fpen & 0x1) == 0x0) ||
1038  (cptr_en_check.fpen == 0x1 && el == EL0 &&
1039  hcr.tge == 0x1)) {
1040  return advSIMDFPAccessTrap64(EL2);
1041  }
1042  } else {
1043  if (cptr_en_check.tz == 1)
1044  return sveAccessTrap(EL2);
1045  if (cptr_en_check.tfp == 1)
1046  return advSIMDFPAccessTrap64(EL2);
1047  }
1048  }
1049 
1050  // Check if access disabled in CPTR_EL3
1051  if (ArmSystem::haveSecurity(tc)) {
1052  CPTR cptr_en_check = tc->readMiscReg(MISCREG_CPTR_EL3);
1053  if (!cptr_en_check.ez)
1054  return sveAccessTrap(EL3);
1055  if (cptr_en_check.tfp)
1056  return advSIMDFPAccessTrap64(EL3);
1057  }
1058 
1059  return NoFault;
1060 }
1061 
1062 static uint8_t
1064 {
1065  // See: shared/functions/system/RestoredITBits in the ARM ARM
1066 
1067  const ExceptionLevel el = opModeToEL((OperatingMode) (uint8_t)spsr.mode);
1068  const uint8_t it = itState(spsr);
1069 
1070  if (!spsr.t || spsr.il)
1071  return 0;
1072 
1073  // The IT bits are forced to zero when they are set to a reserved
1074  // value.
1075  if (bits(it, 7, 4) != 0 && bits(it, 3, 0) == 0)
1076  return 0;
1077 
1078  const bool itd = el == EL2 ?
1079  ((SCTLR)tc->readMiscReg(MISCREG_HSCTLR)).itd :
1080  ((SCTLR)tc->readMiscReg(MISCREG_SCTLR)).itd;
1081 
1082  // The IT bits are forced to zero when returning to A32 state, or
1083  // when returning to an EL with the ITD bit set to 1, and the IT
1084  // bits are describing a multi-instruction block.
1085  if (itd && bits(it, 2, 0) != 0)
1086  return 0;
1087 
1088  return it;
1089 }
1090 
1091 static bool
1092 illegalExceptionReturn(ThreadContext *tc, CPSR cpsr, CPSR spsr)
1093 {
1094  const OperatingMode mode = (OperatingMode) (uint8_t)spsr.mode;
1095  if (unknownMode(mode))
1096  return true;
1097 
1098  SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
1099  HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
1100 
1101  //ELFromSPSR
1102  bool valid;
1103  ExceptionLevel target_el = opModeToEL(mode);
1104  if (!spsr.width) {
1105  if (!ArmSystem::highestELIs64(tc)) {
1106  valid = false;
1107  } else if (!ArmSystem::haveEL(tc, target_el)) {
1108  valid = false;
1109  } else if (spsr & 0x2) {
1110  valid = false;
1111  } else if (target_el == EL0 && spsr.sp) {
1112  valid = false;
1113  } else if (target_el == EL2 && ArmSystem::haveEL(tc, EL3) &&
1114  !scr.ns && !IsSecureEL2Enabled(tc)) {
1115  valid = false;
1116  } else {
1117  valid = true;
1118  }
1119  } else {
1120  valid = !unknownMode32(mode);
1121  }
1122  if (!valid)
1123  return true;
1124 
1125  if (target_el > currEL(tc))
1126  return true;
1127 
1128  bool spsr_mode_is_aarch32 = (spsr.width == 1);
1129  bool known, target_el_is_aarch32;
1130  std::tie(known, target_el_is_aarch32) = ELUsingAArch32K(tc, target_el);
1131  assert(known || (target_el == EL0 && ELIs64(tc, EL1)));
1132 
1133  if (known && (spsr_mode_is_aarch32 != target_el_is_aarch32))
1134  return true;
1135 
1136  if (target_el == EL1 && ArmSystem::haveEL(tc, EL2) && hcr.tge &&
1137  (IsSecureEL2Enabled(tc) || !isSecureBelowEL3(tc))) {
1138  return true;
1139  }
1140 
1141  return false;
1142 }
1143 
1144 CPSR
1145 ArmStaticInst::getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const
1146 {
1147  CPSR new_cpsr = 0;
1148  ExceptionLevel dest;
1149 
1150  if (illegalExceptionReturn(tc, cpsr, spsr)) {
1151  // If the SPSR specifies an illegal exception return,
1152  // then PSTATE.{M, nRW, EL, SP} are unchanged and PSTATE.IL
1153  // is set to 1.
1154  new_cpsr.il = 1;
1155  if (cpsr.width) {
1156  new_cpsr.mode = cpsr.mode;
1157  } else {
1158  new_cpsr.width = cpsr.width;
1159  new_cpsr.el = cpsr.el;
1160  new_cpsr.sp = cpsr.sp;
1161  }
1162  dest = currEL(tc);
1163  } else {
1164  new_cpsr.il = spsr.il;
1165  if (spsr.width && unknownMode32((OperatingMode)(uint8_t)spsr.mode)) {
1166  new_cpsr.il = 1;
1167  } else if (spsr.width) {
1168  new_cpsr.mode = spsr.mode;
1169  } else {
1170  new_cpsr.el = spsr.el;
1171  new_cpsr.sp = spsr.sp;
1172  }
1173  dest = (ExceptionLevel)(uint8_t) spsr.el;
1174  }
1175 
1176  new_cpsr.nz = spsr.nz;
1177  new_cpsr.c = spsr.c;
1178  new_cpsr.v = spsr.v;
1179  new_cpsr.pan = spsr.pan;
1180  if (new_cpsr.width) {
1181  // aarch32
1182  const ITSTATE it = getRestoredITBits(tc, spsr);
1183  new_cpsr.q = spsr.q;
1184  new_cpsr.ge = spsr.ge;
1185  new_cpsr.e = spsr.e;
1186  new_cpsr.aif = spsr.aif;
1187  new_cpsr.t = spsr.t;
1188  new_cpsr.it2 = it.top6;
1189  new_cpsr.it1 = it.bottom2;
1190  } else {
1191  // aarch64
1192  new_cpsr.daif = spsr.daif;
1193  }
1194 
1196  SoftwareStep *ss = sd->getSstep();
1197  new_cpsr.ss = ss->debugExceptionReturnSS(tc, spsr, dest);
1198 
1199  return new_cpsr;
1200 }
1201 
1202 bool
1204  ExceptionLevel pstateEL) const
1205 {
1206  // Returns TRUE if exceptions normally routed to EL1 are being handled
1207  // at an Exception level using AArch64, because either EL1 is using
1208  // AArch64 or TGE is in force and EL2 is using AArch64.
1209  HCR hcr = ((HCR)tc->readMiscReg(MISCREG_HCR_EL2));
1210  return (pstateEL == EL0 && !ELIs32(tc, EL1)) ||
1211  (ArmSystem::haveEL(tc, EL2) && !isSecure(tc) &&
1212  !ELIs32(tc, EL2) && hcr.tge);
1213 }
1214 
1215 unsigned
1217 {
1218  auto *isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr());
1219  return isa->getCurSveVecLenInBits();
1220 }
1221 
1222 }
ArmISA::SelfDebug
Definition: self_debug.hh:273
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
ArmISA::ELIsInHost
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:392
ArmISA::COND_PL
@ COND_PL
Definition: ccregs.hh:69
ArmISA::ArmStaticInst::readPC
static Addr readPC(ExecContext *xc)
Definition: static_inst.hh:309
ArmISA::EL2Enabled
bool EL2Enabled(ThreadContext *tc)
Definition: utility.cc:369
Loader::SymbolTable::findNearest
const_iterator findNearest(Addr addr, Addr &nextaddr) const
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
Definition: symtab.hh:209
ArmISA::COND_EQ
@ COND_EQ
Definition: ccregs.hh:64
ArmISA::advsimd
Bitfield< 23, 20 > advsimd
Definition: miscregs_types.hh:172
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
ArmISA::EL2
@ EL2
Definition: types.hh:624
ArmISA::MISCREG_HCPTR
@ MISCREG_HCPTR
Definition: miscregs.hh:245
ArmISA::ArmShiftType
ArmShiftType
Definition: types.hh:567
ArmISA::HaveVirtHostExt
bool HaveVirtHostExt(ThreadContext *tc)
Definition: utility.cc:326
ArmISA::ConditionCode
ConditionCode
Definition: ccregs.hh:63
ArmISA::ArmFault::BRKPOINT
@ BRKPOINT
Definition: faults.hh:156
ArmISA::sed
Bitfield< 8 > sed
Definition: miscregs_types.hh:374
ArmISA::ArmStaticInst::printCCReg
void printCCReg(std::ostream &os, RegIndex reg_idx) const
Definition: static_inst.cc:361
ArmSystem::highestELIs64
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition: system.hh:204
ArmISA::COND_VC
@ COND_VC
Definition: ccregs.hh:71
ArmISA::ArmStaticInst::isWFxTrapping
bool isWFxTrapping(ThreadContext *tc, ExceptionLevel targetEL, bool isWfe) const
Definition: static_inst.cc:800
X86ISA::exit
Bitfield< 3 > exit
Definition: misc.hh:848
ArmISA::EL0
@ EL0
Definition: types.hh:622
ArmISA::COND_UC
@ COND_UC
Definition: ccregs.hh:79
ArmISA::snsBankedIndex
int snsBankedIndex(MiscRegIndex reg, ThreadContext *tc)
Definition: miscregs.cc:1311
ArmISA::width
Bitfield< 4 > width
Definition: miscregs_types.hh:68
ArmISA::ArmStaticInst::checkForWFxTrap64
Fault checkForWFxTrap64(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch64 should be trapped.
Definition: static_inst.cc:867
ArmISA::OperatingMode
OperatingMode
Definition: types.hh:628
ArmISA::currEL
static ExceptionLevel currEL(const ThreadContext *tc)
Definition: utility.hh:143
ArmISA::ArmStaticInst::sveAccessTrap
Fault sveAccessTrap(ExceptionLevel el) const
Trap an access to SVE registers due to access control bits.
Definition: static_inst.cc:996
ArmISA::ArmStaticInst::checkFPAdvSIMDEnabled64
Fault checkFPAdvSIMDEnabled64(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an Advaned SIMD access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
Definition: static_inst.cc:711
type
uint8_t type
Definition: inet.hh:421
ArmISA::EC_TRAPPED_WFI_WFE
@ EC_TRAPPED_WFI_WFE
Definition: types.hh:651
Loader::SymbolTable
Definition: symtab.hh:59
ArmISA::IntRegIndex
IntRegIndex
Definition: intregs.hh:51
ArmISA::INTREG_ZERO
@ INTREG_ZERO
Definition: intregs.hh:112
ArmISA::ArmFault::UnknownTran
@ UnknownTran
Definition: faults.hh:150
ArmISA::itState
static uint8_t itState(CPSR psr)
Definition: utility.hh:220
ArmISA::SXTW
@ SXTW
Definition: types.hh:582
X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
ArmISA::ArmStaticInst::advSIMDFPAccessTrap64
Fault advSIMDFPAccessTrap64(ExceptionLevel el) const
Trap an access to Advanced SIMD or FP registers due to access control bits.
Definition: static_inst.cc:652
ArmISA::ArmStaticInst::printIntReg
void printIntReg(std::ostream &os, RegIndex reg_idx, uint8_t opWidth=0) const
Print a register name for disassembly given the unique dependence tag number (FP or int).
Definition: static_inst.cc:296
ArmISA::ArmStaticInst::shiftReg64
int64_t shiftReg64(uint64_t base, uint64_t shiftAmt, ArmShiftType type, uint8_t width) const
Definition: static_inst.cc:92
ArmISA::ArmStaticInst::shift_rm_imm
int32_t shift_rm_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Definition: static_inst.cc:57
ArmISA::EL3
@ EL3
Definition: types.hh:625
ArmISA::ISA
Definition: isa.hh:65
ArmISA::UXTW
@ UXTW
Definition: types.hh:578
ArmISA::ArmStaticInst::printShiftOperand
void printShiftOperand(std::ostream &os, IntRegIndex rm, bool immShift, uint32_t shiftAmt, IntRegIndex rs, ArmShiftType type) const
Definition: static_inst.cc:495
ArmISA::miscRegName
const char *const miscRegName[]
Definition: miscregs.hh:1159
ArmISA::illegalExceptionReturn
static bool illegalExceptionReturn(ThreadContext *tc, CPSR cpsr, CPSR spsr)
Definition: static_inst.cc:1092
ArmISA::ArmStaticInst::printMemSymbol
void printMemSymbol(std::ostream &os, const Loader::SymbolTable *symtab, const std::string &prefix, const Addr addr, const std::string &suffix) const
Definition: static_inst.cc:477
ArmISA
Definition: ccregs.hh:41
ArmSystem::haveVirtualization
bool haveVirtualization() const
Returns true if this system implements the virtualization Extensions.
Definition: system.hh:170
ArmISA::ArmFault::DebugEvent
@ DebugEvent
Definition: faults.hh:101
ArmISA::COND_VS
@ COND_VS
Definition: ccregs.hh:70
ArmISA::itd
Bitfield< 7 > itd
Definition: miscregs_types.hh:377
ArmISA::ELIs64
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:377
ThreadContext::getIsaPtr
virtual BaseISA * getIsaPtr()=0
ArmISA::IsSecureEL2Enabled
bool IsSecureEL2Enabled(ThreadContext *tc)
Definition: utility.cc:355
ArmISA::ArmStaticInst::shift_carry_imm
bool shift_carry_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Definition: static_inst.cc:217
ArmISA::ArmStaticInst::softwareBreakpoint32
Fault softwareBreakpoint32(ExecContext *xc, uint16_t imm) const
Trigger a Software Breakpoint.
Definition: static_inst.cc:632
ArmISA::ArmStaticInst::checkForWFxTrap32
Fault checkForWFxTrap32(ThreadContext *tc, ExceptionLevel tgtEl, bool isWfe) const
Check if WFE/WFI instruction execution in aarch32 should be trapped.
Definition: static_inst.cc:827
ArmISA::INTREG_SPX
@ INTREG_SPX
Definition: intregs.hh:160
ArmISA::SXTX
@ SXTX
Definition: types.hh:583
ArmISA::ArmStaticInst::printExtendOperand
void printExtendOperand(bool firstOperand, std::ostream &os, IntRegIndex rm, ArmExtendType type, int64_t shiftAmt) const
Definition: static_inst.cc:559
ArmISA::ArmStaticInst::checkSETENDEnabled
Fault checkSETENDEnabled(ThreadContext *tc, CPSR cpsr) const
Check if SETEND instruction execution in aarch32 should be trapped.
Definition: static_inst.cc:925
ArmISA::ELIs32
bool ELIs32(ThreadContext *tc, ExceptionLevel el)
Definition: utility.cc:383
ArmISA::rn
Bitfield< 19, 16 > rn
Definition: types.hh:122
ArmISA::EC_TRAPPED_SVE
@ EC_TRAPPED_SVE
Definition: types.hh:672
ArmISA::ArmStaticInst::extendReg64
int64_t extendReg64(uint64_t base, ArmExtendType type, uint64_t shiftAmt, uint8_t width) const
Definition: static_inst.cc:131
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
ArmSystem::haveSecurity
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
Definition: system.hh:161
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ArmISA::ROR
@ ROR
Definition: types.hh:571
ArmISA::ArmStaticInst::getCurSveVecLenInBits
static unsigned getCurSveVecLenInBits(ThreadContext *tc)
Definition: static_inst.cc:1216
ArmISA::ExceptionLevel
ExceptionLevel
Definition: types.hh:621
ArmISA::COND_AL
@ COND_AL
Definition: ccregs.hh:78
ArmISA::imm
Bitfield< 7, 0 > imm
Definition: types.hh:141
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
isa.hh
ArmISA::ArmStaticInst::undefinedFault32
Fault undefinedFault32(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch32.
Definition: static_inst.cc:957
ArmISA::ccRegName
const char *const ccRegName[NUM_CCREGS]
Definition: ccregs.hh:54
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
ArmISA::COND_GT
@ COND_GT
Definition: ccregs.hh:76
ArmISA::LSL
@ LSL
Definition: types.hh:568
ArmISA::el
Bitfield< 3, 2 > el
Definition: miscregs_types.hh:69
ArmISA::ArmStaticInst::printMiscReg
void printMiscReg(std::ostream &os, RegIndex reg_idx) const
Definition: static_inst.cc:367
ExecContext
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:70
ArmISA::FramePointerReg
const int FramePointerReg
Definition: registers.hh:113
ArmISA::sd
Bitfield< 4 > sd
Definition: miscregs_types.hh:768
ArmISA::ArmStaticInst::intWidth
uint8_t intWidth
Definition: static_inst.hh:64
ArmISA::ArmStaticInst::shift_carry_rs
bool shift_carry_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Definition: static_inst.cc:257
ArmISA::opModeToEL
static ExceptionLevel opModeToEL(OperatingMode mode)
Definition: types.hh:736
ArmISA::rd
Bitfield< 15, 12 > rd
Definition: types.hh:123
StaticInst::mnemonic
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:258
cprintf.hh
ArmISA::SXTH
@ SXTH
Definition: types.hh:581
ArmISA::COND_LS
@ COND_LS
Definition: ccregs.hh:73
faults.hh
ArmISA::ArmStaticInst::checkFPAdvSIMDTrap64
Fault checkFPAdvSIMDTrap64(ThreadContext *tc, CPSR cpsr) const
Check an Advaned SIMD access against CPTR_EL2 and CPTR_EL3.
Definition: static_inst.cc:672
ArmISA::MISCREG_HCR_EL2
@ MISCREG_HCR_EL2
Definition: miscregs.hh:578
ArmISA::ELUsingAArch32K
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:402
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
ArmISA::getRestoredITBits
static uint8_t getRestoredITBits(ThreadContext *tc, CPSR spsr)
Definition: static_inst.cc:1063
ArmISA::ArmStaticInst::aarch64
bool aarch64
Definition: static_inst.hh:63
ArmISA::EL1
@ EL1
Definition: types.hh:623
ArmISA::ArmStaticInst::printCondition
void printCondition(std::ostream &os, unsigned code, bool noImplicit=false) const
Definition: static_inst.cc:414
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ArmISA::rm
Bitfield< 3, 0 > rm
Definition: types.hh:127
ArmISA::ArmStaticInst::printVecPredReg
void printVecPredReg(std::ostream &os, RegIndex reg_idx) const
Definition: static_inst.cc:355
ArmISA::MISCREG_HSCTLR
@ MISCREG_HSCTLR
Definition: miscregs.hh:240
ArmISA::LSR
@ LSR
Definition: types.hh:569
ArmISA::ArmStaticInst::printVecReg
void printVecReg(std::ostream &os, RegIndex reg_idx, bool isSveVecReg=false) const
Definition: static_inst.cc:348
utility.hh
ArmISA::ISA::getSelfDebug
SelfDebug * getSelfDebug() const
Definition: isa.hh:476
ArmISA::SoftwareStep
Definition: self_debug.hh:191
ArmISA::UXTH
@ UXTH
Definition: types.hh:577
ArmISA::ArmStaticInst::checkAdvSIMDOrFPEnabled32
Fault checkAdvSIMDOrFPEnabled32(ThreadContext *tc, CPSR cpsr, CPACR cpacr, NSACR nsacr, FPEXC fpexc, bool fpexc_check, bool advsimd) const
Check if a VFP/SIMD access from aarch32 should be allowed.
Definition: static_inst.cc:723
ArmISA::ArmExtendType
ArmExtendType
Definition: types.hh:575
ArmISA::ArmStaticInst::printFloatReg
void printFloatReg(std::ostream &os, RegIndex reg_idx) const
Definition: static_inst.cc:342
ArmISA::COND_HI
@ COND_HI
Definition: ccregs.hh:72
ArmISA::MISCREG_SCR_EL3
@ MISCREG_SCR_EL3
Definition: miscregs.hh:585
ArmISA::unknownMode32
static bool unknownMode32(OperatingMode mode)
Definition: types.hh:791
Loader::SymbolTable::end
const_iterator end() const
Definition: symtab.hh:126
ArmISA::ArmStaticInst::generalExceptionsToAArch64
bool generalExceptionsToAArch64(ThreadContext *tc, ExceptionLevel pstateEL) const
Return true if exceptions normally routed to EL1 are being handled at an Exception level using AArch6...
Definition: static_inst.cc:1203
ArmISA::MISCREG_CPTR_EL2
@ MISCREG_CPTR_EL2
Definition: miscregs.hh:580
ArmISA::COND_LE
@ COND_LE
Definition: ccregs.hh:77
ArmISA::ArmStaticInst::printDataInst
void printDataInst(std::ostream &os, bool withImm) const
ExecContext::tcBase
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
ArmISA::EC_TRAPPED_HCPTR
@ EC_TRAPPED_HCPTR
Definition: types.hh:656
condcodes.hh
ArmISA::isSecureBelowEL3
bool isSecureBelowEL3(ThreadContext *tc)
Definition: utility.cc:186
StaticInst::machInst
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:243
ArmISA::StackPointerReg
const int StackPointerReg
Definition: registers.hh:114
RegIndex
uint16_t RegIndex
Definition: types.hh:52
ArmISA::MISCREG_MDCR_EL2
@ MISCREG_MDCR_EL2
Definition: miscregs.hh:579
ArmISA::INTREG_UREG0
@ INTREG_UREG0
Definition: intregs.hh:113
ArmISA::NUM_MISCREGS
@ NUM_MISCREGS
Definition: miscregs.hh:1088
ThreadContext::readMiscReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
static_inst.hh
ArmISA::ArmStaticInst::trapWFx
Fault trapWFx(ThreadContext *tc, CPSR cpsr, SCR scr, bool isWfe) const
WFE/WFI trapping helper function.
Definition: static_inst.cc:899
ArmISA::len
Bitfield< 18, 16 > len
Definition: miscregs_types.hh:439
ArmISA::ArmStaticInst::printMnemonic
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const
Definition: static_inst.cc:374
addr
ip6_addr_t addr
Definition: inet.hh:423
reg_class.hh
ArmISA::INTREG_X31
@ INTREG_X31
Definition: intregs.hh:158
ArmISA::COND_LT
@ COND_LT
Definition: ccregs.hh:75
ArmISA::COND_CS
@ COND_CS
Definition: ccregs.hh:66
ArmSystem::haveEL
static bool haveEL(ThreadContext *tc, ArmISA::ExceptionLevel el)
Return true if the system implements a specific exception level.
Definition: system.cc:135
ArmISA::unknownMode
static bool unknownMode(OperatingMode mode)
Definition: types.hh:765
ArmISA::UXTB
@ UXTB
Definition: types.hh:576
ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:127
ArmISA::SXTB
@ SXTB
Definition: types.hh:580
ArmISA::rs
Bitfield< 9, 8 > rs
Definition: miscregs_types.hh:372
ArmISA::EC_UNKNOWN
@ EC_UNKNOWN
Definition: types.hh:650
ArmISA::COND_MI
@ COND_MI
Definition: ccregs.hh:68
ArmISA::ArmStaticInst::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: static_inst.cc:623
ArmISA::ReturnAddressReg
const int ReturnAddressReg
Definition: registers.hh:115
ArmISA::PCReg
const int PCReg
Definition: registers.hh:116
ArmISA::ArmStaticInst::getPSTATEFromPSR
CPSR getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const
Get the new PSTATE from a SPSR register in preparation for an exception return.
Definition: static_inst.cc:1145
symtab.hh
ArmISA::MISCREG_SCTLR
@ MISCREG_SCTLR
Definition: miscregs.hh:229
ArmISA::ISA::getCurSveVecLenInBits
unsigned getCurSveVecLenInBits() const
Definition: isa.cc:2290
self_debug.hh
ArmISA::ASR
@ ASR
Definition: types.hh:570
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
ArmISA::ArmStaticInst::checkSveEnabled
Fault checkSveEnabled(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const
Check an SVE access against CPACR_EL1, CPTR_EL2, and CPTR_EL3.
Definition: static_inst.cc:1013
ArmISA::ArmStaticInst::printTarget
void printTarget(std::ostream &os, Addr target, const Loader::SymbolTable *symtab) const
Definition: static_inst.cc:395
ArmISA::COND_CC
@ COND_CC
Definition: ccregs.hh:67
ArmISA::ArmStaticInst::shift_rm_rs
int32_t shift_rm_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const
Definition: static_inst.cc:177
ArmISA::COND_NE
@ COND_NE
Definition: ccregs.hh:65
ArmISA::EC_TRAPPED_SIMD_FP
@ EC_TRAPPED_SIMD_FP
Definition: types.hh:657
ArmISA::MISCREG_CPTR_EL3
@ MISCREG_CPTR_EL3
Definition: miscregs.hh:587
ArmISA::ArmStaticInst::printPFflags
void printPFflags(std::ostream &os, int flag) const
Definition: static_inst.cc:331
ArmISA::COND_GE
@ COND_GE
Definition: ccregs.hh:74
ArmISA::ArmStaticInst::undefinedFault64
Fault undefinedFault64(ThreadContext *tc, ExceptionLevel el) const
UNDEFINED behaviour in AArch64.
Definition: static_inst.cc:976
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711
ArmISA::MISCREG_SCTLR_EL1
@ MISCREG_SCTLR_EL1
Definition: miscregs.hh:571
ArmISA::isSecure
bool isSecure(ThreadContext *tc)
Definition: utility.cc:174
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
ArmISA::ArmStaticInst::disabledFault
Fault disabledFault() const
Definition: static_inst.hh:375
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75
ArmISA::UXTX
@ UXTX
Definition: types.hh:579

Generated on Wed Sep 30 2020 14:02:00 for gem5 by doxygen 1.8.17