File tree Expand file tree Collapse file tree
src/hyperlight_host/src/hypervisor/hyperlight_vm Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments