Re: [PATCH v2 01/29] LoongArch: KVM: Add kvm related header files

From: Paolo Bonzini
Date: Tue Feb 21 2023 - 01:50:58 EST


On 2/21/23 03:56, Tianrui Zhao wrote:

In _kvm_check_vmid(), you already have

+    if (migrated || (ver != old)) {
+        _kvm_update_vpid(vcpu, cpu);
+        trace_kvm_vpid_change(vcpu, vcpu->arch.vpid[cpu]);
+    }

so a vpid will never be recycled if a vCPU migrates from physical CPU A to B and back to A.

So please keep the current VPID in the per-cpu struct vmcs, and you can just copy it from there in _kvm_check_vmid().

Thanks,  that is to say we should remove the vpid[NR_CPUS] array and it is enough to use only one vpid variable?

Yes, you need a vpid variable here and one in struct kvm_context.

Paolo