Skip to content

Defer clearing tlb flush flag#1333

Open
ludfjig wants to merge 1 commit intohyperlight-dev:mainfrom
ludfjig:fix_tlb_flush_amd
Open

Defer clearing tlb flush flag#1333
ludfjig wants to merge 1 commit intohyperlight-dev:mainfrom
ludfjig:fix_tlb_flush_amd

Conversation

@ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Mar 20, 2026

Defer clearing TLB flush flag until after run to prevent losing it if the guest is cancelled before executing the flush. This can happen on windows for example. I noticed this on AMD cpus where guest would sometimes read old/stale memory.

Note: if run returns Ok, the guest hit HLT, meaning it ran through the stub which checks ZF and did the flush. If run returns Err the flush may not have happened but doesn't matter since caller is required to store the sandbox before next dispatch anyway (sandbox is poisoned), which will set the tlb flush flag to true again.

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig ludfjig added the kind/bugfix For PRs that fix bugs label Mar 20, 2026
@ludfjig ludfjig requested a review from Copilot March 20, 2026 21:24
@ludfjig ludfjig marked this pull request as ready for review March 20, 2026 21:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Defers clearing the VM’s pending TLB flush flag until after run() completes, aiming to avoid losing the flush request when the guest is cancelled before executing the flush stub.

Changes:

  • Stop clearing pending_tlb_flush when setting ZF in RFLAGS.
  • Capture run() result and clear pending_tlb_flush after run() returns.

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.

2 participants