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
Re: AArch64: calling EL0 function from EL1
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):
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();
Re: AArch64: calling EL0 function from EL1
Thanks Schnoogle, I wanted to be sure.
Best,
Dpotop
Best,
Dpotop
dpotop