Re: [PATCH 5/6] KVM: arm64: Couple VNCR fixmap clearing and CPU number invalidation
Yao Yuan <[email protected]> Tue, 4 Aug 2026 11:34:24 +0800
| Newsgroups | dev.linux.lists.kvmarm,org.infradead.lists.linux-arm-kernel,org.kernel.vger.kvm |
|---|---|
| Message-ID | <wlcvwmmsu3ryj3zytcnx5xhmuhjbgofqsaw5o54qwbdwc3n7ca@wj5n4swgeokb> |
On Sat, Aug 01, 2026 at 01:48:17PM +0800, Marc Zyngier wrote: > 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); Reviewed-by: Yuan Yao <[email protected]> > } > > static bool vncr_tlb_intersects(struct vncr_tlb *vt, u64 addr, > -- > 2.47.3 >