jserv / mini-arm-os

Build a minimal multi-tasking OS kernel for ARM from scratch
Other
1.04k stars 242 forks source link

Wrong processor mode in first time exception return #27

Closed lecopzer closed 5 years ago

lecopzer commented 5 years ago

According to https://www.ptt.cc/bbs/ASM/M.1534260340.A.DC5.html

3d4ea334a96f20b78dace4da7ab145a7d906283c is buggy due to reset is in privilege level and thread mode.

But the commit assume reset_handler is in Handler mode and makes undefined behavior when first calling activate except 06-Preemptive.

By some experiment, I acknowledge that it can still work well in QEMU but fail in real HW (STMF429), and that misled me during checking 3d4ea334a96f20b78dace4da7ab145a7d906283c.

I've solving it in my local by hacking activate or thread_start. After cleanup the code, I will make a PR to solve it.