@@ -86,6 +86,11 @@ static inline bool kvm_pte_valid(kvm_pte_t pte)
return pte & KVM_PTE_VALID;
}
+static inline bool kvm_pte_young(kvm_pte_t pte)
+{
+ return pte & KVM_PTE_LEAF_ATTR_LO_S2_AF;
+}
+
static inline u64 kvm_pte_to_phys(kvm_pte_t pte)
{
u64 pa = pte & KVM_PTE_ADDR_MASK;
@@ -1085,7 +1085,7 @@ bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr, u64 size)
{
kvm_pte_t attr_old = 0;
stage2_update_leaf_attrs(pgt, addr, size, 0, 0, &attr_old, NULL, 0);
- return attr_old & KVM_PTE_LEAF_ATTR_LO_S2_AF;
+ return kvm_pte_young(attr_old);
}
int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
@@ -1607,17 +1607,15 @@ bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
{
u64 size = (range->end - range->start) << PAGE_SHIFT;
- kvm_pte_t kpte;
- pte_t pte;
+ kvm_pte_t pte;
if (!kvm->arch.mmu.pgt)
return false;
- kpte = kvm_pgtable_stage2_mkold(kvm->arch.mmu.pgt,
- range->start << PAGE_SHIFT,
- size);
- pte = __pte(kpte);
- return pte_young(pte);
+ pte = kvm_pgtable_stage2_mkold(kvm->arch.mmu.pgt,
+ range->start << PAGE_SHIFT,
+ size);
+ return kvm_pte_young(pte);
}
bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
There's no real need for indirection through the kernel's PTE types here. Add a new helper to test if the access flag is set on a PTE and use it to roll over kvm_age_gfn() to only using kvm_pte_t. No functional change intended. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> --- arch/arm64/include/asm/kvm_pgtable.h | 5 +++++ arch/arm64/kvm/hyp/pgtable.c | 2 +- arch/arm64/kvm/mmu.c | 12 +++++------- 3 files changed, 11 insertions(+), 8 deletions(-)