arch/loongarch/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
With secondary MMU page table, if there is read page fault, page write
privilege will not set even if it is writable from master MMU page
table. This logic only works if dirty tracking is enabled, page table
can be set as page_write if dirty tracking is disabled.
It reduces extra page fault on secondary MMU page table if VM finishes
migration, where master MMU page table is ready and secondary MMU page
is fresh.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
arch/loongarch/kvm/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 @@ static int kvm_map_page(struct kvm_vcpu *vcpu, unsigned long gpa, bool write)
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);
}
base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
--
2.39.3
Applied, thanks.
Huacai
On Tue, Sep 30, 2025 at 5:17 PM Bibo Mao <maobibo@loongson.cn> wrote:
>
> With secondary MMU page table, if there is read page fault, page write
> privilege will not set even if it is writable from master MMU page
> table. This logic only works if dirty tracking is enabled, page table
> can be set as page_write if dirty tracking is disabled.
>
> It reduces extra page fault on secondary MMU page table if VM finishes
> migration, where master MMU page table is ready and secondary MMU page
> is fresh.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
> arch/loongarch/kvm/mmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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 @@ static int kvm_map_page(struct kvm_vcpu *vcpu, unsigned long gpa, bool write)
>
> 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);
> }
>
>
> base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
> --
> 2.39.3
>
© 2016 - 2025 Red Hat, Inc.