dpotop
Posts: 86
Joined: Mon Nov 24, 2014 2:14 pm

AArch64: calling EL0 function from EL1

Mon Jan 13, 2020 4:42 pm

Hello,

I'd like for privileged (EL1) code to call an unprivileged (EL0) function, and
then get control back to EL1. Is there a simple way of doing it, which does not
involve context saving and SVC instructions?

Best,
Dumitru
dpotop

Schnoogle
Posts: 141
Joined: Sun Feb 11, 2018 4:47 pm

Re: AArch64: calling EL0 function from EL1

Wed Jan 15, 2020 2:26 pm

Hi,

as far as I'm aware this is not possible. The processor can only switch exception levels if an exception is raised (like an interrupt or an call to SMC, HYP, SVC) or using the ERET instruction. While ERET goes down the exceptions levels from EL3->EL2->EL1->EL0 the interrupts or system exception call instructions goes the exception levels up: EL0->EL1->EL2->EL3, there are exceptions to that where interrupts may stay in the same exception level but there is no other way to switch between them.

So when you are in EL1 and would like to call code in EL0 you need to do something like this (pseudo-code):

Code: Select all

switch_el1_to_el0_with_eret();
call el0_function();
switch from el0_to_el1_with_svc();

dpotop
Posts: 86
Joined: Mon Nov 24, 2014 2:14 pm

Re: AArch64: calling EL0 function from EL1

Thu Jan 16, 2020 7:50 pm

Thanks Schnoogle, I wanted to be sure.
Best,
Dpotop
dpotop

Return to “Bare metal, Assembly language”