Preserve siginfo on HVC #9 faults

Merged
MA
4mo ago
+21-4

Summary

  • Honor X8==2 after HVC #9 instruction and data abort returns so delivered SIGSEGV frames are not overwritten.
  • Clear X8 after successful W^X toggles to avoid stale guest state selecting the drop-frame path.
  • Update signal delivery comments for the shared marker contract.

Root Cause

HVC #9 always returned through the W^X TLBI/retry epilogue. When the host side decided the fault was not a W^X toggle and delivered SIGSEGV instead, that epilogue restored the pre-HVC register frame over the SA_SIGINFO handler arguments installed by signal_deliver_fault().

Validation

  • make elfuse
  • make test-rosetta-audit
  • build/elfuse build/test-signal
  • build/elfuse build/test-fault-signal-mt

Skipped: make test-rosetta-jit because the x86_64 Luajit fixture is missing at externals/test-fixtures/x86_64-musl/rootfs/usr/bin/luajit.


Summary by cubic

Fixes corrupted SIGSEGV delivery after HVC #9 faults by preserving SA_SIGINFO frames. The shim now honors X8==2 on return at both abort paths, and the host clears X8 after successful W^X toggles.

  • Bug Fixes
    • On HVC #9 returns from instruction/data aborts, branch to drop the saved frame when X8==2 so installed handler args are kept.
    • Clear X8 in vcpu_run_loop after a successful W^X toggle to avoid stale state selecting the drop-frame path.
    • Update signal delivery comments to document the shared X8 marker and HVC #9 fallback behavior.