2 * Copyright (c) 2009-2014, 2016 ARM Limited
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.
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.
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.
40 #include "arch/arm/utility.hh"
44 #include "arch/arm/faults.hh"
45 #include "arch/arm/isa_traits.hh"
46 #include "arch/arm/system.hh"
47 #include "arch/arm/tlb.hh"
48 #include "arch/arm/vtophys.hh"
49 #include "cpu/base.hh"
50 #include "cpu/checker/cpu.hh"
51 #include "cpu/thread_context.hh"
52 #include "mem/fs_translating_port_proxy.hh"
53 #include "sim/full_system.hh"
58 initCPU(ThreadContext
*tc
, int cpuId
)
60 // Reset CP15?? What does that mean -- ali
64 static Fault reset
= std::make_shared
<Reset
>();
69 getArgument(ThreadContext
*tc
, int &number
, uint16_t size
, bool fp
)
72 panic("getArgument() only implemented for full system mode.\n");
77 panic("getArgument(): Floating point arguments not implemented\n");
80 if (size
== (uint16_t)(-1))
81 size
= sizeof(uint64_t);
83 if (number
< 8 /*NumArgumentRegs64*/) {
84 return tc
->readIntReg(number
);
86 panic("getArgument(): No support reading stack args for AArch64\n");
89 if (size
== (uint16_t)(-1))
90 // todo: should this not be sizeof(uint32_t) rather?
91 size
= ArmISA::MachineBytes
;
93 if (number
< NumArgumentRegs
) {
94 // If the argument is 64 bits, it must be in an even regiser
95 // number. Increment the number here if it isn't even.
96 if (size
== sizeof(uint64_t)) {
97 if ((number
% 2) != 0)
99 // Read the two halves of the data. Number is inc here to
100 // get the second half of the 64 bit reg.
102 tmp
= tc
->readIntReg(number
++);
103 tmp
|= tc
->readIntReg(number
) << 32;
106 return tc
->readIntReg(number
);
109 Addr sp
= tc
->readIntReg(StackPointerReg
);
110 FSTranslatingPortProxy
&vp
= tc
->getVirtProxy();
112 if (size
== sizeof(uint64_t)) {
113 // If the argument is even it must be aligned
114 if ((number
% 2) != 0)
116 arg
= vp
.read
<uint64_t>(sp
+
117 (number
-NumArgumentRegs
) * sizeof(uint32_t));
118 // since two 32 bit args == 1 64 bit arg, increment number
121 arg
= vp
.read
<uint32_t>(sp
+
122 (number
-NumArgumentRegs
) * sizeof(uint32_t));
127 panic("getArgument() should always return\n");
131 skipFunction(ThreadContext
*tc
)
133 PCState newPC
= tc
->pcState();
135 newPC
.set(tc
->readIntReg(INTREG_X30
));
137 newPC
.set(tc
->readIntReg(ReturnAddressReg
) & ~ULL(1));
140 CheckerCPU
*checker
= tc
->getCheckerCpuPtr();
142 tc
->pcStateNoRecord(newPC
);
149 copyRegs(ThreadContext
*src
, ThreadContext
*dest
)
151 for (int i
= 0; i
< NumIntRegs
; i
++)
152 dest
->setIntRegFlat(i
, src
->readIntRegFlat(i
));
154 for (int i
= 0; i
< NumFloatRegs
; i
++)
155 dest
->setFloatRegFlat(i
, src
->readFloatRegFlat(i
));
157 for (int i
= 0; i
< NumCCRegs
; i
++)
158 dest
->setCCReg(i
, src
->readCCReg(i
));
160 for (int i
= 0; i
< NumMiscRegs
; i
++)
161 dest
->setMiscRegNoEffect(i
, src
->readMiscRegNoEffect(i
));
163 // setMiscReg "with effect" will set the misc register mapping correctly.
164 // e.g. updateRegMap(val)
165 dest
->setMiscReg(MISCREG_CPSR
, src
->readMiscRegNoEffect(MISCREG_CPSR
));
167 // Copy over the PC State
168 dest
->pcState(src
->pcState());
170 // Invalidate the tlb misc register cache
171 dest
->getITBPtr()->invalidateMiscReg();
172 dest
->getDTBPtr()->invalidateMiscReg();
176 inSecureState(ThreadContext
*tc
)
178 SCR scr
= inAArch64(tc
) ? tc
->readMiscReg(MISCREG_SCR_EL3
) :
179 tc
->readMiscReg(MISCREG_SCR
);
180 return ArmSystem::haveSecurity(tc
) && inSecureState(
181 scr
, tc
->readMiscReg(MISCREG_CPSR
));
185 inAArch64(ThreadContext
*tc
)
187 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
188 return opModeIs64((OperatingMode
) (uint8_t) cpsr
.mode
);
192 longDescFormatInUse(ThreadContext
*tc
)
194 TTBCR ttbcr
= tc
->readMiscReg(MISCREG_TTBCR
);
195 return ArmSystem::haveLPAE(tc
) && ttbcr
.eae
;
199 getMPIDR(ArmSystem
*arm_sys
, ThreadContext
*tc
)
201 // Multiprocessor Affinity Register MPIDR from Cortex(tm)-A15 Technical
204 // bit 31 - Multi-processor extensions available
205 // bit 30 - Uni-processor system
206 // bit 24 - Multi-threaded cores
207 // bit 11-8 - Cluster ID
210 // We deliberately extend both the Cluster ID and CPU ID fields to allow
211 // for simulation of larger systems
212 assert((0 <= tc
->cpuId()) && (tc
->cpuId() < 256));
213 assert(tc
->socketId() < 65536);
214 if (arm_sys
->multiThread
) {
215 return 0x80000000 | // multiprocessor extensions available
217 } else if (arm_sys
->multiProc
) {
218 return 0x80000000 | // multiprocessor extensions available
219 tc
->cpuId() | tc
->socketId() << 8;
221 return 0x80000000 | // multiprocessor extensions available
222 0x40000000 | // in up system
223 tc
->cpuId() | tc
->socketId() << 8;
228 ELIs64(ThreadContext
*tc
, ExceptionLevel el
)
230 if (ArmSystem::highestEL(tc
) == el
)
231 // Register width is hard-wired
232 return ArmSystem::highestELIs64(tc
);
236 return opModeIs64(currOpMode(tc
));
239 if (ArmSystem::haveVirtualization(tc
)) {
240 HCR hcr
= tc
->readMiscReg(MISCREG_HCR_EL2
);
242 } else if (ArmSystem::haveSecurity(tc
)) {
243 SCR scr
= tc
->readMiscReg(MISCREG_SCR_EL3
);
246 panic("must haveSecurity(tc)");
250 assert(ArmSystem::haveSecurity(tc
));
251 SCR scr
= tc
->readMiscReg(MISCREG_SCR_EL3
);
255 panic("Invalid exception level");
261 isBigEndian64(ThreadContext
*tc
)
263 switch (opModeToEL(currOpMode(tc
))) {
265 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL3
)).ee
;
267 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL2
)).ee
;
269 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL1
)).ee
;
271 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL1
)).e0e
;
273 panic("Invalid exception level");
279 purifyTaggedAddr(Addr addr
, ThreadContext
*tc
, ExceptionLevel el
,
285 if (bits(addr
, 55, 48) == 0xFF && tcr
.tbi1
)
286 return addr
| mask(63, 55);
287 else if (!bits(addr
, 55, 48) && tcr
.tbi0
)
288 return bits(addr
,55, 0);
291 assert(ArmSystem::haveVirtualization(tc
));
292 tcr
= tc
->readMiscReg(MISCREG_TCR_EL2
);
294 return addr
& mask(56);
297 assert(ArmSystem::haveSecurity(tc
));
299 return addr
& mask(56);
302 panic("Invalid exception level");
306 return addr
; // Nothing to do if this is not a tagged address
310 purifyTaggedAddr(Addr addr
, ThreadContext
*tc
, ExceptionLevel el
)
317 tcr
= tc
->readMiscReg(MISCREG_TCR_EL1
);
318 if (bits(addr
, 55, 48) == 0xFF && tcr
.tbi1
)
319 return addr
| mask(63, 55);
320 else if (!bits(addr
, 55, 48) && tcr
.tbi0
)
321 return bits(addr
,55, 0);
324 assert(ArmSystem::haveVirtualization(tc
));
325 tcr
= tc
->readMiscReg(MISCREG_TCR_EL2
);
327 return addr
& mask(56);
330 assert(ArmSystem::haveSecurity(tc
));
331 tcr
= tc
->readMiscReg(MISCREG_TCR_EL3
);
333 return addr
& mask(56);
336 panic("Invalid exception level");
340 return addr
; // Nothing to do if this is not a tagged address
346 return addr
& ~(PageBytes
- 1);
352 return (addr
+ PageBytes
- 1) & ~(PageBytes
- 1);
356 mcrMrc15TrapToHyp(const MiscRegIndex miscReg
, HCR hcr
, CPSR cpsr
, SCR scr
,
357 HDCR hdcr
, HSTR hstr
, HCPTR hcptr
, uint32_t iss
)
365 bool trapToHype
= false;
368 if (!inSecureState(scr
, cpsr
) && (cpsr
.mode
!= MODE_HYP
)) {
369 mcrMrcIssExtract(iss
, isRead
, crm
, rt
, crn
, opc1
, opc2
);
370 trapToHype
= ((uint32_t) hstr
) & (1 << crn
);
371 trapToHype
|= hdcr
.tpm
&& (crn
== 9) && (crm
>= 12);
372 trapToHype
|= hcr
.tidcp
&& (
373 ((crn
== 9) && ((crm
<= 2) || ((crm
>= 5) && (crm
<= 8)))) ||
374 ((crn
== 10) && ((crm
<= 1) || (crm
== 4) || (crm
== 8))) ||
375 ((crn
== 11) && ((crm
<= 8) || (crm
== 15))) );
378 switch (unflattenMiscReg(miscReg
)) {
380 trapToHype
= hcptr
.tcpac
;
386 trapToHype
= hcr
.tid1
;
392 trapToHype
= hcr
.tid2
;
394 case MISCREG_ID_PFR0
:
395 case MISCREG_ID_PFR1
:
396 case MISCREG_ID_DFR0
:
397 case MISCREG_ID_AFR0
:
398 case MISCREG_ID_MMFR0
:
399 case MISCREG_ID_MMFR1
:
400 case MISCREG_ID_MMFR2
:
401 case MISCREG_ID_MMFR3
:
402 case MISCREG_ID_ISAR0
:
403 case MISCREG_ID_ISAR1
:
404 case MISCREG_ID_ISAR2
:
405 case MISCREG_ID_ISAR3
:
406 case MISCREG_ID_ISAR4
:
407 case MISCREG_ID_ISAR5
:
408 trapToHype
= hcr
.tid3
;
413 trapToHype
= hcr
.tsw
;
415 case MISCREG_DCIMVAC
:
416 case MISCREG_DCCIMVAC
:
417 case MISCREG_DCCMVAC
:
418 trapToHype
= hcr
.tpc
;
420 case MISCREG_ICIMVAU
:
421 case MISCREG_ICIALLU
:
422 case MISCREG_ICIALLUIS
:
423 case MISCREG_DCCMVAU
:
424 trapToHype
= hcr
.tpu
;
426 case MISCREG_TLBIALLIS
:
427 case MISCREG_TLBIMVAIS
:
428 case MISCREG_TLBIASIDIS
:
429 case MISCREG_TLBIMVAAIS
:
430 case MISCREG_DTLBIALL
:
431 case MISCREG_ITLBIALL
:
432 case MISCREG_DTLBIMVA
:
433 case MISCREG_ITLBIMVA
:
434 case MISCREG_DTLBIASID
:
435 case MISCREG_ITLBIASID
:
436 case MISCREG_TLBIMVAA
:
437 case MISCREG_TLBIALL
:
438 case MISCREG_TLBIMVA
:
439 case MISCREG_TLBIASID
:
440 trapToHype
= hcr
.ttlb
;
443 trapToHype
= hcr
.tac
;
460 case MISCREG_CONTEXTIDR
:
461 trapToHype
= hcr
.tvm
& !isRead
;
464 trapToHype
= hdcr
.tpmcr
;
466 // No default action needed
477 mcrMrc14TrapToHyp(const MiscRegIndex miscReg
, HCR hcr
, CPSR cpsr
, SCR scr
,
478 HDCR hdcr
, HSTR hstr
, HCPTR hcptr
, uint32_t iss
)
486 bool trapToHype
= false;
488 if (!inSecureState(scr
, cpsr
) && (cpsr
.mode
!= MODE_HYP
)) {
489 mcrMrcIssExtract(iss
, isRead
, crm
, rt
, crn
, opc1
, opc2
);
490 inform("trap check M:%x N:%x 1:%x 2:%x hdcr %x, hcptr %x, hstr %x\n",
491 crm
, crn
, opc1
, opc2
, hdcr
, hcptr
, hstr
);
492 trapToHype
= hdcr
.tda
&& (opc1
== 0);
493 trapToHype
|= hcptr
.tta
&& (opc1
== 1);
495 switch (unflattenMiscReg(miscReg
)) {
496 case MISCREG_DBGOSLSR
:
497 case MISCREG_DBGOSLAR
:
498 case MISCREG_DBGOSDLR
:
499 case MISCREG_DBGPRCR
:
500 trapToHype
= hdcr
.tdosa
;
502 case MISCREG_DBGDRAR
:
503 case MISCREG_DBGDSAR
:
504 trapToHype
= hdcr
.tdra
;
507 trapToHype
= hcr
.tid0
;
511 trapToHype
= hstr
.tjdbx
;
515 trapToHype
= hstr
.ttee
;
517 // No default action needed
527 mcrrMrrc15TrapToHyp(const MiscRegIndex miscReg
, CPSR cpsr
, SCR scr
, HSTR hstr
,
528 HCR hcr
, uint32_t iss
)
536 bool trapToHype
= false;
538 if (!inSecureState(scr
, cpsr
) && (cpsr
.mode
!= MODE_HYP
)) {
539 // This is technically the wrong function, but we can re-use it for
540 // the moment because we only need one field, which overlaps with the
542 mcrMrcIssExtract(iss
, isRead
, crm
, rt
, crn
, opc1
, opc2
);
543 trapToHype
= ((uint32_t) hstr
) & (1 << crm
);
546 switch (unflattenMiscReg(miscReg
)) {
562 case MISCREG_CONTEXTIDR
:
563 trapToHype
= hcr
.tvm
& !isRead
;
565 // No default action needed
575 msrMrs64TrapToSup(const MiscRegIndex miscReg
, ExceptionLevel el
,
576 CPACR cpacr
/* CPACR_EL1 */)
578 bool trapToSup
= false;
582 case MISCREG_FPEXC32_EL2
:
583 if ((el
== EL0
&& cpacr
.fpen
!= 0x3) ||
584 (el
== EL1
&& !(cpacr
.fpen
& 0x1)))
594 msrMrs64TrapToHyp(const MiscRegIndex miscReg
,
597 CPTR cptr
/* CPTR_EL2 */,
598 HCR hcr
/* HCR_EL2 */,
601 bool trapToHyp
= false;
608 case MISCREG_FPEXC32_EL2
:
609 trapToHyp
= cptr
.tfp
;
613 case MISCREG_CPACR_EL1
:
614 trapToHyp
= cptr
.tcpac
&& el
== EL1
;
616 // Virtual memory control regs
617 case MISCREG_SCTLR_EL1
:
618 case MISCREG_TTBR0_EL1
:
619 case MISCREG_TTBR1_EL1
:
620 case MISCREG_TCR_EL1
:
621 case MISCREG_ESR_EL1
:
622 case MISCREG_FAR_EL1
:
623 case MISCREG_AFSR0_EL1
:
624 case MISCREG_AFSR1_EL1
:
625 case MISCREG_MAIR_EL1
:
626 case MISCREG_AMAIR_EL1
:
627 case MISCREG_CONTEXTIDR_EL1
:
628 trapToHyp
= ((hcr
.trvm
&& isRead
) || (hcr
.tvm
&& !isRead
))
631 // TLB maintenance instructions
632 case MISCREG_TLBI_VMALLE1
:
633 case MISCREG_TLBI_VAE1_Xt
:
634 case MISCREG_TLBI_ASIDE1_Xt
:
635 case MISCREG_TLBI_VAAE1_Xt
:
636 case MISCREG_TLBI_VALE1_Xt
:
637 case MISCREG_TLBI_VAALE1_Xt
:
638 case MISCREG_TLBI_VMALLE1IS
:
639 case MISCREG_TLBI_VAE1IS_Xt
:
640 case MISCREG_TLBI_ASIDE1IS_Xt
:
641 case MISCREG_TLBI_VAAE1IS_Xt
:
642 case MISCREG_TLBI_VALE1IS_Xt
:
643 case MISCREG_TLBI_VAALE1IS_Xt
:
644 trapToHyp
= hcr
.ttlb
&& el
== EL1
;
646 // Cache maintenance instructions to the point of unification
647 case MISCREG_IC_IVAU_Xt
:
648 case MISCREG_ICIALLU
:
649 case MISCREG_ICIALLUIS
:
650 case MISCREG_DC_CVAU_Xt
:
651 trapToHyp
= hcr
.tpu
&& el
<= EL1
;
653 // Data/Unified cache maintenance instructions to the point of coherency
654 case MISCREG_DC_IVAC_Xt
:
655 case MISCREG_DC_CIVAC_Xt
:
656 case MISCREG_DC_CVAC_Xt
:
657 trapToHyp
= hcr
.tpc
&& el
<= EL1
;
659 // Data/Unified cache maintenance instructions by set/way
660 case MISCREG_DC_ISW_Xt
:
661 case MISCREG_DC_CSW_Xt
:
662 case MISCREG_DC_CISW_Xt
:
663 trapToHyp
= hcr
.tsw
&& el
== EL1
;
666 case MISCREG_ACTLR_EL1
:
667 trapToHyp
= hcr
.tacr
&& el
== EL1
;
670 // @todo: Trap implementation-dependent functionality based on
674 case MISCREG_ID_PFR0_EL1
:
675 case MISCREG_ID_PFR1_EL1
:
676 case MISCREG_ID_DFR0_EL1
:
677 case MISCREG_ID_AFR0_EL1
:
678 case MISCREG_ID_MMFR0_EL1
:
679 case MISCREG_ID_MMFR1_EL1
:
680 case MISCREG_ID_MMFR2_EL1
:
681 case MISCREG_ID_MMFR3_EL1
:
682 case MISCREG_ID_ISAR0_EL1
:
683 case MISCREG_ID_ISAR1_EL1
:
684 case MISCREG_ID_ISAR2_EL1
:
685 case MISCREG_ID_ISAR3_EL1
:
686 case MISCREG_ID_ISAR4_EL1
:
687 case MISCREG_ID_ISAR5_EL1
:
688 case MISCREG_MVFR0_EL1
:
689 case MISCREG_MVFR1_EL1
:
690 case MISCREG_MVFR2_EL1
:
691 case MISCREG_ID_AA64PFR0_EL1
:
692 case MISCREG_ID_AA64PFR1_EL1
:
693 case MISCREG_ID_AA64DFR0_EL1
:
694 case MISCREG_ID_AA64DFR1_EL1
:
695 case MISCREG_ID_AA64ISAR0_EL1
:
696 case MISCREG_ID_AA64ISAR1_EL1
:
697 case MISCREG_ID_AA64MMFR0_EL1
:
698 case MISCREG_ID_AA64MMFR1_EL1
:
699 case MISCREG_ID_AA64AFR0_EL1
:
700 case MISCREG_ID_AA64AFR1_EL1
:
702 trapToHyp
= hcr
.tid3
&& el
== EL1
;
705 case MISCREG_CTR_EL0
:
706 case MISCREG_CCSIDR_EL1
:
707 case MISCREG_CLIDR_EL1
:
708 case MISCREG_CSSELR_EL1
:
709 trapToHyp
= hcr
.tid2
&& el
<= EL1
;
712 case MISCREG_AIDR_EL1
:
713 case MISCREG_REVIDR_EL1
:
715 trapToHyp
= hcr
.tid1
&& el
== EL1
;
724 msrMrs64TrapToMon(const MiscRegIndex miscReg
, CPTR cptr
/* CPTR_EL3 */,
725 ExceptionLevel el
, bool * isVfpNeon
)
727 bool trapToMon
= false;
734 case MISCREG_FPEXC32_EL2
:
735 trapToMon
= cptr
.tfp
;
739 case MISCREG_CPACR_EL1
:
741 trapToMon
= cptr
.tcpac
;
744 case MISCREG_CPTR_EL2
:
746 trapToMon
= cptr
.tcpac
;
756 decodeMrsMsrBankedReg(uint8_t sysM
, bool r
, bool &isIntReg
, int ®Idx
,
757 CPSR cpsr
, SCR scr
, NSACR nsacr
, bool checkSecurity
)
759 OperatingMode mode
= MODE_UNDEFINED
;
762 // R mostly indicates if its a int register or a misc reg, we override
763 // below if the few corner cases
765 // Loosely based on ARM ARM issue C section B9.3.10
770 regIdx
= MISCREG_SPSR_FIQ
;
774 regIdx
= MISCREG_SPSR_IRQ
;
778 regIdx
= MISCREG_SPSR_SVC
;
782 regIdx
= MISCREG_SPSR_ABT
;
786 regIdx
= MISCREG_SPSR_UND
;
787 mode
= MODE_UNDEFINED
;
790 regIdx
= MISCREG_SPSR_MON
;
794 regIdx
= MISCREG_SPSR_HYP
;
802 int sysM4To3
= bits(sysM
, 4, 3);
806 regIdx
= intRegInMode(mode
, bits(sysM
, 2, 0) + 8);
807 } else if (sysM4To3
== 1) {
809 regIdx
= intRegInMode(mode
, bits(sysM
, 2, 0) + 8);
810 } else if (sysM4To3
== 3) {
811 if (bits(sysM
, 1) == 0) {
813 regIdx
= intRegInMode(mode
, 14 - bits(sysM
, 0));
816 if (bits(sysM
, 0) == 1) {
817 regIdx
= intRegInMode(mode
, 13); // R13 in HYP
820 regIdx
= MISCREG_ELR_HYP
;
823 } else { // Other Banked registers
824 int sysM2
= bits(sysM
, 2);
825 int sysM1
= bits(sysM
, 1);
827 mode
= (OperatingMode
) ( ((sysM2
|| sysM1
) << 0) |
829 ((sysM2
&& !sysM1
) << 2) |
830 ((sysM2
&& sysM1
) << 3) |
832 regIdx
= intRegInMode(mode
, 14 - bits(sysM
, 0));
833 // Don't flatten the register here. This is going to go through
834 // setIntReg() which will do the flattening
835 ok
&= mode
!= cpsr
.mode
;
839 // Check that the requested register is accessable from the current mode
840 if (ok
&& checkSecurity
&& mode
!= cpsr
.mode
) {
847 ok
&= mode
!= MODE_HYP
;
848 ok
&= (mode
!= MODE_MON
) || !scr
.ns
;
851 ok
&= mode
!= MODE_MON
;
852 ok
&= (mode
!= MODE_FIQ
) || !nsacr
.rfr
;
859 ok
&= mode
!= MODE_HYP
;
860 ok
&= (mode
!= MODE_MON
) || !scr
.ns
;
861 ok
&= (mode
!= MODE_FIQ
) || !nsacr
.rfr
;
863 // can access everything, no further checks required
867 panic("unknown Mode 0x%x\n", cpsr
.mode
);
875 SPAlignmentCheckEnabled(ThreadContext
* tc
)
877 switch (opModeToEL(currOpMode(tc
))) {
879 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL3
)).sa
;
881 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL2
)).sa
;
883 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL1
)).sa
;
885 return ((SCTLR
) tc
->readMiscReg(MISCREG_SCTLR_EL1
)).sa0
;
887 panic("Invalid exception level");
893 decodePhysAddrRange64(uint8_t pa_enc
)
911 panic("Invalid phys. address range encoding");
916 encodePhysAddrRange64(int pa_size
)
932 panic("Invalid phys. address range");
936 } // namespace ArmISA