]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: KVM: Set page with write attribute if dirty track disabled
authorBibo Mao <maobibo@loongson.cn>
Sun, 9 Nov 2025 08:02:09 +0000 (16:02 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 10 Nov 2025 00:37:07 +0000 (08:37 +0800)
With secondary MMU page table, if there is a read page fault, the page's
write attribute will not set even if it is writable from master MMU page
table. This logic only works if dirty tracking is enabled, so page table
should be set with _PAGE_WRITE if dirty tracking is disabled.

It reduces extra page fault on secondary MMU page table if a VM finishes
migration, when the master MMU page table is ready and the secondary MMU
page is fresh.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/mmu.c

index 7c8143e79c127909f5d00997817de2e2d1cfb6ae..a7fa458e33605e31929260edf651f2d8158d74e6 100644 (file)
@@ -857,7 +857,7 @@ retry:
 
        if (writeable) {
                prot_bits = kvm_pte_mkwriteable(prot_bits);
-               if (write)
+               if (write || !kvm_slot_dirty_track_enabled(memslot))
                        prot_bits = kvm_pte_mkdirty(prot_bits);
        }