News for hackers. Stuff that matters.
Re:Writing an OS in Rust: Returning from Exceptions by Animats on Wednesday September 21, 2016 @04:55PM (#12552148)
Hm. Is that code using the user's stack to handle an exception or interrupt? That's unsafe. If there's not enough user stack space (something the user can force), the kernel will get a double fault, usually a kernel panic condition. Normally, OSs above the DOS level switch to a kernel stack on an exception or interrupt.

There's hardware support to help with this; see "Task state segment" (16 and 32 bit x86 only, amd64 is different).

Re:Writing an OS in Rust: Returning from Exceptions by amluto on Wednesday September 21, 2016 @06:21PM (#12552795)
No. In fact, that hardware support is mandatory. The SP0 field is used unconditionally on a cross-privilege exception.

Sadly, AMD64 came up with a terrible design for SYSCALL, and an exception right after SYSCALL will not automatically switch stacks. The result is a big mess.

Re:Writing an OS in Rust: Returning from Exceptions by monocasa on Wednesday September 21, 2016 @05:56PM (#12552631)
He doesn't have user mode yet AFAICT.