Skip to content

Commit 6acf516

Browse files
Ricardo Kolleroupton
authored andcommitted
KVM: arm64: Split huge pages during KVM_CLEAR_DIRTY_LOG
This is the arm64 counterpart of commit cb00a70 ("KVM: x86/mmu: Split huge pages mapped by the TDP MMU during KVM_CLEAR_DIRTY_LOG"), which has the benefit of splitting the cost of splitting a memslot across multiple ioctls. Split huge pages on the range specified using KVM_CLEAR_DIRTY_LOG. And do not split when enabling dirty logging if KVM_DIRTY_LOG_INITIALLY_SET is set. Signed-off-by: Ricardo Koller <ricarkol@google.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Link: https://lore.kernel.org/r/20230426172330.1439644-12-ricarkol@google.com Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 3005f6f commit 6acf516

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

arch/arm64/kvm/mmu.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,8 @@ static void kvm_mmu_split_memory_region(struct kvm *kvm, int slot)
11141114
* @mask: The mask of pages at offset 'gfn_offset' in this memory
11151115
* slot to enable dirty logging on
11161116
*
1117-
* Writes protect selected pages to enable dirty logging for them. Caller must
1118-
* acquire kvm->mmu_lock.
1117+
* Writes protect selected pages to enable dirty logging, and then
1118+
* splits them to PAGE_SIZE. Caller must acquire kvm->mmu_lock.
11191119
*/
11201120
void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
11211121
struct kvm_memory_slot *slot,
@@ -1128,6 +1128,17 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
11281128
lockdep_assert_held_write(&kvm->mmu_lock);
11291129

11301130
stage2_wp_range(&kvm->arch.mmu, start, end);
1131+
1132+
/*
1133+
* Eager-splitting is done when manual-protect is set. We
1134+
* also check for initially-all-set because we can avoid
1135+
* eager-splitting if initially-all-set is false.
1136+
* Initially-all-set equal false implies that huge-pages were
1137+
* already split when enabling dirty logging: no need to do it
1138+
* again.
1139+
*/
1140+
if (kvm_dirty_log_manual_protect_and_init_set(kvm))
1141+
kvm_mmu_split_huge_pages(kvm, start, end);
11311142
}
11321143

11331144
static void kvm_send_hwpoison_signal(unsigned long address, short lsb)

0 commit comments

Comments
 (0)