2 * Copyright (c) 2010, 2012-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 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * Copyright (c) 2007-2008 The Florida State University
16 * All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 #include "arch/arm/faults.hh"
48 #include "arch/arm/system.hh"
49 #include "arch/arm/utility.hh"
50 #include "arch/arm/insts/static_inst.hh"
51 #include "base/compiler.hh"
52 #include "base/trace.hh"
53 #include "cpu/base.hh"
54 #include "cpu/thread_context.hh"
55 #include "debug/Faults.hh"
56 #include "sim/full_system.hh"
61 uint8_t ArmFault::shortDescFaultSources
[] = {
62 0x01, // AlignmentFault
63 0x04, // InstructionCacheMaintenance
64 0xff, // SynchExtAbtOnTranslTableWalkL0 (INVALID)
65 0x0c, // SynchExtAbtOnTranslTableWalkL1
66 0x0e, // SynchExtAbtOnTranslTableWalkL2
67 0xff, // SynchExtAbtOnTranslTableWalkL3 (INVALID)
68 0xff, // SynchPtyErrOnTranslTableWalkL0 (INVALID)
69 0x1c, // SynchPtyErrOnTranslTableWalkL1
70 0x1e, // SynchPtyErrOnTranslTableWalkL2
71 0xff, // SynchPtyErrOnTranslTableWalkL3 (INVALID)
72 0xff, // TranslationL0 (INVALID)
73 0x05, // TranslationL1
74 0x07, // TranslationL2
75 0xff, // TranslationL3 (INVALID)
76 0xff, // AccessFlagL0 (INVALID)
79 0xff, // AccessFlagL3 (INVALID)
80 0xff, // DomainL0 (INVALID)
83 0xff, // DomainL3 (INVALID)
84 0xff, // PermissionL0 (INVALID)
87 0xff, // PermissionL3 (INVALID)
89 0x08, // SynchronousExternalAbort
90 0x10, // TLBConflictAbort
91 0x19, // SynchPtyErrOnMemoryAccess
92 0x16, // AsynchronousExternalAbort
93 0x18, // AsynchPtyErrOnMemoryAccess
94 0xff, // AddressSizeL0 (INVALID)
95 0xff, // AddressSizeL1 (INVALID)
96 0xff, // AddressSizeL2 (INVALID)
97 0xff, // AddressSizeL3 (INVALID)
98 0x40, // PrefetchTLBMiss
99 0x80 // PrefetchUncacheable
102 static_assert(sizeof(ArmFault::shortDescFaultSources
) ==
103 ArmFault::NumFaultSources
,
104 "Invalid size of ArmFault::shortDescFaultSources[]");
106 uint8_t ArmFault::longDescFaultSources
[] = {
107 0x21, // AlignmentFault
108 0xff, // InstructionCacheMaintenance (INVALID)
109 0xff, // SynchExtAbtOnTranslTableWalkL0 (INVALID)
110 0x15, // SynchExtAbtOnTranslTableWalkL1
111 0x16, // SynchExtAbtOnTranslTableWalkL2
112 0x17, // SynchExtAbtOnTranslTableWalkL3
113 0xff, // SynchPtyErrOnTranslTableWalkL0 (INVALID)
114 0x1d, // SynchPtyErrOnTranslTableWalkL1
115 0x1e, // SynchPtyErrOnTranslTableWalkL2
116 0x1f, // SynchPtyErrOnTranslTableWalkL3
117 0xff, // TranslationL0 (INVALID)
118 0x05, // TranslationL1
119 0x06, // TranslationL2
120 0x07, // TranslationL3
121 0xff, // AccessFlagL0 (INVALID)
122 0x09, // AccessFlagL1
123 0x0a, // AccessFlagL2
124 0x0b, // AccessFlagL3
125 0xff, // DomainL0 (INVALID)
128 0xff, // DomainL3 (RESERVED)
129 0xff, // PermissionL0 (INVALID)
130 0x0d, // PermissionL1
131 0x0e, // PermissionL2
132 0x0f, // PermissionL3
134 0x10, // SynchronousExternalAbort
135 0x30, // TLBConflictAbort
136 0x18, // SynchPtyErrOnMemoryAccess
137 0x11, // AsynchronousExternalAbort
138 0x19, // AsynchPtyErrOnMemoryAccess
139 0xff, // AddressSizeL0 (INVALID)
140 0xff, // AddressSizeL1 (INVALID)
141 0xff, // AddressSizeL2 (INVALID)
142 0xff, // AddressSizeL3 (INVALID)
143 0x40, // PrefetchTLBMiss
144 0x80 // PrefetchUncacheable
147 static_assert(sizeof(ArmFault::longDescFaultSources
) ==
148 ArmFault::NumFaultSources
,
149 "Invalid size of ArmFault::longDescFaultSources[]");
151 uint8_t ArmFault::aarch64FaultSources
[] = {
152 0x21, // AlignmentFault
153 0xff, // InstructionCacheMaintenance (INVALID)
154 0x14, // SynchExtAbtOnTranslTableWalkL0
155 0x15, // SynchExtAbtOnTranslTableWalkL1
156 0x16, // SynchExtAbtOnTranslTableWalkL2
157 0x17, // SynchExtAbtOnTranslTableWalkL3
158 0x1c, // SynchPtyErrOnTranslTableWalkL0
159 0x1d, // SynchPtyErrOnTranslTableWalkL1
160 0x1e, // SynchPtyErrOnTranslTableWalkL2
161 0x1f, // SynchPtyErrOnTranslTableWalkL3
162 0x04, // TranslationL0
163 0x05, // TranslationL1
164 0x06, // TranslationL2
165 0x07, // TranslationL3
166 0x08, // AccessFlagL0
167 0x09, // AccessFlagL1
168 0x0a, // AccessFlagL2
169 0x0b, // AccessFlagL3
170 // @todo: Section & Page Domain Fault in AArch64?
171 0xff, // DomainL0 (INVALID)
172 0xff, // DomainL1 (INVALID)
173 0xff, // DomainL2 (INVALID)
174 0xff, // DomainL3 (INVALID)
175 0x0c, // PermissionL0
176 0x0d, // PermissionL1
177 0x0e, // PermissionL2
178 0x0f, // PermissionL3
179 0xff, // DebugEvent (INVALID)
180 0x10, // SynchronousExternalAbort
181 0x30, // TLBConflictAbort
182 0x18, // SynchPtyErrOnMemoryAccess
183 0xff, // AsynchronousExternalAbort (INVALID)
184 0xff, // AsynchPtyErrOnMemoryAccess (INVALID)
185 0x00, // AddressSizeL0
186 0x01, // AddressSizeL1
187 0x02, // AddressSizeL2
188 0x03, // AddressSizeL3
189 0x40, // PrefetchTLBMiss
190 0x80 // PrefetchUncacheable
193 static_assert(sizeof(ArmFault::aarch64FaultSources
) ==
194 ArmFault::NumFaultSources
,
195 "Invalid size of ArmFault::aarch64FaultSources[]");
197 // Fields: name, offset, cur{ELT,ELH}Offset, lowerEL{64,32}Offset, next mode,
198 // {ARM, Thumb, ARM_ELR, Thumb_ELR} PC offset, hyp trap,
199 // {A, F} disable, class, stat
200 template<> ArmFault::FaultVals ArmFaultVals
<Reset
>::vals
= {
201 // Some dummy values (the reset vector has an IMPLEMENTATION DEFINED
202 // location in AArch64)
203 "Reset", 0x000, 0x000, 0x000, 0x000, 0x000, MODE_SVC
,
204 0, 0, 0, 0, false, true, true, EC_UNKNOWN
, FaultStat()
206 template<> ArmFault::FaultVals ArmFaultVals
<UndefinedInstruction
>::vals
= {
207 "Undefined Instruction", 0x004, 0x000, 0x200, 0x400, 0x600, MODE_UNDEFINED
,
208 4, 2, 0, 0, true, false, false, EC_UNKNOWN
, FaultStat()
210 template<> ArmFault::FaultVals ArmFaultVals
<SupervisorCall
>::vals
= {
211 "Supervisor Call", 0x008, 0x000, 0x200, 0x400, 0x600, MODE_SVC
,
212 4, 2, 4, 2, true, false, false, EC_SVC_TO_HYP
, FaultStat()
214 template<> ArmFault::FaultVals ArmFaultVals
<SecureMonitorCall
>::vals
= {
215 "Secure Monitor Call", 0x008, 0x000, 0x200, 0x400, 0x600, MODE_MON
,
216 4, 4, 4, 4, false, true, true, EC_SMC_TO_HYP
, FaultStat()
218 template<> ArmFault::FaultVals ArmFaultVals
<HypervisorCall
>::vals
= {
219 "Hypervisor Call", 0x008, 0x000, 0x200, 0x400, 0x600, MODE_HYP
,
220 4, 4, 4, 4, true, false, false, EC_HVC
, FaultStat()
222 template<> ArmFault::FaultVals ArmFaultVals
<PrefetchAbort
>::vals
= {
223 "Prefetch Abort", 0x00C, 0x000, 0x200, 0x400, 0x600, MODE_ABORT
,
224 4, 4, 0, 0, true, true, false, EC_PREFETCH_ABORT_TO_HYP
, FaultStat()
226 template<> ArmFault::FaultVals ArmFaultVals
<DataAbort
>::vals
= {
227 "Data Abort", 0x010, 0x000, 0x200, 0x400, 0x600, MODE_ABORT
,
228 8, 8, 0, 0, true, true, false, EC_DATA_ABORT_TO_HYP
, FaultStat()
230 template<> ArmFault::FaultVals ArmFaultVals
<VirtualDataAbort
>::vals
= {
231 "Virtual Data Abort", 0x010, 0x000, 0x200, 0x400, 0x600, MODE_ABORT
,
232 8, 8, 0, 0, true, true, false, EC_INVALID
, FaultStat()
234 template<> ArmFault::FaultVals ArmFaultVals
<HypervisorTrap
>::vals
= {
235 // @todo: double check these values
236 "Hypervisor Trap", 0x014, 0x000, 0x200, 0x400, 0x600, MODE_HYP
,
237 0, 0, 0, 0, false, false, false, EC_UNKNOWN
, FaultStat()
239 template<> ArmFault::FaultVals ArmFaultVals
<Interrupt
>::vals
= {
240 "IRQ", 0x018, 0x080, 0x280, 0x480, 0x680, MODE_IRQ
,
241 4, 4, 0, 0, false, true, false, EC_UNKNOWN
, FaultStat()
243 template<> ArmFault::FaultVals ArmFaultVals
<VirtualInterrupt
>::vals
= {
244 "Virtual IRQ", 0x018, 0x080, 0x280, 0x480, 0x680, MODE_IRQ
,
245 4, 4, 0, 0, false, true, false, EC_INVALID
, FaultStat()
247 template<> ArmFault::FaultVals ArmFaultVals
<FastInterrupt
>::vals
= {
248 "FIQ", 0x01C, 0x100, 0x300, 0x500, 0x700, MODE_FIQ
,
249 4, 4, 0, 0, false, true, true, EC_UNKNOWN
, FaultStat()
251 template<> ArmFault::FaultVals ArmFaultVals
<VirtualFastInterrupt
>::vals
= {
252 "Virtual FIQ", 0x01C, 0x100, 0x300, 0x500, 0x700, MODE_FIQ
,
253 4, 4, 0, 0, false, true, true, EC_INVALID
, FaultStat()
255 template<> ArmFault::FaultVals ArmFaultVals
<SupervisorTrap
>::vals
= {
256 // Some dummy values (SupervisorTrap is AArch64-only)
257 "Supervisor Trap", 0x014, 0x000, 0x200, 0x400, 0x600, MODE_SVC
,
258 0, 0, 0, 0, false, false, false, EC_UNKNOWN
, FaultStat()
260 template<> ArmFault::FaultVals ArmFaultVals
<SecureMonitorTrap
>::vals
= {
261 // Some dummy values (SecureMonitorTrap is AArch64-only)
262 "Secure Monitor Trap", 0x014, 0x000, 0x200, 0x400, 0x600, MODE_MON
,
263 0, 0, 0, 0, false, false, false, EC_UNKNOWN
, FaultStat()
265 template<> ArmFault::FaultVals ArmFaultVals
<PCAlignmentFault
>::vals
= {
266 // Some dummy values (PCAlignmentFault is AArch64-only)
267 "PC Alignment Fault", 0x000, 0x000, 0x200, 0x400, 0x600, MODE_SVC
,
268 0, 0, 0, 0, true, false, false, EC_PC_ALIGNMENT
, FaultStat()
270 template<> ArmFault::FaultVals ArmFaultVals
<SPAlignmentFault
>::vals
= {
271 // Some dummy values (SPAlignmentFault is AArch64-only)
272 "SP Alignment Fault", 0x000, 0x000, 0x200, 0x400, 0x600, MODE_SVC
,
273 0, 0, 0, 0, true, false, false, EC_STACK_PTR_ALIGNMENT
, FaultStat()
275 template<> ArmFault::FaultVals ArmFaultVals
<SystemError
>::vals
= {
276 // Some dummy values (SError is AArch64-only)
277 "SError", 0x000, 0x180, 0x380, 0x580, 0x780, MODE_SVC
,
278 0, 0, 0, 0, false, true, true, EC_SERROR
, FaultStat()
280 template<> ArmFault::FaultVals ArmFaultVals
<FlushPipe
>::vals
= {
282 "Pipe Flush", 0x000, 0x000, 0x000, 0x000, 0x000, MODE_SVC
,
283 0, 0, 0, 0, false, true, true, EC_UNKNOWN
, FaultStat()
285 template<> ArmFault::FaultVals ArmFaultVals
<ArmSev
>::vals
= {
287 "ArmSev Flush", 0x000, 0x000, 0x000, 0x000, 0x000, MODE_SVC
,
288 0, 0, 0, 0, false, true, true, EC_UNKNOWN
, FaultStat()
290 template<> ArmFault::FaultVals ArmFaultVals
<IllegalInstSetStateFault
>::vals
= {
291 // Some dummy values (SPAlignmentFault is AArch64-only)
292 "Illegal Inst Set State Fault", 0x000, 0x000, 0x200, 0x400, 0x600, MODE_SVC
,
293 0, 0, 0, 0, true, false, false, EC_ILLEGAL_INST
, FaultStat()
297 ArmFault::getVector(ThreadContext
*tc
)
301 // ARM ARM issue C B1.8.1
302 bool haveSecurity
= ArmSystem::haveSecurity(tc
);
304 // panic if SCTLR.VE because I have no idea what to do with vectored
306 SCTLR sctlr
= tc
->readMiscReg(MISCREG_SCTLR
);
308 // Check for invalid modes
309 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
310 assert(haveSecurity
|| cpsr
.mode
!= MODE_MON
);
311 assert(ArmSystem::haveVirtualization(tc
) || cpsr
.mode
!= MODE_HYP
);
316 base
= tc
->readMiscReg(MISCREG_MVBAR
);
319 base
= tc
->readMiscReg(MISCREG_HVBAR
);
325 base
= haveSecurity
? tc
->readMiscReg(MISCREG_VBAR
) : 0;
329 return base
+ offset(tc
);
333 ArmFault::getVector64(ThreadContext
*tc
)
338 assert(ArmSystem::haveSecurity(tc
));
339 vbar
= tc
->readMiscReg(MISCREG_VBAR_EL3
);
342 assert(ArmSystem::haveVirtualization(tc
));
343 vbar
= tc
->readMiscReg(MISCREG_VBAR_EL2
);
346 vbar
= tc
->readMiscReg(MISCREG_VBAR_EL1
);
349 panic("Invalid target exception level");
352 return vbar
+ offset64();
356 ArmFault::getSyndromeReg64() const
360 return MISCREG_ESR_EL1
;
362 return MISCREG_ESR_EL2
;
364 return MISCREG_ESR_EL3
;
366 panic("Invalid exception level");
372 ArmFault::getFaultAddrReg64() const
376 return MISCREG_FAR_EL1
;
378 return MISCREG_FAR_EL2
;
380 return MISCREG_FAR_EL3
;
382 panic("Invalid exception level");
388 ArmFault::setSyndrome(ThreadContext
*tc
, MiscRegIndex syndrome_reg
)
391 uint32_t exc_class
= (uint32_t) ec(tc
);
392 uint32_t issVal
= iss();
393 assert(!from64
|| ArmSystem::highestELIs64(tc
));
395 value
= exc_class
<< 26;
397 // HSR.IL not valid for Prefetch Aborts (0x20, 0x21) and Data Aborts (0x24,
398 // 0x25) for which the ISS information is not valid (ARMv7).
399 // @todo: ARMv8 revises AArch32 functionality: when HSR.IL is not
400 // valid it is treated as RES1.
403 } else if ((bits(exc_class
, 5, 3) != 4) ||
404 (bits(exc_class
, 2) && bits(issVal
, 24))) {
405 if (!machInst
.thumb
|| machInst
.bigThumb
)
408 // Condition code valid for EC[5:4] nonzero
409 if (!from64
&& ((bits(exc_class
, 5, 4) == 0) &&
410 (bits(exc_class
, 3, 0) != 0))) {
411 if (!machInst
.thumb
) {
413 ConditionCode condCode
= (ConditionCode
) (uint32_t) machInst
.condCode
;
414 // If its on unconditional instruction report with a cond code of
415 // 0xE, ie the unconditional code
416 cond
= (condCode
== COND_UC
) ? COND_AL
: condCode
;
420 value
|= bits(issVal
, 19, 0);
424 tc
->setMiscReg(syndrome_reg
, value
);
428 ArmFault::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
430 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
432 if (ArmSystem::highestELIs64(tc
)) { // ARMv8
433 // Determine source exception level and mode
434 fromMode
= (OperatingMode
) (uint8_t) cpsr
.mode
;
435 fromEL
= opModeToEL(fromMode
);
436 if (opModeIs64(fromMode
))
439 // Determine target exception level
440 if (ArmSystem::haveSecurity(tc
) && routeToMonitor(tc
))
443 toEL
= opModeToEL(nextMode());
447 if (toEL
== ArmSystem::highestEL(tc
) || ELIs64(tc
, toEL
)) {
448 // Invoke exception handler in AArch64 state
455 // ARMv7 (ARM ARM issue C B1.9)
457 bool have_security
= ArmSystem::haveSecurity(tc
);
458 bool have_virtualization
= ArmSystem::haveVirtualization(tc
);
460 FaultBase::invoke(tc
);
465 SCTLR sctlr
= tc
->readMiscReg(MISCREG_SCTLR
);
466 SCR scr
= tc
->readMiscReg(MISCREG_SCR
);
467 CPSR saved_cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
468 saved_cpsr
.nz
= tc
->readCCReg(CCREG_NZ
);
469 saved_cpsr
.c
= tc
->readCCReg(CCREG_C
);
470 saved_cpsr
.v
= tc
->readCCReg(CCREG_V
);
471 saved_cpsr
.ge
= tc
->readCCReg(CCREG_GE
);
473 Addr curPc M5_VAR_USED
= tc
->pcState().pc();
474 ITSTATE it
= tc
->pcState().itstate();
475 saved_cpsr
.it2
= it
.top6
;
476 saved_cpsr
.it1
= it
.bottom2
;
478 // if we have a valid instruction then use it to annotate this fault with
479 // extra information. This is used to generate the correct fault syndrome
482 ArmStaticInst
*armInst
= reinterpret_cast<ArmStaticInst
*>(inst
.get());
483 armInst
->annotateFault(this);
486 if (have_security
&& routeToMonitor(tc
))
487 cpsr
.mode
= MODE_MON
;
488 else if (have_virtualization
&& routeToHyp(tc
))
489 cpsr
.mode
= MODE_HYP
;
491 cpsr
.mode
= nextMode();
493 // Ensure Secure state if initially in Monitor mode
494 if (have_security
&& saved_cpsr
.mode
== MODE_MON
) {
495 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
498 tc
->setMiscRegNoEffect(MISCREG_SCR
, scr
);
502 // some bits are set differently if we have been routed to hyp mode
503 if (cpsr
.mode
== MODE_HYP
) {
504 SCTLR hsctlr
= tc
->readMiscReg(MISCREG_HSCTLR
);
507 if (!scr
.ea
) {cpsr
.a
= 1;}
508 if (!scr
.fiq
) {cpsr
.f
= 1;}
509 if (!scr
.irq
) {cpsr
.i
= 1;}
510 } else if (cpsr
.mode
== MODE_MON
) {
511 // Special case handling when entering monitor mode
521 // The *Disable functions are virtual and different per fault
522 cpsr
.a
= cpsr
.a
| abortDisable(tc
);
523 cpsr
.f
= cpsr
.f
| fiqDisable(tc
);
526 cpsr
.it1
= cpsr
.it2
= 0;
528 tc
->setMiscReg(MISCREG_CPSR
, cpsr
);
530 // Make sure mailbox sets to one always
531 tc
->setMiscReg(MISCREG_SEV_MAILBOX
, 1);
533 // Clear the exclusive monitor
534 tc
->setMiscReg(MISCREG_LOCKFLAG
, 0);
536 if (cpsr
.mode
== MODE_HYP
) {
537 tc
->setMiscReg(MISCREG_ELR_HYP
, curPc
+
538 (saved_cpsr
.t
? thumbPcOffset(true) : armPcOffset(true)));
540 tc
->setIntReg(INTREG_LR
, curPc
+
541 (saved_cpsr
.t
? thumbPcOffset(false) : armPcOffset(false)));
546 tc
->setMiscReg(MISCREG_SPSR_FIQ
, saved_cpsr
);
549 tc
->setMiscReg(MISCREG_SPSR_IRQ
, saved_cpsr
);
552 tc
->setMiscReg(MISCREG_SPSR_SVC
, saved_cpsr
);
555 assert(have_security
);
556 tc
->setMiscReg(MISCREG_SPSR_MON
, saved_cpsr
);
559 tc
->setMiscReg(MISCREG_SPSR_ABT
, saved_cpsr
);
562 tc
->setMiscReg(MISCREG_SPSR_UND
, saved_cpsr
);
563 if (ec(tc
) != EC_UNKNOWN
)
564 setSyndrome(tc
, MISCREG_HSR
);
567 assert(have_virtualization
);
568 tc
->setMiscReg(MISCREG_SPSR_HYP
, saved_cpsr
);
569 setSyndrome(tc
, MISCREG_HSR
);
572 panic("unknown Mode\n");
575 Addr newPc
= getVector(tc
);
576 DPRINTF(Faults
, "Invoking Fault:%s cpsr:%#x PC:%#x lr:%#x newVec: %#x\n",
577 name(), cpsr
, curPc
, tc
->readIntReg(INTREG_LR
), newPc
);
580 pc
.nextThumb(pc
.thumb());
582 pc
.nextJazelle(pc
.jazelle());
583 pc
.aarch64(!cpsr
.width
);
584 pc
.nextAArch64(!cpsr
.width
);
589 ArmFault::invoke64(ThreadContext
*tc
, const StaticInstPtr
&inst
)
591 // Determine actual misc. register indices for ELR_ELx and SPSR_ELx
592 MiscRegIndex elr_idx
, spsr_idx
;
595 elr_idx
= MISCREG_ELR_EL1
;
596 spsr_idx
= MISCREG_SPSR_EL1
;
599 assert(ArmSystem::haveVirtualization(tc
));
600 elr_idx
= MISCREG_ELR_EL2
;
601 spsr_idx
= MISCREG_SPSR_EL2
;
604 assert(ArmSystem::haveSecurity(tc
));
605 elr_idx
= MISCREG_ELR_EL3
;
606 spsr_idx
= MISCREG_SPSR_EL3
;
609 panic("Invalid target exception level");
613 // Save process state into SPSR_ELx
614 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
616 spsr
.nz
= tc
->readCCReg(CCREG_NZ
);
617 spsr
.c
= tc
->readCCReg(CCREG_C
);
618 spsr
.v
= tc
->readCCReg(CCREG_V
);
620 // Force some bitfields to 0
629 spsr
.ge
= tc
->readCCReg(CCREG_GE
);
630 ITSTATE it
= tc
->pcState().itstate();
632 spsr
.it1
= it
.bottom2
;
633 // Force some bitfields to 0
637 tc
->setMiscReg(spsr_idx
, spsr
);
639 // Save preferred return address into ELR_ELx
640 Addr curr_pc
= tc
->pcState().pc();
641 Addr ret_addr
= curr_pc
;
643 ret_addr
+= armPcElrOffset();
645 ret_addr
+= spsr
.t
? thumbPcElrOffset() : armPcElrOffset();
646 tc
->setMiscReg(elr_idx
, ret_addr
);
648 // Update process state
649 OperatingMode64 mode
= 0;
657 tc
->setMiscReg(MISCREG_CPSR
, cpsr
);
659 // Set PC to start of exception handler
660 Addr new_pc
= purifyTaggedAddr(getVector64(tc
), tc
, toEL
);
661 DPRINTF(Faults
, "Invoking Fault (AArch64 target EL):%s cpsr:%#x PC:%#x "
662 "elr:%#x newVec: %#x\n", name(), cpsr
, curr_pc
, ret_addr
, new_pc
);
664 pc
.aarch64(!cpsr
.width
);
665 pc
.nextAArch64(!cpsr
.width
);
668 // If we have a valid instruction then use it to annotate this fault with
669 // extra information. This is used to generate the correct fault syndrome
672 reinterpret_cast<ArmStaticInst
*>(inst
.get())->annotateFault(this);
673 // Save exception syndrome
674 if ((nextMode() != MODE_IRQ
) && (nextMode() != MODE_FIQ
))
675 setSyndrome(tc
, getSyndromeReg64());
679 Reset::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
682 tc
->getCpuPtr()->clearInterrupts(tc
->threadId());
685 if (!ArmSystem::highestELIs64(tc
)) {
686 ArmFault::invoke(tc
, inst
);
687 tc
->setMiscReg(MISCREG_VMPIDR
,
688 getMPIDR(dynamic_cast<ArmSystem
*>(tc
->getSystemPtr()), tc
));
690 // Unless we have SMC code to get us there, boot in HYP!
691 if (ArmSystem::haveVirtualization(tc
) &&
692 !ArmSystem::haveSecurity(tc
)) {
693 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
694 cpsr
.mode
= MODE_HYP
;
695 tc
->setMiscReg(MISCREG_CPSR
, cpsr
);
698 // Advance the PC to the IMPLEMENTATION DEFINED reset value
699 PCState pc
= ArmSystem::resetAddr64(tc
);
701 pc
.nextAArch64(true);
707 UndefinedInstruction::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
710 ArmFault::invoke(tc
, inst
);
714 // If the mnemonic isn't defined this has to be an unknown instruction.
715 assert(unknown
|| mnemonic
!= NULL
);
717 panic("Attempted to execute disabled instruction "
718 "'%s' (inst 0x%08x)", mnemonic
, machInst
);
719 } else if (unknown
) {
720 panic("Attempted to execute unknown instruction (inst 0x%08x)",
723 panic("Attempted to execute unimplemented instruction "
724 "'%s' (inst 0x%08x)", mnemonic
, machInst
);
729 UndefinedInstruction::routeToHyp(ThreadContext
*tc
) const
733 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
734 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
735 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
737 // if in Hyp mode then stay in Hyp mode
738 toHyp
= scr
.ns
&& (cpsr
.mode
== MODE_HYP
);
739 // if HCR.TGE is set to 1, take to Hyp mode through Hyp Trap vector
740 toHyp
|= !inSecureState(scr
, cpsr
) && hcr
.tge
&& (cpsr
.mode
== MODE_USER
);
745 UndefinedInstruction::iss() const
747 if (overrideEc
== EC_INVALID
)
750 uint32_t new_iss
= 0;
751 uint32_t op0
, op1
, op2
, CRn
, CRm
, Rt
, dir
;
753 dir
= bits(machInst
, 21, 21);
754 op0
= bits(machInst
, 20, 19);
755 op1
= bits(machInst
, 18, 16);
756 CRn
= bits(machInst
, 15, 12);
757 CRm
= bits(machInst
, 11, 8);
758 op2
= bits(machInst
, 7, 5);
759 Rt
= bits(machInst
, 4, 0);
761 new_iss
= op0
<< 20 | op2
<< 17 | op1
<< 14 | CRn
<< 10 |
762 Rt
<< 5 | CRm
<< 1 | dir
;
768 SupervisorCall::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
771 ArmFault::invoke(tc
, inst
);
775 // As of now, there isn't a 32 bit thumb version of this instruction.
776 assert(!machInst
.bigThumb
);
778 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
779 OperatingMode mode
= (OperatingMode
)(uint8_t)cpsr
.mode
;
780 if (opModeIs64(mode
))
781 callNum
= tc
->readIntReg(INTREG_X8
);
783 callNum
= tc
->readIntReg(INTREG_R7
);
784 tc
->syscall(callNum
);
786 // Advance the PC since that won't happen automatically.
787 PCState pc
= tc
->pcState();
794 SupervisorCall::routeToHyp(ThreadContext
*tc
) const
798 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
799 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
800 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
802 // if in Hyp mode then stay in Hyp mode
803 toHyp
= scr
.ns
&& (cpsr
.mode
== MODE_HYP
);
804 // if HCR.TGE is set to 1, take to Hyp mode through Hyp Trap vector
805 toHyp
|= !inSecureState(scr
, cpsr
) && hcr
.tge
&& (cpsr
.mode
== MODE_USER
);
810 SupervisorCall::ec(ThreadContext
*tc
) const
812 return (overrideEc
!= EC_INVALID
) ? overrideEc
:
813 (from64
? EC_SVC_64
: vals
.ec
);
817 SupervisorCall::iss() const
819 // Even if we have a 24 bit imm from an arm32 instruction then we only use
820 // the bottom 16 bits for the ISS value (it doesn't hurt for AArch64 SVC).
821 return issRaw
& 0xFFFF;
825 SecureMonitorCall::iss() const
828 return bits(machInst
, 20, 5);
833 UndefinedInstruction::ec(ThreadContext
*tc
) const
835 return (overrideEc
!= EC_INVALID
) ? overrideEc
: vals
.ec
;
839 HypervisorCall::HypervisorCall(ExtMachInst _machInst
, uint32_t _imm
) :
840 ArmFaultVals
<HypervisorCall
>(_machInst
, _imm
)
844 HypervisorTrap::ec(ThreadContext
*tc
) const
846 return (overrideEc
!= EC_INVALID
) ? overrideEc
: vals
.ec
;
851 ArmFaultVals
<T
>::offset(ThreadContext
*tc
)
853 bool isHypTrap
= false;
855 // Normally we just use the exception vector from the table at the top if
856 // this file, however if this exception has caused a transition to hype
857 // mode, and its an exception type that would only do this if it has been
858 // trapped then we use the hyp trap vector instead of the normal vector
859 if (vals
.hypTrappable
) {
860 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
861 if (cpsr
.mode
== MODE_HYP
) {
862 CPSR spsr
= tc
->readMiscReg(MISCREG_SPSR_HYP
);
863 isHypTrap
= spsr
.mode
!= MODE_HYP
;
866 return isHypTrap
? 0x14 : vals
.offset
;
870 // SupervisorCall::setSyndrome64(ThreadContext *tc, MiscRegIndex esr_idx)
873 // esr.ec = machInst.aarch64 ? SvcAArch64 : SvcAArch32;
874 // esr.il = !machInst.thumb;
875 // if (machInst.aarch64)
876 // esr.imm16 = bits(machInst.instBits, 20, 5);
877 // else if (machInst.thumb)
878 // esr.imm16 = bits(machInst.instBits, 7, 0);
880 // esr.imm16 = bits(machInst.instBits, 15, 0);
881 // tc->setMiscReg(esr_idx, esr);
885 SecureMonitorCall::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
888 ArmFault::invoke(tc
, inst
);
894 SecureMonitorCall::ec(ThreadContext
*tc
) const
896 return (from64
? EC_SMC_64
: vals
.ec
);
900 SupervisorTrap::ec(ThreadContext
*tc
) const
902 return (overrideEc
!= EC_INVALID
) ? overrideEc
: vals
.ec
;
906 SecureMonitorTrap::ec(ThreadContext
*tc
) const
908 return (overrideEc
!= EC_INVALID
) ? overrideEc
:
909 (from64
? EC_SMC_64
: vals
.ec
);
914 AbortFault
<T
>::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
916 if (tranMethod
== ArmFault::UnknownTran
) {
917 tranMethod
= longDescFormatInUse(tc
) ? ArmFault::LpaeTran
918 : ArmFault::VmsaTran
;
920 if ((tranMethod
== ArmFault::VmsaTran
) && this->routeToMonitor(tc
)) {
921 // See ARM ARM B3-1416
922 bool override_LPAE
= false;
923 TTBCR ttbcr_s
= tc
->readMiscReg(MISCREG_TTBCR_S
);
924 TTBCR M5_VAR_USED ttbcr_ns
= tc
->readMiscReg(MISCREG_TTBCR_NS
);
926 override_LPAE
= true;
928 // Unimplemented code option, not seen in testing. May need
929 // extension according to the manual exceprt above.
930 DPRINTF(Faults
, "Warning: Incomplete translation method "
931 "override detected.\n");
934 tranMethod
= ArmFault::LpaeTran
;
938 if (source
== ArmFault::AsynchronousExternalAbort
) {
939 tc
->getCpuPtr()->clearInterrupt(tc
->threadId(), INT_ABT
, 0);
941 // Get effective fault source encoding
942 CPSR cpsr
= tc
->readMiscReg(MISCREG_CPSR
);
943 FSR fsr
= getFsr(tc
);
945 // source must be determined BEFORE invoking generic routines which will
946 // try to set hsr etc. and are based upon source!
947 ArmFaultVals
<T
>::invoke(tc
, inst
);
949 if (!this->to64
) { // AArch32
950 if (cpsr
.mode
== MODE_HYP
) {
951 tc
->setMiscReg(T::HFarIndex
, faultAddr
);
953 tc
->setMiscReg(MISCREG_HPFAR
, (faultAddr
>> 8) & ~0xf);
954 tc
->setMiscReg(T::HFarIndex
, OVAddr
);
956 tc
->setMiscReg(T::FsrIndex
, fsr
);
957 tc
->setMiscReg(T::FarIndex
, faultAddr
);
959 DPRINTF(Faults
, "Abort Fault source=%#x fsr=%#x faultAddr=%#x "\
960 "tranMethod=%#x\n", source
, fsr
, faultAddr
, tranMethod
);
962 // Set the FAR register. Nothing else to do if we are in AArch64 state
963 // because the syndrome register has already been set inside invoke64()
964 tc
->setMiscReg(AbortFault
<T
>::getFaultAddrReg64(), faultAddr
);
970 AbortFault
<T
>::getFsr(ThreadContext
*tc
)
974 if (((CPSR
) tc
->readMiscRegNoEffect(MISCREG_CPSR
)).width
) {
976 assert(tranMethod
!= ArmFault::UnknownTran
);
977 if (tranMethod
== ArmFault::LpaeTran
) {
978 srcEncoded
= ArmFault::longDescFaultSources
[source
];
979 fsr
.status
= srcEncoded
;
982 srcEncoded
= ArmFault::shortDescFaultSources
[source
];
983 fsr
.fsLow
= bits(srcEncoded
, 3, 0);
984 fsr
.fsHigh
= bits(srcEncoded
, 4);
985 fsr
.domain
= static_cast<uint8_t>(domain
);
987 fsr
.wnr
= (write
? 1 : 0);
991 srcEncoded
= ArmFault::aarch64FaultSources
[source
];
993 if (srcEncoded
== ArmFault::FaultSourceInvalid
) {
994 panic("Invalid fault source\n");
1001 AbortFault
<T
>::abortDisable(ThreadContext
*tc
)
1003 if (ArmSystem::haveSecurity(tc
)) {
1004 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1005 return (!scr
.ns
|| scr
.aw
);
1012 AbortFault
<T
>::annotate(ArmFault::AnnotationIDs id
, uint64_t val
)
1016 case ArmFault::S1PTW
:
1023 // Just ignore unknown ID's
1031 AbortFault
<T
>::iss() const
1035 val
= srcEncoded
& 0x3F;
1043 AbortFault
<T
>::isMMUFault() const
1045 // NOTE: Not relying on LL information being aligned to lowest bits here
1047 (source
== ArmFault::AlignmentFault
) ||
1048 ((source
>= ArmFault::TranslationLL
) &&
1049 (source
< ArmFault::TranslationLL
+ 4)) ||
1050 ((source
>= ArmFault::AccessFlagLL
) &&
1051 (source
< ArmFault::AccessFlagLL
+ 4)) ||
1052 ((source
>= ArmFault::DomainLL
) &&
1053 (source
< ArmFault::DomainLL
+ 4)) ||
1054 ((source
>= ArmFault::PermissionLL
) &&
1055 (source
< ArmFault::PermissionLL
+ 4));
1059 PrefetchAbort::ec(ThreadContext
*tc
) const
1064 return EC_PREFETCH_ABORT_CURR_EL
;
1066 return EC_PREFETCH_ABORT_LOWER_EL
;
1069 // Abort faults have different EC codes depending on whether
1070 // the fault originated within HYP mode, or not. So override
1071 // the method and add the extra adjustment of the EC value.
1073 ExceptionClass ec
= ArmFaultVals
<PrefetchAbort
>::vals
.ec
;
1075 CPSR spsr
= tc
->readMiscReg(MISCREG_SPSR_HYP
);
1076 if (spsr
.mode
== MODE_HYP
) {
1077 ec
= ((ExceptionClass
) (((uint32_t) ec
) + 1));
1084 PrefetchAbort::routeToMonitor(ThreadContext
*tc
) const
1088 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR_EL3
);
1090 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1092 return scr
.ea
&& !isMMUFault();
1096 PrefetchAbort::routeToHyp(ThreadContext
*tc
) const
1100 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1101 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
1102 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
1103 HDCR hdcr
= tc
->readMiscRegNoEffect(MISCREG_HDCR
);
1105 // if in Hyp mode then stay in Hyp mode
1106 toHyp
= scr
.ns
&& (cpsr
.mode
== MODE_HYP
);
1107 // otherwise, check whether to take to Hyp mode through Hyp Trap vector
1109 ( (source
== DebugEvent
) && hdcr
.tde
&& (cpsr
.mode
!= MODE_HYP
)) ||
1110 ( (source
== SynchronousExternalAbort
) && hcr
.tge
&& (cpsr
.mode
== MODE_USER
))
1111 ) && !inSecureState(scr
, cpsr
);
1116 DataAbort::ec(ThreadContext
*tc
) const
1120 if (source
== ArmFault::AsynchronousExternalAbort
) {
1121 panic("Asynchronous External Abort should be handled with "
1122 "SystemErrors (SErrors)!");
1125 return EC_DATA_ABORT_CURR_EL
;
1127 return EC_DATA_ABORT_LOWER_EL
;
1130 // Abort faults have different EC codes depending on whether
1131 // the fault originated within HYP mode, or not. So override
1132 // the method and add the extra adjustment of the EC value.
1134 ExceptionClass ec
= ArmFaultVals
<DataAbort
>::vals
.ec
;
1136 CPSR spsr
= tc
->readMiscReg(MISCREG_SPSR_HYP
);
1137 if (spsr
.mode
== MODE_HYP
) {
1138 ec
= ((ExceptionClass
) (((uint32_t) ec
) + 1));
1145 DataAbort::routeToMonitor(ThreadContext
*tc
) const
1149 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR_EL3
);
1151 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1153 return scr
.ea
&& !isMMUFault();
1157 DataAbort::routeToHyp(ThreadContext
*tc
) const
1161 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1162 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
1163 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
1164 HDCR hdcr
= tc
->readMiscRegNoEffect(MISCREG_HDCR
);
1166 // if in Hyp mode then stay in Hyp mode
1167 toHyp
= scr
.ns
&& (cpsr
.mode
== MODE_HYP
);
1168 // otherwise, check whether to take to Hyp mode through Hyp Trap vector
1170 ( (cpsr
.mode
!= MODE_HYP
) && ( ((source
== AsynchronousExternalAbort
) && hcr
.amo
) ||
1171 ((source
== DebugEvent
) && hdcr
.tde
) )
1173 ( (cpsr
.mode
== MODE_USER
) && hcr
.tge
&&
1174 ((source
== AlignmentFault
) ||
1175 (source
== SynchronousExternalAbort
))
1177 ) && !inSecureState(scr
, cpsr
);
1182 DataAbort::iss() const
1186 // Add on the data abort specific fields to the generic abort ISS value
1187 val
= AbortFault
<DataAbort
>::iss();
1188 // ISS is valid if not caused by a stage 1 page table walk, and when taken
1189 // to AArch64 only when directed to EL2
1190 if (!s1ptw
&& (!to64
|| toEL
== EL2
)) {
1196 // AArch64 only. These assignments are safe on AArch32 as well
1197 // because these vars are initialized to false
1206 DataAbort::annotate(AnnotationIDs id
, uint64_t val
)
1208 AbortFault
<DataAbort
>::annotate(id
, val
);
1231 // Just ignore unknown ID's
1238 VirtualDataAbort::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
1240 AbortFault
<VirtualDataAbort
>::invoke(tc
, inst
);
1241 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
1243 tc
->setMiscRegNoEffect(MISCREG_HCR
, hcr
);
1247 Interrupt::routeToMonitor(ThreadContext
*tc
) const
1249 assert(ArmSystem::haveSecurity(tc
));
1252 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR_EL3
);
1254 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1259 Interrupt::routeToHyp(ThreadContext
*tc
) const
1263 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1264 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
1265 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
1266 // Determine whether IRQs are routed to Hyp mode.
1267 toHyp
= (!scr
.irq
&& hcr
.imo
&& !inSecureState(scr
, cpsr
)) ||
1268 (cpsr
.mode
== MODE_HYP
);
1273 Interrupt::abortDisable(ThreadContext
*tc
)
1275 if (ArmSystem::haveSecurity(tc
)) {
1276 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1277 return (!scr
.ns
|| scr
.aw
);
1282 VirtualInterrupt::VirtualInterrupt()
1286 FastInterrupt::routeToMonitor(ThreadContext
*tc
) const
1288 assert(ArmSystem::haveSecurity(tc
));
1291 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR_EL3
);
1293 scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1298 FastInterrupt::routeToHyp(ThreadContext
*tc
) const
1302 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1303 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
1304 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
1305 // Determine whether IRQs are routed to Hyp mode.
1306 toHyp
= (!scr
.fiq
&& hcr
.fmo
&& !inSecureState(scr
, cpsr
)) ||
1307 (cpsr
.mode
== MODE_HYP
);
1312 FastInterrupt::abortDisable(ThreadContext
*tc
)
1314 if (ArmSystem::haveSecurity(tc
)) {
1315 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1316 return (!scr
.ns
|| scr
.aw
);
1322 FastInterrupt::fiqDisable(ThreadContext
*tc
)
1324 if (ArmSystem::haveVirtualization(tc
)) {
1326 } else if (ArmSystem::haveSecurity(tc
)) {
1327 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR
);
1328 return (!scr
.ns
|| scr
.fw
);
1333 VirtualFastInterrupt::VirtualFastInterrupt()
1337 PCAlignmentFault::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
1339 ArmFaultVals
<PCAlignmentFault
>::invoke(tc
, inst
);
1342 tc
->setMiscReg(getFaultAddrReg64(), faultPC
);
1345 SPAlignmentFault::SPAlignmentFault()
1348 SystemError::SystemError()
1352 SystemError::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
)
1354 tc
->getCpuPtr()->clearInterrupt(tc
->threadId(), INT_ABT
, 0);
1355 ArmFault::invoke(tc
, inst
);
1359 SystemError::routeToMonitor(ThreadContext
*tc
) const
1361 assert(ArmSystem::haveSecurity(tc
));
1363 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR_EL3
);
1368 SystemError::routeToHyp(ThreadContext
*tc
) const
1373 SCR scr
= tc
->readMiscRegNoEffect(MISCREG_SCR_EL3
);
1374 HCR hcr
= tc
->readMiscRegNoEffect(MISCREG_HCR
);
1375 CPSR cpsr
= tc
->readMiscRegNoEffect(MISCREG_CPSR
);
1377 toHyp
= (!scr
.ea
&& hcr
.amo
&& !inSecureState(scr
, cpsr
)) ||
1378 (!scr
.ea
&& !scr
.rw
&& !hcr
.amo
&& !inSecureState(scr
,cpsr
));
1383 FlushPipe::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
) {
1384 DPRINTF(Faults
, "Invoking FlushPipe Fault\n");
1386 // Set the PC to the next instruction of the faulting instruction.
1387 // Net effect is simply squashing all instructions behind and
1388 // start refetching from the next instruction.
1389 PCState pc
= tc
->pcState();
1391 inst
->advancePC(pc
);
1396 ArmSev::invoke(ThreadContext
*tc
, const StaticInstPtr
&inst
) {
1397 DPRINTF(Faults
, "Invoking ArmSev Fault\n");
1401 // Set sev_mailbox to 1, clear the pending interrupt from remote
1402 // SEV execution and let pipeline continue as pcState is still
1404 tc
->setMiscReg(MISCREG_SEV_MAILBOX
, 1);
1405 tc
->getCpuPtr()->clearInterrupt(tc
->threadId(), INT_SEV
, 0);
1408 // Instantiate all the templates to make the linker happy
1409 template class ArmFaultVals
<Reset
>;
1410 template class ArmFaultVals
<UndefinedInstruction
>;
1411 template class ArmFaultVals
<SupervisorCall
>;
1412 template class ArmFaultVals
<SecureMonitorCall
>;
1413 template class ArmFaultVals
<HypervisorCall
>;
1414 template class ArmFaultVals
<PrefetchAbort
>;
1415 template class ArmFaultVals
<DataAbort
>;
1416 template class ArmFaultVals
<VirtualDataAbort
>;
1417 template class ArmFaultVals
<HypervisorTrap
>;
1418 template class ArmFaultVals
<Interrupt
>;
1419 template class ArmFaultVals
<VirtualInterrupt
>;
1420 template class ArmFaultVals
<FastInterrupt
>;
1421 template class ArmFaultVals
<VirtualFastInterrupt
>;
1422 template class ArmFaultVals
<SupervisorTrap
>;
1423 template class ArmFaultVals
<SecureMonitorTrap
>;
1424 template class ArmFaultVals
<PCAlignmentFault
>;
1425 template class ArmFaultVals
<SPAlignmentFault
>;
1426 template class ArmFaultVals
<SystemError
>;
1427 template class ArmFaultVals
<FlushPipe
>;
1428 template class ArmFaultVals
<ArmSev
>;
1429 template class AbortFault
<PrefetchAbort
>;
1430 template class AbortFault
<DataAbort
>;
1431 template class AbortFault
<VirtualDataAbort
>;
1434 IllegalInstSetStateFault::IllegalInstSetStateFault()
1438 } // namespace ArmISA