From: Bibo Mao Date: Sun, 9 Nov 2025 08:02:09 +0000 (+0800) Subject: LoongArch: KVM: Set page with write attribute if dirty track disabled X-Git-Tag: v6.18-rc6~36^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37e9d1a91382661c2d1f656b54c5d22dfe7a8606;p=thirdparty%2Fkernel%2Flinux.git LoongArch: KVM: Set page with write attribute if dirty track disabled 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 Signed-off-by: Huacai Chen --- diff --git a/arch/loongarch/kvm/mmu.c b/arch/loongarch/kvm/mmu.c index 7c8143e79c12..a7fa458e3360 100644 --- a/arch/loongarch/kvm/mmu.c +++ b/arch/loongarch/kvm/mmu.c @@ -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); }