Skip to content

Commit ebe4afd

Browse files
committed
Flush tlb from host
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 729aca1 commit ebe4afd

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • src/hyperlight_host/src/hypervisor/virtual_machine

src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,22 @@ impl VirtualMachine for WhpVm {
729729
WHvResetPartition(self.partition)
730730
.map_err(|e| RegisterError::ResetPartition(e.into()))?;
731731

732+
// WHvResetPartition resets the VMCB but may not update the
733+
// hypervisor's internal register-change tracking used for
734+
// TLB flush decisions on AMD SVM. Explicitly re-announce
735+
// the post-reset CR0 (PG=0) via the WHP API so that the
736+
// subsequent restore_sregs() write of CR0 with PG=1 is
737+
// detected as a paging-mode change, triggering
738+
// SVM_TLB_FLUSH_CURRENT_ASID on the next VMRUN.
739+
let post_reset_sregs = self.sregs()?;
740+
self.set_registers(&[(
741+
WHvX64RegisterCr0,
742+
Align16(WHV_REGISTER_VALUE {
743+
Reg64: post_reset_sregs.cr0,
744+
}),
745+
)])
746+
.map_err(|e| RegisterError::ResetPartition(e.into()))?;
747+
732748
// WHvResetPartition resets LAPIC to power-on defaults.
733749
// Re-initialize it when LAPIC emulation is active.
734750
#[cfg(feature = "hw-interrupts")]

0 commit comments

Comments
 (0)