Skip to content

Only clear 'cancel_requested' flag when cancelling vcpu run. #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Jun 4, 2025

Currently, it's possible for the cancel_requested flag to be cleared without the vcpu being cancelled. This can lead to a call to kill() being lost. Consider the following thread interleaving:

  1. Vcpu finishes vcpu::run()
  2. Other thread calls kill() which sets cancel_requested to true
  3. Vcpu sets cancel_requested to false.
  4. Other thread sends signal, which doesn't do anything because vcpu thread is in userspace.
  5. Vcpu returns as normal

This PR fixes it by only clearing the flag when the vcpu is actually interrupted.

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig ludfjig merged commit ae4c10a into hyperlight-dev:main Jun 4, 2025
45 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bugfix For PRs that fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants