Hacker News new | past | comments | ask | show | jobs | submit login

> > STI; LRET works too, and it's faster for stupid reasons. > > Interesting, didn't know that.

In case you're curious, here's an implementation for Linux:

https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/...

There are a couple gotchas. RF and TF won't work right with the LRET hack. You need to make sure not to clear IF until the STI, as otherwise you lose the magic one-instruction no-interrupts window. And it's unclear in the spec if NMIs or MCEs honor that window, so, if you want to be robust and your kernel can recover from NMI or MCE, you should detect if this happens, rewind one instruction, and clear IF again before returning.

Other than that, it appears to work perfectly. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: