Hi Experts,
I am developping linux kernel with ARMv8-A processor.
Kernel can work both secure EL1 and non-secure EL1.
How to obtain CPU state is secure or non-secure in kernel?
SCR_EL3[0] can indicate EL1/EL0 secure/non-secure state, but it can not be accessed in kernel.
Is there CPU register can be accessed in kernel to indicate secure or non-secure state?
Thanks for your attention!
Best Regards,
yan
It's unusual to have a piece of code that might run in either Secure or Non-secure state on a given processor. Partly because the two Security states are (typically) used for very different things. It's therefore unlikely that same, say, OS would be the best choice for both worlds. Because of this, most code will just "know" what Security state it expects to run in.At EL1 there isn't an easy way of determining the Security state. There are few ways you could infer it. For example, some of the GIC registers (e.g. ICC_BPR1_EL1 and GICR_IGROUPRn) behave differently in Secure and Non-secure states. That's still not perfect, as in EL1 there might be a hypervisor that your code is running under. That hypervisor could be emulating some of your accesses.
Thanks for your explanation.
I use GICD_IGROUPRn to check, it can work.