We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am trying to do follow this tutorial on baremetal code (https://github.com/s-matyukevich/raspberry-pi-os/blob/master/docs/lesson03/rpi-os.md) using QEMU. Specifically, starting at EL1, I'm trying to handle an exception at EL2 and then return to EL1.
To accomplish this, I've set the HCR_EL2.TRVM bit to 1 and then I call asm("msr x0, SCTLR_EL1") in my C code, which should (according to the documentation), cause
AArch64.SystemAccessTrap(EL2, 0x18);
to occur.
However, how would I catch this SystemAccessTrap and proceed to do something with it (in my case, I'd just want to print out the current exception level - which would be 2 while handling the exception - and then return)?
I'm not sure if a SystemAccessTrap is a synchronous exception, and if it is, how to handle it at EL2 (which I assume I'd need to implement given that the asm command will force an EL2 access due to the TRVM bit being set).
You may find the below document useful
developer.arm.com/.../exception-model