KVM: arm64: Fix propagation of TLBI level in kvm_pgtable_stage2_relax_perms()
Marc Zyngier
maintainerPATCH 1/1 KVM: arm64: Fix propagation of TLBI level in kvm_pgtable_stage2_relax_perms()
Assigning the invalidation level (an s8 value) with TLBI_TTL_UNKNOWN (a 32bit signed value) is not ideal, to say the least. Instead of this, only pass TLBI_TTL_UNKNOWN to __kvm_tlb_flush_vmid_ipa_nsh() when we know for sure that we don't have a provided level.
Fixes 100baf0184896 ("KVM: arm64: Ensure level is always initialized when relaxing perms")
Reported-by Mark Brown <[email protected]>
Reviewed-by Oliver Upton <[email protected]>
Signed-off-by Marc Zyngier <[email protected]>
--- arch/arm64/kvm/hyp/pgtable.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/pgtable.c +3 -2
@@ -1356,7 +1356,7 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, enum kvm_pgtable_prot prot, enum kvm_pgtable_walk_flags flags) { kvm_pte_t xn = 0, set = 0, clr = 0; -s8 level =TLBI_TTL_UNKNOWN ; +s8 level;int ret;if (prot &KVM_PTE_LEAF_ATTR_HI_SW )
@@ -1379,7 +1379,8 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, ret =stage2_update_leaf_attrs (pgt, addr,1 , set, clr,NULL , &level, flags);if (!ret || ret == -EAGAIN ) -kvm_call_hyp (__kvm_tlb_flush_vmid_ipa_nsh, pgt->mmu, addr, level); +kvm_call_hyp (__kvm_tlb_flush_vmid_ipa_nsh, pgt->mmu, addr, + (ret == -EAGAIN ) ?TLBI_TTL_UNKNOWN : level);return ret; }
Signature · 1 line
2.47.3
Quoted 6 lines · Marc Zyngier
Assigning the invalidation level (an s8 value) with
TLBI_TTL_UNKNOWN(a 32bit signed value) is not ideal, to say the least. Instead of this, only passTLBI_TTL_UNKNOWNto__kvm_tlb_flush_vmid_ipa_nsh()when we know for sure that we don't have a provided level.
Applied to fixes, thanks!
[1/1] KVM: arm64: Fix propagation of TLBI level in kvm_pgtable_stage2_relax_perms()
commit: 8d187d4b33c262c0f3e44842553521151d8629e8
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.