diff mbox series

[2/5] KVM: arm64: Add a mask for all leaf PTE attributes

Message ID 20230111000300.2034799-3-oliver.upton@linux.dev (mailing list archive)
State New, archived
Headers show
Series KVM: arm64: Handle unaligned memslots in kvm_(test_)_age_gfn() | expand

Commit Message

Oliver Upton Jan. 11, 2023, 12:02 a.m. UTC
No functional change intended.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
 arch/arm64/include/asm/kvm_pgtable.h | 3 +++
 arch/arm64/kvm/hyp/pgtable.c         | 7 +++----
 2 files changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h
index 8071698cc680..f8f6b4d2735a 100644
--- a/arch/arm64/include/asm/kvm_pgtable.h
+++ b/arch/arm64/include/asm/kvm_pgtable.h
@@ -73,6 +73,9 @@  typedef u64 kvm_pte_t;
 					 KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \
 					 KVM_PTE_LEAF_ATTR_HI_S2_XN)
 
+#define KVM_PTE_LEAF_ATTRS		(KVM_PTE_LEAF_ATTR_LO | \
+					 KVM_PTE_LEAF_ATTR_HI)
+
 #define KVM_PTE_ADDR_MASK		GENMASK(47, PAGE_SHIFT)
 #define KVM_PTE_ADDR_51_48		GENMASK(15, 12)
 
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 3efe3aca3cb9..26f61462527d 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -111,7 +111,7 @@  static kvm_pte_t kvm_init_valid_leaf_pte(u64 pa, kvm_pte_t attr, u32 level)
 	u64 type = (level == KVM_PGTABLE_MAX_LEVELS - 1) ? KVM_PTE_TYPE_PAGE :
 							   KVM_PTE_TYPE_BLOCK;
 
-	pte |= attr & (KVM_PTE_LEAF_ATTR_LO | KVM_PTE_LEAF_ATTR_HI);
+	pte |= attr & KVM_PTE_LEAF_ATTRS;
 	pte |= FIELD_PREP(KVM_PTE_TYPE, type);
 	pte |= KVM_PTE_VALID;
 
@@ -1027,10 +1027,9 @@  static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr,
 				    u32 *level, enum kvm_pgtable_walk_flags flags)
 {
 	int ret;
-	kvm_pte_t attr_mask = KVM_PTE_LEAF_ATTR_LO | KVM_PTE_LEAF_ATTR_HI;
 	struct stage2_attr_data data = {
-		.attr_set	= attr_set & attr_mask,
-		.attr_clr	= attr_clr & attr_mask,
+		.attr_set	= attr_set & KVM_PTE_LEAF_ATTRS,
+		.attr_clr	= attr_clr & KVM_PTE_LEAF_ATTRS,
 	};
 	struct kvm_pgtable_walker walker = {
 		.cb		= stage2_attr_walker,