Skip to content

Commit 4a2bc01

Browse files
sean-jcbonzini
authored andcommitted
KVM: LoongArch: Mark "struct page" pfns accessed only in "slow" page fault path
Mark pages accessed only in the slow path, before dropping mmu_lock when faulting in guest memory so that LoongArch can convert to kvm_release_faultin_page() without tripping its lockdep assertion on mmu_lock being held. Reviewed-by: Bibo Mao <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Tested-by: Dmitry Osipenko <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-ID: <[email protected]>
1 parent 0fe133a commit 4a2bc01

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

arch/loongarch/kvm/mmu.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,10 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
552552
static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool write)
553553
{
554554
int ret = 0;
555-
kvm_pfn_t pfn = 0;
556555
kvm_pte_t *ptep, changed, new;
557556
gfn_t gfn = gpa >> PAGE_SHIFT;
558557
struct kvm *kvm = vcpu->kvm;
559558
struct kvm_memory_slot *slot;
560-
struct page *page;
561559

562560
spin_lock(&kvm->mmu_lock);
563561

@@ -570,8 +568,6 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
570568

571569
/* Track access to pages marked old */
572570
new = kvm_pte_mkyoung(*ptep);
573-
/* call kvm_set_pfn_accessed() after unlock */
574-
575571
if (write && !kvm_pte_dirty(new)) {
576572
if (!kvm_pte_write(new)) {
577573
ret = -EFAULT;
@@ -595,22 +591,10 @@ static int kvm_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa, bool writ
595591
}
596592

597593
changed = new ^ (*ptep);
598-
if (changed) {
594+
if (changed)
599595
kvm_set_pte(ptep, new);
600-
pfn = kvm_pte_pfn(new);
601-
page = kvm_pfn_to_refcounted_page(pfn);
602-
if (page)
603-
get_page(page);
604-
}
605-
spin_unlock(&kvm->mmu_lock);
606596

607-
if (changed) {
608-
if (kvm_pte_young(changed))
609-
kvm_set_pfn_accessed(pfn);
610-
611-
if (page)
612-
put_page(page);
613-
}
597+
spin_unlock(&kvm->mmu_lock);
614598

615599
if (kvm_pte_dirty(changed))
616600
mark_page_dirty(kvm, gfn);

0 commit comments

Comments
 (0)