4 Commits
Author SHA1 Message Date
Andrei VaginandgVisor bot 8890371e35 platform/kvm: use per-thread signal stack to run bluepill handler
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
2024-10-11 16:40:39 -07:00
Konstantin BogomolovandgVisor bot fa27ee0b23 Extract kvm variants of Syscall helpers to their own pkg.
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
2024-09-30 15:22:23 -07:00
Konstantin BogomolovandgVisor bot 0760a3df59 kvm: reduce stack usage
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
2024-09-27 16:58:17 -07:00
Andrei VaginandgVisor bot 374a11a7cd platform/kvm: rewriting bluepill() without signal handler trampolining
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
2024-08-19 14:50:36 -07:00