8.3. How To Handle Exceptions At Current Exception Level

8.3.1. Problem Statement

In previous generations of QNX on ARMv7 based processors, the QNX HLOS would catch exceptions and log output to terminal window in appropriate signal errors (SIGBUS, SIGABORT, etc). On the Jacinto 7, the QNX running on A72 core (which is ARMv8 based), update to the EA bit bit of the ARM SCR_EL3 register is set high by default in the ATF code, which is causing all exceptions to be routed to EL3, which in turns results in exception at terminal window, and lock up of system.

Setting of the EA bit to 0, at least for development or debug builds should be considered.

8.3.2. Solution

8.3.2.1. Option 1 - Code update

In order to set the EA bit 0, the below makefile can be modified, and the ATF rebuilt:

…/arm-trusted-firmware/plat/ti/k3/common/plat_common.mk

Modify: HANDLE_EA_EL3_FIRST := 1

To: HANDLE_EA_EL3_FIRST := 0

8.3.2.2. Option 2 - build time

The other easy option which avoids modifying the makefile is to specify the HANDLE_EA_EL3_FIRST flag as a command line option during the build of the ATF (bl31.bin)

cd $(ATF_DIR)
make  -s -j32 CROSS_COMPILE=$(GCC_LINUX_ARM_ROOT)/bin/aarch64-none-linux-gnu- PLAT=k3 TARGET_BOARD=generic SPD=opteed HANDLE_EA_EL3_FIRST=0

8.3.3. Example Output

Exception when EA Bit is set high:

ERROR: Unhandled External Abort received on 0x80000000 at EL3!
ERROR: exception reason=1 syndrome=0x92000210
PANIC in EL3.
x30 = 0x0000000070005650
x0 = 0x0000000000000000
x1 = 0x0000000000000060
x2 = 0x0000000000000060
x3 = 0x0000000000000008
x4 = 0x0000000000000039
x5 = 0x0000000000000039
x6 = 0x0000000000000009
x7 = 0x0000000000000000
x8 = 0x00000000a0000000
x9 = 0x0000000041023020
x10 = 0x000000000000073d
x11 = 0x0000000000000001
x12 = 0x000000000000000f
x13 = 0x0fffffffffffffff
x14 = 0x0000000000000000
x15 = 0x0000000000000000
x16 = 0x00000000010ae360
x17 = 0x0000000001040bd0
x18 = 0x00000000100c7af0
x19 = 0x0000000000000001
x20 = 0x0000000092000210
x21 = 0x0000000000000002
x22 = 0xffffff80830ad000
x23 = 0x000000000000000b
x24 = 0x00000000100c7f80
x25 = 0xffffff80830aa090
x26 = 0xffffff80830aa0a0
x27 = 0x000000000000000c
x28 = 0x0000000000000000
x29 = 0x000000007000b520
scr_el3 = 0x000000000000073d
sctlr_el3 = 0x0000000030cd183f
cptr_el3 = 0x0000000000000000
tcr_el3 = 0x0000000080803520
daif = 0x00000000000002c0
mair_el3 = 0x00000000004404ff
spsr_el3 = 0x0000000060000000
elr_el3 = 0x00000000100c8b08
ttbr0_el3 = 0x00000000700100e0
esr_el3 = 0x0000000092000210
far_el3 = 0x0000000028000000
spsr_el1 = 0x0000000060000000
elr_el1 = 0x0000000001051560
spsr_abt = 0x0000000000000000
spsr_und = 0x0000000000000000
spsr_irq = 0x0000000000000000
spsr_fiq = 0x0000000000000000
sctlr_el1 = 0x0000000034d5db1d
actlr_el1 = 0x0000000000000000
cpacr_el1 = 0x0000000000000000
csselr_el1 = 0x0000000000000002
sp_el1 = 0xffffff8083044000
esr_el1 = 0x0000000056000051
ttbr0_el1 = 0x00140008fa916000
ttbr1_el1 = 0x000000008000b000
mair_el1 = 0xff000044eeaa0400
amair_el1 = 0x0000000000000000
tcr_el1 = 0x00000014b5183519
tpidr_el1 = 0x0000000000000000
tpidr_el0 = 0x0000000000000000
tpidrro_el0 = 0x00000000100c7f90
par_el1 = 0x0000000000000000
mpidr_el1 = 0x0000000080000000
afsr0_el1 = 0x0000000000000000
afsr1_el1 = 0x0000000000000000
contextidr_el1 = 0x0000000000000000
vbar_el1 = 0xffffff8060085800
cntp_ctl_el0 = 0x0000000000000000
cntp_cval_el0 = 0x0000000000000000
cntv_ctl_el0 = 0x0000000000000005
cntv_cval_el0 = 0x0000000656368901
cntkctl_el1 = 0x0000000000000002
sp_el0 = 0x000000007000b520
isr_el1 = 0x0000000000000040
dacr32_el2 = 0x0000000000000000
ifsr32_el2 = 0x0000000000000000
cpuectlr_el1 = 0x0000001b00000040
cpumerrsr_el1 = 0x0000000000000000
l2merrsr_el1 = 0x0000000000000000

SIGBUS when EA Bit is set low:

Process 57363 (in32) terminated SIGBUS code=5 fltno=11 ip=00000000100c8b08(/proc /boot/in32@_btext+0x0000000000000078) mapaddr=0000000000000b08. ref=000000002800 0000
Bus error (core dumped)