[PATCH 5/6] KVM: arm64: Couple VNCR fixmap clearing and CPU number invalidation

Yao Yuan yaoyuan at linux.alibaba.com
Mon Aug 3 20:34:24 PDT 2026


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 <maz at kernel.org>
> ---
>  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 <yaoyuan at linux.alibaba.com>

>  }
>
>  static bool vncr_tlb_intersects(struct vncr_tlb *vt, u64 addr,
> --
> 2.47.3
>



More information about the linux-arm-kernel mailing list