Skip to content

Commit 3d9ce58

Browse files
committed
Plz w0rk I cri
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 9a9a4da commit 3d9ce58

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • src/hyperlight_host/src/hypervisor/hyperlight_vm

src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ impl HyperlightVm {
292292
let mut rflags = 1 << 1; // RFLAGS.1 is RES1
293293
if self.pending_tlb_flush {
294294
rflags |= 1 << 6; // set ZF if we need a tlb flush done before anything else executes
295+
// Note: pending_tlb_flush is cleared AFTER run() returns successfully,
296+
// not here. If the guest is cancelled before executing the flush
297+
// (e.g. CancelPending causes WHvRunVirtualProcessor to return
298+
// immediately), we must retry the flush on the next dispatch.
295299
}
296300
// set RIP and RSP, reset others
297301
let regs = CommonRegisters {
@@ -328,7 +332,11 @@ impl HyperlightVm {
328332
.map_err(DispatchGuestCallError::Run);
329333

330334
// Clear the TLB flush flag only after run() returns. The guest
331-
// may have been cancelled before it executed the flush.
335+
// may have been cancelled before it executed the flush (the CR4
336+
// PGE toggle in dispatch_function). If we cleared the flag
337+
// eagerly before run(), a cancelled dispatch would consume it
338+
// and the next dispatch would skip the flush, leaving stale
339+
// GVA→GPA TLB entries from the pre-restore page tables.
332340
self.pending_tlb_flush = false;
333341

334342
result

0 commit comments

Comments
 (0)