Skip to content

Commit 9d0c3f7

Browse files
authored
Defer clearing tlb flush flag (#1333)
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 53f840f commit 9d0c3f7

File tree

1 file changed

+14
-8
lines changed
  • src/hyperlight_host/src/hypervisor/hyperlight_vm

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ 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-
self.pending_tlb_flush = false;
296295
}
297296
// set RIP and RSP, reset others
298297
let regs = CommonRegisters {
@@ -319,13 +318,20 @@ impl HyperlightVm {
319318
.set_fpu(&CommonFpu::default())
320319
.map_err(DispatchGuestCallError::SetupRegs)?;
321320

322-
self.run(
323-
mem_mgr,
324-
host_funcs,
325-
#[cfg(gdb)]
326-
dbg_mem_access_fn,
327-
)
328-
.map_err(DispatchGuestCallError::Run)
321+
let result = self
322+
.run(
323+
mem_mgr,
324+
host_funcs,
325+
#[cfg(gdb)]
326+
dbg_mem_access_fn,
327+
)
328+
.map_err(DispatchGuestCallError::Run);
329+
330+
// Clear the TLB flush flag only after run() returns. The guest
331+
// may have been cancelled before it executed the flush.
332+
self.pending_tlb_flush = false;
333+
334+
result
329335
}
330336

331337
/// Resets the following vCPU state:

0 commit comments

Comments
 (0)