Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about lesson 2 exception level #131

Open
rgbstar opened this issue Aug 12, 2019 · 1 comment
Open

Question about lesson 2 exception level #131

rgbstar opened this issue Aug 12, 2019 · 1 comment

Comments

@rgbstar
Copy link

rgbstar commented Aug 12, 2019

you mentioned "when we enter el1_entry function the execution should be already at EL1 mode.", but

int el = get_el(); printf("Exception level: %d \r\n", el);

the code shows it is exception level 3, seems self contradiction,

also, without calling "svc", how did you change the exception level from 3 to 1?

thanks in advance!

@sferrini
Copy link
Contributor

Hi @rgbstar,

The svc (Supervisor Call) instruction generates a synchronous exceptions that traps EL0 into EL1, so it's not used to drop EL but instead it's used to raise it. For example if user-space (running at EL0) want to request an OS service (running at EL1), it will use the svc instruction.

If you want to drop EL, you use the eret (Exception return) instruction. It will restore the processor state using spsr_eln (which in-fact also contains the EL to restore) and elr_eln (address to return to).

Have a look at switching-to-el1 from lesson02 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants