[bug] Avoid holding the pipeline lock across management uart writes - #1206
Open
zeeshanlakhani wants to merge 1 commit into
Open
[bug] Avoid holding the pipeline lock across management uart writes#1206zeeshanlakhani wants to merge 1 commit into
zeeshanlakhani wants to merge 1 commit into
Conversation
`handle_management_message` took the p4 pipeline mutex at the top of the function and held it while writing responses to the management uart, yielding whenever the one-byte FIFO was full. If a queue notify landed on a vcpu during that window, `process_guest_packet` blocked on the same mutex, the vcpu never returned from its PIO exit, and the guest could no longer drain the tty, deadlocking the entire guest. Now, we take the lock only where table state is read or written, serialize dump responses before writing, and bound uart writes with a 30-second deadline so that a guest that stops reading the management tty cannot pin the handler thread. A write that times out mid-response leaves a partial frame in the tty. The handler remembers this and terminates the stale frame with a newline before the next response, so framing recovers after one possibly garbled read. *Note*: I ran into this issue on a long-running voxel session. The pre-fix binary reproduces it within minutes under a scadm polling loop, while the fixed one does not (A/B testing).
zeeshanlakhani
force-pushed
the
zl/softnpu-mgmt-deadlock
branch
from
August 31, 2026 01:48
6c4faed to
3d694ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
handle_management_messagetook the p4 pipeline mutex at the top of the function and held it while writing responses to the management uart, yielding whenever the one-byte FIFO was full. If a queue notify landed on a vcpu during that window,process_guest_packetblocked on the same mutex, the vcpu never returned from its PIO exit, and the guest could no longer drain the tty, deadlocking the entire guest.Now, we take the lock only where table state is read or written, serialize dump responses before writing, and bound uart writes with a 30-second deadline so that a guest that stops reading the management tty cannot pin the handler thread.
A write that times out mid-response leaves a partial frame in the tty. The handler remembers this and terminates the stale frame with a newline before the next response, so framing recovers after one possibly garbled read.
Note: I ran into this issue on a long-running voxel session. The pre-fix binary reproduces it within minutes under a scadm polling loop, while the fixed one does not (A/B testing).