[PATCH v5 05/69] KVM: arm64: Allow preservation of the S2 SW bits
Marc Zyngier
maz at kernel.org
Mon Nov 29 12:00:46 PST 2021
The S2 page table code has a limited use the SW bits, but we are about
to need them to encode some guest Stage-2 information (its mapping size
in the form of the TTL encoding).
Propagate the SW bits specified by the caller, and store them into
the corresponding entry.
Signed-off-by: Marc Zyngier <maz at kernel.org>
---
arch/arm64/kvm/hyp/pgtable.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 8cdbc43fa651..d69e400b2de6 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -1064,9 +1064,6 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
u32 level;
kvm_pte_t set = 0, clr = 0;
- if (prot & KVM_PTE_LEAF_ATTR_HI_SW)
- return -EINVAL;
-
if (prot & KVM_PGTABLE_PROT_R)
set |= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R;
@@ -1076,6 +1073,10 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
if (prot & KVM_PGTABLE_PROT_X)
clr |= KVM_PTE_LEAF_ATTR_HI_S2_XN;
+ /* Always propagate the SW bits */
+ clr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_SW, 0xf);
+ set |= prot & KVM_PTE_LEAF_ATTR_HI_SW;
+
ret = stage2_update_leaf_attrs(pgt, addr, 1, set, clr, NULL, &level);
if (!ret)
kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, pgt->mmu, addr, level);
--
2.30.2
More information about the linux-arm-kernel
mailing list