From: Oliver Upton <oliver.upton@linux.dev>
To: Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
Quentin Perret <qperret@google.com>,
Will Deacon <will@kernel.org>, Reiji Watanabe <reijiw@google.com>,
Oliver Upton <oliver.upton@linux.dev>
Subject: [PATCH 5/5] KVM: arm64: Consistently use KVM's types/helpers in kvm_age_gfn()
Date: Wed, 11 Jan 2023 00:03:00 +0000 [thread overview]
Message-ID: <20230111000300.2034799-6-oliver.upton@linux.dev> (raw)
In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev>
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(-)
diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h
index 81e04a24cc76..a81cd1ea64cb 100644
--- a/arch/arm64/include/asm/kvm_pgtable.h
+++ b/arch/arm64/include/asm/kvm_pgtable.h
@@ -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;
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 791f7e81671e..19f5094dfd93 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -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,
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 0b8e2a57f81a..3297475dcfcc 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -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)
--
2.39.0.314.g84b9a713c41-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2023-01-11 0:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 0:02 [PATCH 0/5] KVM: arm64: Handle unaligned memslots in kvm_(test_)_age_gfn() Oliver Upton
2023-01-11 0:02 ` [PATCH 1/5] KVM: arm64: Hoist S2 PTE definitions into kvm_pgtable.h Oliver Upton
2023-01-11 0:02 ` [PATCH 2/5] KVM: arm64: Add a mask for all leaf PTE attributes Oliver Upton
2023-01-11 0:02 ` [PATCH 3/5] KVM: arm64: Only return attributes from stage2_update_leaf_attrs() Oliver Upton
2023-01-11 8:52 ` Marc Zyngier
2023-01-11 17:21 ` Oliver Upton
2023-02-02 22:08 ` Oliver Upton
2023-02-07 14:56 ` Marc Zyngier
2023-01-11 0:02 ` [PATCH 4/5] KVM: arm64: Correctly handle page aging notifiers for unaligned memlsot Oliver Upton
2023-01-12 15:44 ` Marc Zyngier
2023-01-11 0:03 ` Oliver Upton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230111000300.2034799-6-oliver.upton@linux.dev \
--to=oliver.upton@linux.dev \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=qperret@google.com \
--cc=reijiw@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).