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

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0