bmarcot / vega

vega -- The Unix-like Operating System for micro-controllers (ARM Cortex-M4)
6 stars 1 forks source link

arch/arm: fork(): Copy non-scratch registers of parent process #34

Closed bmarcot closed 7 years ago

bmarcot commented 7 years ago

Non-scratch registers are currently not restored in forked process. They need to be restored in the new process.

This is an issue in current kernel architecture, because non-scratch registers are not saved on exception entry. They are rather saved on the go (in function prologue, and restored in function epilogue), as functions in the kernel use them. Then they are saved on a thread switch. But at this time this is a mix a user regs and kernel regs.

To fix fork() we need to always save all the user registers because there is no way to retrieve them once the kernel starts clobbering them.