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

Generated on Mon Jan 13 2025 04:28:21 for gem5 by doxygen 1.9.8