Re: [PATCH v3 11/19] RISC-V: KVM: Implement VMID allocator

From: Anup Patel
Date: Mon Aug 05 2019 - 23:19:40 EST


On Mon, Aug 5, 2019 at 9:33 PM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> On 05/08/19 15:43, Anup Patel wrote:
> > + spin_lock(&vmid_lock);
> > +
> > + /*
> > + * We need to re-check the vmid_version here to ensure that if
> > + * another vcpu already allocated a valid vmid for this vm.
> > + */
> > + if (!kvm_riscv_stage2_vmid_ver_changed(vmid)) {
> > + spin_unlock(&vmid_lock);
> > + return;
> > + }
> > +
> > + /* First user of a new VMID version? */
> > + if (unlikely(vmid_next == 0)) {
> > + WRITE_ONCE(vmid_version, READ_ONCE(vmid_version) + 1);
> > + vmid_next = 1;
> > +
> > + /*
> > + * On SMP, we know no other CPUs can use this CPU's or
> > + * each other's VMID after forced exit returns since the
> > + * vmid_lock blocks them from re-entry to the guest.
> > + */
> > + spin_unlock(&vmid_lock);
> > + kvm_flush_remote_tlbs(vcpu->kvm);
> > + spin_lock(&vmid_lock);
>
> This comment is not true anymore, so this "if" should become a "while".

Sure, I will update in v4.

Regards,
Anup