Something that's always baffled me: why don't CPUs have a "save ALL state" and "restore ALL state" instructions? Why does every new set of CPU registers seem to require an OS update to save them on context switches?
Why isn't memset() async-signal-safe?
11–20 of 98 posts
Re: Why isn't memset() async-signal-safe?
#12Something that's always baffled me: why don't CPUs have a "save ALL state" and "restore ALL state" instructions? Why does every new set of CPU registers seem to require an OS update to save them on context switches?
They do, now. On current Intel CPUs, you can use xsave and xrstor to save and load the complete state, including all new state information. Ring 0 code can ask the CPU for the size of that state (via CPUID leaf 0xd), and allocate the appropriate amount of space per task.
Re: Why isn't memset() async-signal-safe?
#13Related: Unix signals are deemed "unfixable" by some: https://lwn.net/Articles/414618/
Re: Why isn't memset() async-signal-safe?
#14Something that's always baffled me: why don't CPUs have a "save ALL state" and "restore ALL state" instructions? Why does every new set of CPU registers seem to require an OS update to save them on context switches?
When the number of state variables gets bigger, that buffer needs to get bigger. Need some cooperation from the operating system to increase the size of the buffers, that's all.
Re: Why isn't memset() async-signal-safe?
#15Re: Why isn't memset() async-signal-safe?
#16Something that's always baffled me: why don't CPUs have a "save ALL state" and "restore ALL state" instructions? Why does every new set of CPU registers seem to require an OS update to save them on context switches?
Re: Why isn't memset() async-signal-safe?
#17Related: Unix signals are deemed "unfixable" by some: https://lwn.net/Articles/414618/
Re: Why isn't memset() async-signal-safe?
#18Something that's always baffled me: why don't CPUs have a "save ALL state" and "restore ALL state" instructions? Why does every new set of CPU registers seem to require an OS update to save them on context switches?
Re: Why isn't memset() async-signal-safe?
#19Earlier quoted context omitted.
They do, now. On current Intel CPUs, you can use xsave and xrstor to save and load the complete state, including all new state information. Ring 0 code can ask the CPU for the size of that state (via CPUID leaf 0xd), and allocate the appropriate amount of space per task.
Oh wow. When did this change? I vaguely seem to remember that as recently as Windows 7 (or was it 8.0?) there was trouble with AVX2 or something, but I can't find the info anywhere at the moment.