nvme_driver: add timeout to controller ready/reset wait loops - #3976
Open
Novikov Kirill (knQzx) wants to merge 1 commit into
Open
nvme_driver: add timeout to controller ready/reset wait loops#3976Novikov Kirill (knQzx) wants to merge 1 commit into
Novikov Kirill (knQzx) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the NVMe driver’s controller bring-up/reset paths by adding a CAP.TO-derived deadline to previously-unbounded CSTS.RDY polling loops, preventing permanent hangs when a controller never reaches the expected ready state (including fuzzing scenarios).
Changes:
- Add a
ready_timeout(cap)helper derived from CAP.TO (500ms units, 3s floor when TO=0) and use it to bound the CC.EN=1 “wait for RDY set” loop. - Bound
Bar0::reset()’s “wait for RDY clear” loop using the same CAP.TO-derived deadline (preserving the existingResult<(), u32>signature). - Add a unit test that mocks CAP.TO and a stuck CSTS to assert
NvmeDriver::new()errors instead of hanging, and implementset_mock_response_u32to support that mock.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| vm/devices/storage/disk_nvme/nvme_driver/src/tests.rs | Adds a regression test for controller-ready timeout and enables mocking u32 MMIO reads (CSTS). |
| vm/devices/storage/disk_nvme/nvme_driver/src/registers.rs | Introduces CAP.TO-based timeout helper and applies it to the reset RDY-clear polling loop. |
| vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs | Applies CAP.TO-based timeout to the controller-enable RDY-set polling loop and bails with an error on expiry. |
Contributor
Author
|
@microsoft-github-policy-service agree |
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.
the enable() wait-for-RDY loop and Bar0::reset() wait-for-RDY-clear loop both poll with Backoff forever, so a stuck emulated device, a broken physical device, or a malicious VF that never lets the controller reach the expected state hangs the driver thread, and it also blocks the fuzzer from exercising setup-time parameters
this is the minimal fix from the issue's suggested fix: derive a deadline from CAP.TO (500ms units, 3s floor when TO is 0) and bound both loops
kept out of scope on purpose: no full reset support or DMA quiescence, and nothing frees or unaliases DMA memory on the timeout path, that broader work is a bigger change and can follow up separately
fixes #3022