Skip to content

fix: classify KVM_RUN failures by whether the timer fired, not was armed - #92

Open
perbu wants to merge 1 commit into
masterfrom
pr1-timer-classify
Open

fix: classify KVM_RUN failures by whether the timer fired, not was armed#92
perbu wants to merge 1 commit into
masterfrom
pr1-timer-classify

Conversation

@perbu

@perbu perbu commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Step 1 of the ladder in #91. Standalone.

run_once() tested timer_ticks, which holds the configured timeout, so every KVM_RUN failure inside a timed run threw Timeout Exception and discarded errno — a guest EFAULT was indistinguishable from a slow request. A timeout now requires the timer to have actually fired (the SIGUSR2 handler's thread_local, or EINTR with a timer armed); everything else keeps its errno and routes to the existing EFAULT/generic branches. errno is captured inside the ioctl scope, before the profiler destructor can overwrite it.

Same treatment on arm64. Unit suite on x86-64 matches the master baseline; the arm64 side was validated on an Asahi host on the original branch.

🤖 Generated with Claude Code

run_once() tested timer_ticks, which holds the *configured* timeout in
ms, so every KVM_RUN failure inside a timed run was thrown as "Timeout
Exception" and its errno discarded - an EFAULT from a guest touch of
protected or unbacked host memory in particular became indistinguishable
from a slow request. Now a timeout requires the timer to have actually
fired (the SIGUSR2 handler's thread_local, or EINTR with a timer armed);
everything else keeps its errno and routes to the existing EFAULT /
generic branches. errno is captured inside the ioctl scope before the
profiler's destructor can overwrite it. Genuine timeouts still throw
MachineTimeoutException with unchanged message and data.

arm64 mirror transcribed from the amd64 shape; not build-verified here
(no aarch64 toolchain on this box).

Found while testing VmGroup PerGroup guard bands, where the band fault
surfaces as -EFAULT from KVM_RUN and the relabel would have been a
diagnosability regression.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant