Re: [PATCH v3 17/62] KVM: SVM: Add enable_ipiv param, never set IsRunning if disabled

Naveen N Rao
2025-06-19T12:05:12Z

On Thu, Jun 19, 2025 at 05:01:30PM +0530, Naveen N Rao wrote:
> On Wed, Jun 11, 2025 at 03:45:20PM -0700, Sean Christopherson wrote:
> > @@ -1030,7 +1047,7 @@ void avic_vcpu_put(struct kvm_vcpu *vcpu)
> > * can't be scheduled out and thus avic_vcpu_{put,load}() can't run
> > * recursively.
> > */
> > - entry = READ_ONCE(kvm_svm->avic_physical_id_table[vcpu->vcpu_id]);
> > + entry = svm->avic_physical_id_entry;
> >
> > /* Nothing to do if IsRunning == '0' due to vCPU blocking. */
> > if (!(entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK))
> > @@ -1049,7 +1066,10 @@ void avic_vcpu_put(struct kvm_vcpu *vcpu)
> > avic_update_iommu_vcpu_affinity(vcpu, -1, 0);
> >
> > entry &= ~AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK;
> > - WRITE_ONCE(kvm_svm->avic_physical_id_table[vcpu->vcpu_id], entry);
> > + svm->avic_physical_id_entry = entry;
> > +
> > + if (enable_ipiv)
> > + WRITE_ONCE(kvm_svm->avic_physical_id_table[vcpu->vcpu_id], entry);
>
> If enable_ipiv is false, then isRunning bit will never be set and we
> would have bailed out earlier. So, the check for enable_ipiv can be
> dropped here (or converted into an assert).

Ignore this, I got this wrong, sorry. The earlier check is against the
local copy of the physical ID table entry, which will indeed have
isRunning set so this is all good.

- Naveen