I am working on a simple kernel and test it on Qemu which supports RasPi3. During the boot level. Ras Pi goes to EL3 level, and I set spsr_el3 to 1 and elr_el3 to kernel_main and then use eret to enter EL1 mode. My problem is I create a kernel thread which still in EL1 level. I want to switch the kernel thread to user level. What I did is that this kernel thread also set spsr_el1 to 0 and elr_el1 to a function pointer, then eret. But this case a sync interrupt, I think caused by this eret? Please help her
Do you use the MMU?
If so, did you enable r/w/x for user mode?
Regarding sync exception: Don't guess. Try to get the error information (ESR_EL1 and ELR_EL1).
Hi, How to enable r/w/x for user mode.
ESR code is 92000050, and PC already point to the function which I assigned to.
Thanks very much :)
Check the ARMv8-A manuals:
EC == 100100 Data Abort from a lower Exception level, that might be using AArch32 or AArch64.Used for MMU faults generated by data accesses, alignment faults other than those caused by Stack Pointer misalignment, and synchronous External aborts, including synchronous parity or ECC errors. Not used for debug related exceptions.This value is valid for all described registers.
So likely, the MMU setup is wrong.
Thank you very much for your help :) Let me do a quick check