极术小姐姐 · 2020年02月03日

how to return from exception generated by SMC instruction

Hi,

I am experimenting execution level switching on A53. I go from EL3->El2, then call SMC instruction to return to EL3. As soon as SMC instruction is executed, the processor enters EL3 mode and an exception is generated.

I have written an exception handler to return from this question. My question is should I use an ERET at the end of the exception handler? In that case will it go back to EL2 or will remain in EL3(since the exception was generated in EL2)? I would like for the processor to remain in EL3. SHould I manually modify the ELR so that the processor remains in EL3. I want to know how it is normally done.

1 个回答 得票排序 · 时间排序
棋子 · 2020年02月03日

In ARMv8-A AArch64, ERET is the only exception return instruction. You would normally expect to use an ERET at the end of the handler.

The SMC instruction executed in EL2 triggered an exception which caused entry to EL3. The automatically generated ELR_EL3 and SPSR_EL3 values will point back to EL2, to the instruction immediately after the SMC. Therefore if you don't modify the ELR/SPSR and execute ERET, that's where execution will go.

If you want to return somewhere you need to modify ELR and/or SPSR before executing ERET.

Although if you want to stay in EL3, you don't necessarily have to execute in ERET at all. You could just branch to whatever code you want to run next.

你的回答
关注数
1
收藏数
0
浏览数
2124
棋子
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息