The user-space bluepill introduced the issue. With that change, we use a
per-vcpu stack to run bluepillHandler. BluepillHanlder releases a vcpu before
calling sigreturn, so it is still running on the vcpu stack. The race looks
like this: one thread releases a vcpu, another thread takes it and starts
using its stack, the first thread calls sigreturn with a corrupted signal
frame.

PiperOrigin-RevId: 684992950
These are already used in platform/kvm and pkg/sigframe. Maybe there will be
more in the future that are outside KVM, we don't want to keep redefining
these.
PiperOrigin-RevId: 680737814
Debug build functions use more stack space than normal, such that the
KVM-nosplit function call chain doesn't fit. This patch replaces calls into
unix.RawSyscall* functions with variants that do not grow the stack, and inlines
some functions in ring0/pagetables in order to reduce stack usage. Additionally
seccompMmapHandler is not used during debug builds anymore for making it fit
into the nosplit stack size requirements.
PiperOrigin-RevId: 679774881
Implement bluepill() without relying on a signal handler trampoline by
directly switching stacks and execution contexts. Here, it is implemented
just for x86_64. The arm64 part will be implemented separately.
Here are benchmark results before and after this change: Before:
BenchmarkWorldSwitchToUserRoundtrip-8 255940 4407 ns/op
After:
BenchmarkWorldSwitchToUserRoundtrip-8 307773 3765 ns/op
Suggested-by: Jamie Liu <jamieliu@google.com>
PiperOrigin-RevId: 664989586