On 16/05/19 14:50, Peter Maydell wrote: > On Wed, 15 May 2019 at 10:48, Stefan Hajnoczi <stefa...@gmail.com> wrote: >> 1. It's required for Intel Control-flow Enforcement Technology (CET). >> The existing ucontext backend doesn't work with CET. >> 2. It's faster than the existing ucontext implementation. > > Mmm, I think we've talked about 1 before, but I think it would > be useful to clearly state why we need to do things here.
The reason is that, with CET enabled, setjmp and longjmp assume that they are used only to unwind the stack and not to switch to a completely different one. You are supposed to use swapcontext for that, but it doesn't work for QEMU coroutines because it saves/restores the signal mask; that is not only slower, it's incorrect we want the signal mask to be a property of the thread, not the coroutine. > It's also useful for identifying whether we need an asm > backend for every host, or only some hosts (and if so which). It's not needed for _any_ host (except x86 if you want CET support). I wrote these three backends to ensure that it could be ported without much effort on any host. If you prefer not having an aarch64 backend, for example, I can leave it out. Paolo