Hi everyone,
Wherever I go on internet, the thing I read is that when SMC instruction is executed an exception is generated, it takes you to the highest exception level (EL3) where secure monitor is running.
In ARM v8 vector table, given on ARMv8-A architecture reference manual page 1800, there are four types of exceptions:
As there is no exception with name SMC, I want to ask under which exception type does SMC fall? If I have a baremetal program running on Cortex-A72, what do I need to do if want to write a SMC handler?
Any answers will be highly appreciated,
Thanks
SMC instruction - monitor mode of processor with dedicated banked registers (I am not a prcatical user of ARM Cortex-A ARMv8-A, but if you write the address of your exception handler to vector table and use in your bare metal SMC instruction you may trap to your monitor handler).
Read more in ARM Cortex-A Series Programmer’s Guide for ARMv8-A, Chapter 4.5 Changing execution state
Read more about exceptions in ARM Cortex-A Series Programmer’s Guide for ARMv8-A, Chapter 10. Exception handling
Exceptions caused by SMC instructions go to the Synchronous exception vector. This makes sense, because the exception is precise and is caused during program execution by an instruction. To know if the exception taken is really an SMC, you have to look at EL3_ESR register, since other things like translation table faults also vector synchronously. The ARMv8 A, Architecture Reference Manual describes how to decode it to figure out if it was indeed an exception caused by the SMC.
Thank you so much raghu.ncstate. This is exactly what I wanted to know. I also had the same thing in my mind but somehow, I don't know why, my SMC doesn't take me to synchronous exception handler but to simply a crash. I'll see that now. Thanks again for the precise reply :)
Umair