[PATCH 5/6] KVM: arm64: Couple VNCR fixmap clearing and CPU number invalidation
Marc Zyngier <[email protected]> Sat, 1 Aug 2026 13:48:17 +0100
| Newsgroups | dev.linux.lists.kvmarm,org.infradead.lists.linux-arm-kernel,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
A mapped VNCR translation must indicate which CPU it is resident. Unmapping such a translation must make this CPU number -1. Couple the unmap and the setting to -1 in a helper, so that we are always sure they are done together. Signed-off-by: Marc Zyngier <[email protected]> --- arch/arm64/kvm/nested.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c index 47d61d3cf053c..84915e2cff604 100644 --- a/arch/arm64/kvm/nested.c +++ b/arch/arm64/kvm/nested.c @@ -894,6 +894,12 @@ void kvm_vcpu_load_hw_mmu(struct kvm_vcpu *vcpu) } } +static void unmap_l1_vncr(struct vncr_tlb *vt) +{ + clear_fixmap(vncr_fixmap(vt->cpu)); + vt->cpu = -1; +} + static void this_cpu_reset_vncr_fixmap(struct kvm_vcpu *vcpu) { if (!host_data_test_flag(L1_VNCR_MAPPED)) @@ -902,8 +908,7 @@ static void this_cpu_reset_vncr_fixmap(struct kvm_vcpu *vcpu) BUG_ON(vcpu->arch.vncr_tlb->cpu != smp_processor_id()); BUG_ON(is_hyp_ctxt(vcpu)); - clear_fixmap(vncr_fixmap(vcpu->arch.vncr_tlb->cpu)); - vcpu->arch.vncr_tlb->cpu = -1; + unmap_l1_vncr(vcpu->arch.vncr_tlb); host_data_clear_flag(L1_VNCR_MAPPED); } @@ -996,7 +1001,7 @@ static void invalidate_vncr(struct vncr_tlb *vt) { vt->valid = false; if (vt->cpu != -1) - clear_fixmap(vncr_fixmap(vt->cpu)); + unmap_l1_vncr(vt); } static bool vncr_tlb_intersects(struct vncr_tlb *vt, u64 addr, -- 2.47.3