Skip to content

Commit 2362506

Browse files
sean-jcbonzini
authored andcommitted
KVM: arm64: Don't mark "struct page" accessed when making SPTE young
Don't mark pages/folios as accessed in the primary MMU when making a SPTE young in KVM's secondary MMU, as doing so relies on kvm_pfn_to_refcounted_page(), and generally speaking is unnecessary and wasteful. KVM participates in page aging via mmu_notifiers, so there's no need to push "accessed" updates to the primary MMU. Dropping use of kvm_set_pfn_accessed() also paves the way for removing kvm_pfn_to_refcounted_page() and all its users. Tested-by: Alex Bennée <[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 66bc627 commit 2362506

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

arch/arm64/include/asm/kvm_pgtable.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,8 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size);
674674
*
675675
* If there is a valid, leaf page-table entry used to translate @addr, then
676676
* set the access flag in that entry.
677-
*
678-
* Return: The old page-table entry prior to setting the flag, 0 on failure.
679677
*/
680-
kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr);
678+
void kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr);
681679

682680
/**
683681
* kvm_pgtable_stage2_test_clear_young() - Test and optionally clear the access

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,19 +1245,16 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size)
12451245
NULL, NULL, 0);
12461246
}
12471247

1248-
kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr)
1248+
void kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr)
12491249
{
1250-
kvm_pte_t pte = 0;
12511250
int ret;
12521251

12531252
ret = stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0,
1254-
&pte, NULL,
1253+
NULL, NULL,
12551254
KVM_PGTABLE_WALK_HANDLE_FAULT |
12561255
KVM_PGTABLE_WALK_SHARED);
12571256
if (!ret)
12581257
dsb(ishst);
1259-
1260-
return pte;
12611258
}
12621259

12631260
struct stage2_age_data {

arch/arm64/kvm/mmu.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,18 +1707,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17071707
/* Resolve the access fault by making the page young again. */
17081708
static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)
17091709
{
1710-
kvm_pte_t pte;
17111710
struct kvm_s2_mmu *mmu;
17121711

17131712
trace_kvm_access_fault(fault_ipa);
17141713

17151714
read_lock(&vcpu->kvm->mmu_lock);
17161715
mmu = vcpu->arch.hw_mmu;
1717-
pte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa);
1716+
kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa);
17181717
read_unlock(&vcpu->kvm->mmu_lock);
1719-
1720-
if (kvm_pte_valid(pte))
1721-
kvm_set_pfn_accessed(kvm_pte_to_pfn(pte));
17221718
}
17231719

17241720
/**

0 commit comments

Comments
 (0)