This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to know if the processor is in EL0 state on armv8?

Hi Fellows,

I want to determine in code, if the processor is in EL0 mode or not. I read CurrentEL register to do this but if my code is running from EL0, it throws an exception since we can't access CurrentEL from EL0. Is there any alternative and easy way to do determine mode that works even at EL0? Thanks.

Regards,

Mughees

Parents
  • Being unable to access CurrentEL is a good indication that you *are* in EL0.

    I would:
    a) argue that code should know which EL it is running in and

    b) if you are checking for security purposes then only >EL1 really cares as EL0 code should never even try to perform a privileged operation. If EL1 checks CurrentEL and the access fails this indicates something has gone horribly wrong and the exception (and resultant privilege escalation) is a good thing.
Reply
  • Being unable to access CurrentEL is a good indication that you *are* in EL0.

    I would:
    a) argue that code should know which EL it is running in and

    b) if you are checking for security purposes then only >EL1 really cares as EL0 code should never even try to perform a privileged operation. If EL1 checks CurrentEL and the access fails this indicates something has gone horribly wrong and the exception (and resultant privilege escalation) is a good thing.
Children
  • Well I agree about just determining the level, but using the same code and doing something different is a reasonable idea. It is what multiple threads within a single virtual address space do and what the thread id register is for. Plus it is I think quite a good idea to be able to share library code between privilege levels. A while ago I'd been thinking about running the client part of a  database system at a privileged level to control system resources and sharing the code with the user level.

  • Hi,

    What will be the exception level when the board start up?
    Is there a way to set up this?
    How do i chose whether i should go to a higher exception level?

    regards,
    Ajeesh