Prevent possible UB, and use naked functions correctly.
More recent versions of
rustc have started to warn about
#[naked] functions which contain more than only a single inline asm block, which will eventually be phased out. Not only that, but
rsp cannot be changed in inline assembly, if there is regular code in the same function.
This MR fixes that, while simultaneously also making sure that the context switch locks are only released inside the switch_to function, by calling a rust hook.