Files
DragonOS/docs
LoGin 60c7f860d3 feat(kernel): add SMP-safe text patching (#2203)
* feat(kernel): add SMP-safe text patching

Introduce a transactional text patching core and an x86_64 backend that parks remote CPUs, validates expected instruction bytes, writes through dedicated RW+NX fixmap aliases, and synchronizes instruction fetch before returning.

Vendor static-keys 0.8.2 with a minimal transactional backend interface so a key publishes its enabled state only after every branch site commits successfully. Migrate tracepoints to audited DragonOS declarations and propagate control-plane failures without adding work to the disabled fast path.

Move perf event final release to a preallocated deferred worker so File::drop never sleeps or patches text. Quiesce patching during reboot and add single-CPU, SMP stable-epoch, tracepoint, and deferred-release coverage.

RISC-V and LoongArch64 remain fail-closed until their SMP, IPI, and W^X prerequisites are implemented.

Signed-off-by: longjin <longjin@dragonos.org>

* doc: add text patching docs

Signed-off-by: longjin <longjin@dragonos.org>

* fix(kernel): address text patching regressions

Preserve tracepoint enablement on architectures without a live text-patching backend by using the Linux-style dynamic-key fallback, while keeping x86 static branches unchanged.

Validate all early-ioremap size and address arithmetic before slot allocation, publish static-key initialization with acquire/release ordering, and restore hosted dependencies required by workspace tests.

Signed-off-by: longjin <longjin@dragonos.org>

* fix(kernel): satisfy x86 text patching lints

Use direct iteration for the text-poke alias table, remove a redundant perf-worker closure, and document the unsafe transaction queue contract.

Signed-off-by: longjin <longjin@dragonos.org>

* fix(perf): retry transient text patch timeouts

Keep the release node and callbacks alive when an x86 text rendezvous times out before commit, then retry from the sleepable worker after a bounded backoff. Document the retry-safety contract for perf event implementations.

Signed-off-by: longjin <longjin@dragonos.org>

* fix(perf): requeue timed-out releases

Return a timed-out release node to the existing intrusive queue after backoff so one unresponsive text-patch target cannot monopolize the global perf release worker.

Signed-off-by: longjin <longjin@dragonos.org>

* test(tracepoint): restore SMP test affinity

Use an RAII guard to restore the gtest thread's original CPU mask on both normal completion and fatal assertion exits.

Signed-off-by: longjin <longjin@dragonos.org>

* fix(kernel): enforce strong text patch completion

Use the calibrated TSC only for the boot-time rendezvous probe, then give live text updates stop-machine-style strong completion semantics. Remove deferred perf retry amplification and route executable-text invariant failures through a no-unwind machine stop.

Signed-off-by: longjin <longjin@dragonos.org>

---------

Signed-off-by: longjin <longjin@dragonos.org>
2026-08-20 00:47:48 +08:00
..
2025-05-23 02:02:48 +08:00
2022-06-17 23:50:40 +08:00