]> xenbits.xensource.com Git - people/pauldu/linux.git/commitdiff
KVM: arm64: Use vcpu_idx for invalidation tracking
authorMarc Zyngier <maz@kernel.org>
Wed, 27 Sep 2023 09:09:06 +0000 (10:09 +0100)
committerOliver Upton <oliver.upton@linux.dev>
Sat, 30 Sep 2023 18:15:43 +0000 (18:15 +0000)
While vcpu_id isn't necessarily a bad choice as an identifier for
the currently running vcpu, it is provided by userspace, and there
is close to no guarantee that it would be unique.

Switch it to vcpu_idx instead, for which we have much stronger
guarantees.

Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230927090911.3355209-7-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/arm.c

index fa21fb15e92775c6ca5db72c77c7027117f41094..9379a122750179da7f19b3bd3dcf7c5f2cf79b4f 100644 (file)
@@ -438,9 +438,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
         * We might get preempted before the vCPU actually runs, but
         * over-invalidation doesn't affect correctness.
         */
-       if (*last_ran != vcpu->vcpu_id) {
+       if (*last_ran != vcpu->vcpu_idx) {
                kvm_call_hyp(__kvm_flush_cpu_context, mmu);
-               *last_ran = vcpu->vcpu_id;
+               *last_ran = vcpu->vcpu_idx;
        }
 
        vcpu->cpu = cpu;