From: Sean Christopherson Date: Mon, 29 Nov 2021 18:55:14 +0000 Subject: Re: [PATCH v2 11/43] KVM: Don't block+unblock when halt-polling is successful Message-Id: List-Id: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-12-seanjc@google.com> <4e883728e3e5201a94eb46b56315afca5e95ad9c.camel@redhat.com> <496c2fc6-26b0-9b5d-32f4-2f9e9dd6a064@redhat.com> In-Reply-To: <496c2fc6-26b0-9b5d-32f4-2f9e9dd6a064@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Paolo Bonzini Cc: Cornelia Huck , Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, Paul Mackerras , Atish Patra , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , Maxim Levitsky , Christian Borntraeger , Aleksandar Markovic , Albert Ou , kvm-ppc@vger.kernel.org, Paul Walmsley , David Matlack , linux-arm-kernel@lists.infradead.org, Jim Mattson , Anup Patel , linux-mips@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Vitaly Kuznetsov On Mon, Nov 29, 2021, Paolo Bonzini wrote: > On 11/29/21 18:25, Sean Christopherson wrote: > > If a posted interrupt arrives after KVM has done its final search throu= gh the vIRR, > > but before avic_update_iommu_vcpu_affinity() is called, the posted inte= rrupt will > > be set in the vIRR without triggering a host IRQ to wake the vCPU via t= he GA log. > >=20 > > I.e. KVM is missing an equivalent to VMX's posted interrupt check for a= n outstanding > > notification after switching to the wakeup vector. >=20 > BTW Maxim reported that it can break even without assigned devices. >=20 > > For now, the least awful approach is sadly to keep the vcpu_(un)blockin= g() hooks. >=20 > I agree that the hooks cannot be dropped but the bug is reproducible with > this patch, where the hooks are still there. ... > Still it does seem to be a race that happens when IS_RUNNING=3Dtrue but > vcpu->mode =3D OUTSIDE_GUEST_MODE. This patch makes the race easier to > trigger because it moves IS_RUNNING=FAlse later. Oh! Any chance the bug only repros with preemption enabled? That would ex= plain why I don't see problems, I'm pretty sure I've only run AVIC with a PREEMPT= =3Dn. svm_vcpu_{un}blocking() are called with preemption enabled, and avic_set_ru= nning() passes in vcpu->cpu. If the vCPU is preempted and scheduled in on a differ= ent CPU, avic_vcpu_load() will overwrite the vCPU's entry with the wrong CPU info.