mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 16:44:58 +02:00
KVM: RISC-V: Mark "struct page" pfns dirty iff a stage-2 PTE is installed
Don't mark pages dirty if KVM bails from the page fault handler without installing a stage-2 mapping, i.e. if the page is guaranteed to not be written by the guest. In addition to being a (very) minor fix, this paves the way for converting RISC-V to use kvm_release_faultin_page(). Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Acked-by: Anup Patel <anup@brainfault.org> Signed-off-by: Sean Christopherson <seanjc@google.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20241010182427.1434605-58-seanjc@google.com>
This commit is contained in:
parent
85c7869e30
commit
9b3639bb02
|
|
@ -669,7 +669,6 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
|
|||
goto out_unlock;
|
||||
|
||||
if (writable) {
|
||||
kvm_set_pfn_dirty(hfn);
|
||||
mark_page_dirty(kvm, gfn);
|
||||
ret = gstage_map_page(kvm, pcache, gpa, hfn << PAGE_SHIFT,
|
||||
vma_pagesize, false, true);
|
||||
|
|
@ -682,6 +681,9 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
|
|||
kvm_err("Failed to map in G-stage\n");
|
||||
|
||||
out_unlock:
|
||||
if ((!ret || ret == -EEXIST) && writable)
|
||||
kvm_set_pfn_dirty(hfn);
|
||||
|
||||
spin_unlock(&kvm->mmu_lock);
|
||||
kvm_set_pfn_accessed(hfn);
|
||||
kvm_release_pfn_clean(hfn);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user