Skip to content

Comments

MigTD: Remove lock for REPORTSTATUS flags#717

Open
haitaohuang wants to merge 1 commit intointel:mainfrom
haitaohuang:fix
Open

MigTD: Remove lock for REPORTSTATUS flags#717
haitaohuang wants to merge 1 commit intointel:mainfrom
haitaohuang:fix

Conversation

@haitaohuang
Copy link
Contributor

The interrupt handler (vmcall_service_callback) previously held a spin::Mutex on VMCALL_MIG_REPORTSTATUS_FLAGS (BTreeMap). On the single-threaded TDX guest, if an interrupt fires while non-ISR code holds the same lock, the ISR spins forever — guaranteed deadlock.

Replace the per-request BTreeMap<u64, AtomicBool> + Mutex with direct buffer polling: each report_status poll_fn checks its own private shared-memory buffer's datastatus field on every poll cycle. This is correct because:

  • The buffer is the ground truth for VMM completion
  • Any interrupt (WFR or otherwise) wakes the CPU from HLT, triggering poll_tasks() which re-polls all pending futures
  • Each consumer checks its own buffer — no shared state, no interference between concurrent report_status calls

The ISR now only sets VMCALL_SERVICE_FLAG (for wait_for_request).

The interrupt handler (vmcall_service_callback) previously held a
spin::Mutex on VMCALL_MIG_REPORTSTATUS_FLAGS (BTreeMap). On the
single-threaded TDX guest, if an interrupt fires while non-ISR code
holds the same lock, the ISR spins forever — guaranteed deadlock.

Replace the per-request BTreeMap<u64, AtomicBool> + Mutex with direct
buffer polling: each report_status poll_fn checks its own private
shared-memory buffer's datastatus field on every poll cycle. This is
correct because:
- The buffer is the ground truth for VMM completion
- Any interrupt (WFR or otherwise) wakes the CPU from HLT, triggering
  poll_tasks() which re-polls all pending futures
- Each consumer checks its own buffer — no shared state, no interference
  between concurrent report_status calls

The ISR now only sets VMCALL_SERVICE_FLAG (for wait_for_request).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
@haitaohuang haitaohuang requested a review from jyao1 as a code owner February 22, 2026 21:26
@haitaohuang
Copy link
Contributor Author

The build failure seems network issue

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