utility.cc (12495:9569e57f67f5) utility.cc (12496:e7bc841e521c)
1/*
2 * Copyright (c) 2009-2014, 2016-2018 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

--- 229 unchanged lines hidden (view full) ---

238ELIs64(ThreadContext *tc, ExceptionLevel el)
239{
240 return !ELIs32(tc, el);
241}
242
243bool
244ELIs32(ThreadContext *tc, ExceptionLevel el)
245{
1/*
2 * Copyright (c) 2009-2014, 2016-2018 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

--- 229 unchanged lines hidden (view full) ---

238ELIs64(ThreadContext *tc, ExceptionLevel el)
239{
240 return !ELIs32(tc, el);
241}
242
243bool
244ELIs32(ThreadContext *tc, ExceptionLevel el)
245{
246 // Return true if the specified EL is in aarch32 state.
246 bool known, aarch32;
247 std::tie(known, aarch32) = ELUsingAArch32K(tc, el);
248 panic_if(!known, "EL state is UNKNOWN");
249 return aarch32;
250}
247
251
252std::pair<bool, bool>
253ELUsingAArch32K(ThreadContext *tc, ExceptionLevel el)
254{
255 // Return true if the specified EL is in aarch32 state.
248 const bool have_el3 = ArmSystem::haveSecurity(tc);
249 const bool have_el2 = ArmSystem::haveVirtualization(tc);
250
251 panic_if(el == EL2 && !have_el2, "Asking for EL2 when it doesn't exist");
252 panic_if(el == EL3 && !have_el3, "Asking for EL3 when it doesn't exist");
253
256 const bool have_el3 = ArmSystem::haveSecurity(tc);
257 const bool have_el2 = ArmSystem::haveVirtualization(tc);
258
259 panic_if(el == EL2 && !have_el2, "Asking for EL2 when it doesn't exist");
260 panic_if(el == EL3 && !have_el3, "Asking for EL3 when it doesn't exist");
261
254 if (ArmSystem::highestELIs64(tc)
255 && ArmSystem::highestEL(tc) == el) {
256 return false;
262 bool known, aarch32;
263 known = aarch32 = false;
264 if (ArmSystem::highestELIs64(tc) && ArmSystem::highestEL(tc) == el) {
265 // Target EL is the highest one in a system where
266 // the highest is using AArch64.
267 known = true; aarch32 = false;
257 } else if (!ArmSystem::highestELIs64(tc)) {
268 } else if (!ArmSystem::highestELIs64(tc)) {
258 // All levels are using AArch32
259 return true;
269 // All ELs are using AArch32:
270 known = true; aarch32 = true;
260 } else {
261 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
262 bool aarch32_below_el3 = (have_el3 && scr.rw == 0);
263
264 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
265 bool aarch32_at_el1 = (aarch32_below_el3
266 || (have_el2
267 && !isSecureBelowEL3(tc) && hcr.rw == 0));
268
269 // Only know if EL0 using AArch32 from PSTATE
270 if (el == EL0 && !aarch32_at_el1) {
271 } else {
272 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);
273 bool aarch32_below_el3 = (have_el3 && scr.rw == 0);
274
275 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
276 bool aarch32_at_el1 = (aarch32_below_el3
277 || (have_el2
278 && !isSecureBelowEL3(tc) && hcr.rw == 0));
279
280 // Only know if EL0 using AArch32 from PSTATE
281 if (el == EL0 && !aarch32_at_el1) {
271 CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
272 panic_if(cpsr.el != EL0, "EL0 state is UNKNOWN");
273 // EL0 controlled by PSTATE
282 // EL0 controlled by PSTATE
274 return cpsr.width != 0;
283 CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
284
285 known = (cpsr.el == EL0);
286 aarch32 = (cpsr.width == 1);
275 } else {
287 } else {
276 return (aarch32_below_el3 && el != EL3)
277 || (aarch32_at_el1 && (el == EL0 || el == EL1) );
288 known = true;
289 aarch32 = (aarch32_below_el3 && el != EL3)
290 || (aarch32_at_el1 && (el == EL0 || el == EL1) );
278 }
279 }
291 }
292 }
293
294 return std::make_pair(known, aarch32);
280}
281
282bool
283isBigEndian64(ThreadContext *tc)
284{
285 switch (opModeToEL(currOpMode(tc))) {
286 case EL3:
287 return ((SCTLR) tc->readMiscReg(MISCREG_SCTLR_EL3)).ee;

--- 671 unchanged lines hidden ---
295}
296
297bool
298isBigEndian64(ThreadContext *tc)
299{
300 switch (opModeToEL(currOpMode(tc))) {
301 case EL3:
302 return ((SCTLR) tc->readMiscReg(MISCREG_SCTLR_EL3)).ee;

--- 671 unchanged lines hidden ---