8 Commits
Author SHA1 Message Date
Jimmy TranandgVisor bot 544a60277d kvm: RSEQ: Add RSEQ support
This change adds RSEQ support for platform/kvm. RSEQ is disabled by default.

To support RSEQ, the KVM platform must provide two key capabilities:
 (1) A stable, unique CPU ID.
 (2) A way to detect when a thread as been preempted.

This implementation provides the necessary support as follows:
CPU ID:
  - platform/kvm now advertises the KVM vCPU ID as the cpu_id

Preemption Detection:
  - Compares the last context the CPU ran against the current context being
 scheduled.
  - Compares the context's rseqCPU and CPU ID retrieved by the platform

To facilitate this, several new methods are introduced to the platform
interface and implemented by platform/kvm:
 - HasCpuNumbers()
 - NumCPUs()
 - DetectsCPUPreemption()
 - PreemptCpu()
 - PreemptAllCpus()

A new user-facing KVM specific option, use_cpu_numbers, is introduced to
effectively feature guard RSEQ. When use_cpu_numbers is true, vCPU IDs are
exposed to the guest, enabling RSEQ support. Setting it to false reverts to
the previous behavior and effectively disables RSEQ for applications that
rely on it.

PiperOrigin-RevId: 844846226
2025-12-15 11:14:18 -08:00
Jamie LiuandgVisor bot f5f4c2e420 Downgrade rseq test TODOs to NOTEs.
PiperOrigin-RevId: 621626382
2024-04-03 13:46:13 -07:00
Jamie LiuandgVisor bot 636b2b13ba Copy out rseq::cpu_id_start and rseq::cpu_id even if they don't change.
Userspace can mutate them, and this is consistent with Linux.

PiperOrigin-RevId: 610902711
2024-02-27 16:00:13 -08:00
Zach KoopmansandgVisor bot 493eb43691 Fix return for rseq_test.
Accept 128 + SIGNAL as well as SIGNAL as valid
returns for fork/exec tests.

Also, make changes so that test compiles in opensource. Test
had compile errors on latest Ubuntu 16.04 image with updated bazel to
3.4.0 (as well as base 2.0) used for Kokoro tests.

PiperOrigin-RevId: 327510310
2020-08-19 14:46:55 -07:00
Adin ScannellandgVisor bot 456f4ac3f1 Add notes to relevant tests.
These were out-of-band notes that can help provide additional context
and simplify automated imports.

PiperOrigin-RevId: 293525915
2020-02-05 22:46:35 -08:00
Adin ScannellandgVisor bot 1b8ff2ce79 Change to standard types.
PiperOrigin-RevId: 290846481
2020-01-21 17:28:57 -08:00
gVisor bot 33f3ef287f Merge pull request #1492 from majek:err_typo_in_netstack_tests
PiperOrigin-RevId: 290840370
2020-01-21 16:32:49 -08:00
Michael PrattandgVisor bot c0156557b6 Add tests for rseq(2)
Add a decent set of syscall tests for rseq(2). These are a bit awkward because
of issues with library integration. libc may register rseq on thread start
(including before main on the initial thread), precluding much testing. Thus we
run tests in a libc-free subprocess.

Support for rseq(2) in gVisor will come in a later commit.

PiperOrigin-RevId: 284595994
2019-12-09 11:22:31 -08:00