Skip to content

Commit 06c4cd9

Browse files
dmatlacksean-jc
authored andcommitted
KVM: x86/mmu: WARN if huge page recovery triggered during dirty logging
WARN and bail out of recover_huge_pages_range() if dirty logging is enabled. KVM shouldn't be recovering huge pages during dirty logging anyway, since KVM needs to track writes at 4KiB. However it's not out of the possibility that that changes in the future. If KVM wants to recover huge pages during dirty logging, make_huge_spte() must be updated to write-protect the new huge page mapping. Otherwise, writes through the newly recovered huge page mapping will not be tracked. Note that this potential risk did not exist back when KVM zapped to recover huge page mappings, since subsequent accesses would just be faulted in at PG_LEVEL_4K if dirty logging was enabled. Signed-off-by: David Matlack <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 430e264 commit 06c4cd9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,9 @@ static void recover_huge_pages_range(struct kvm *kvm,
15901590
u64 huge_spte;
15911591
int r;
15921592

1593+
if (WARN_ON_ONCE(kvm_slot_dirty_track_enabled(slot)))
1594+
return;
1595+
15931596
rcu_read_lock();
15941597

15951598
for_each_tdp_pte_min_level(iter, root, PG_LEVEL_2M, start, end) {

0 commit comments

Comments
 (0)