Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B43C6C433EF for ; Mon, 29 Nov 2021 22:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbhK2W4T (ORCPT ); Mon, 29 Nov 2021 17:56:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235368AbhK2Wza (ORCPT ); Mon, 29 Nov 2021 17:55:30 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6395EC1EB41C for ; Mon, 29 Nov 2021 10:55:19 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id z6so12931268plk.6 for ; Mon, 29 Nov 2021 10:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TYbgQqCpCmOsVo/Ud6S4W0dWbGKnEHCC/sbfSrxRU2Q=; b=V9NdrM9IGQ8TORtVAjZzUck1RI7UtY24/5ryhbIDx46VwTLIEKKddxeNbMrV6TQpIl KTCIPozOyBw/wCgOEJPsKU3C9LENDNILuHldgqEm6W55x2AEOVy9zbC+oB0Q8kNXcib2 utENfqKkezcYzZnD0pmUAjWeJ/cGQai7wseSy0Tb7+ezAyGs24Tiec69FywheOS97WPw hiOKPwklIAtqAAVwW+TVa82nOI4oJHItJIs2sHILKArSIy33/Br5zlJSRUemG17TIymQ 2z90v41HGfafPsWOqjYsVFIk8gpVXUcAMJTfJevG+nopt2huTRvy9U+7v5siSDcfSs81 05ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TYbgQqCpCmOsVo/Ud6S4W0dWbGKnEHCC/sbfSrxRU2Q=; b=wIDImCQFMheH1VrUwIXN702nDTAL1cbPQz94VLoVQLhgdgAihPsK2s0irsVf5qQPNv RJBubtJg+pmSir18KqkeDBLIDL34U1qYYdHeEemN0kNs+KSYD8Kvj9xMUjGrf4zkJApF YRusR/67w6Fbxhi4GlFxjRPeWNAN+Xe/r+Xis3O2Pq2HhD3cX6L2/pAykiGYtZF0iBtx LwdEyil8VkiiSvSooQgZhsBYBflZeh4SSbGRPHCyNVbRQRGM+csfTPopsiOLev7q4xjS RSSbYQz7hpA80mIjTW28GjgAs3ICb9045RT9Or7Gn7ghlvZDVO0+RL80dpb7gwaqsAAf KVPg== X-Gm-Message-State: AOAM530LfWJygK2fgg8itEcLzeeeCpOPnJNo2fGeRAg1buqRSUfogX8t wgtklGjUgphia7WqjjJKZM7//g== X-Google-Smtp-Source: ABdhPJzGwlSa9NgpBenMt4CKt9Ftf4k4qsHL0lT0KjuZVEYivrfeFPAQn3AoVSiAs1eAB5ezweh9DQ== X-Received: by 2002:a17:90b:2251:: with SMTP id hk17mr189639pjb.31.1638212118683; Mon, 29 Nov 2021 10:55:18 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id d17sm17979027pfj.215.2021.11.29.10.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 10:55:18 -0800 (PST) Date: Mon, 29 Nov 2021 18:55:14 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: Maxim Levitsky , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , Oliver Upton , Jing Zhang Subject: Re: [PATCH v2 11/43] KVM: Don't block+unblock when halt-polling is successful Message-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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <496c2fc6-26b0-9b5d-32f4-2f9e9dd6a064@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 through the vIRR, > > but before avic_update_iommu_vcpu_affinity() is called, the posted interrupt will > > be set in the vIRR without triggering a host IRQ to wake the vCPU via the GA log. > > > > I.e. KVM is missing an equivalent to VMX's posted interrupt check for an outstanding > > notification after switching to the wakeup vector. > > BTW Maxim reported that it can break even without assigned devices. > > > For now, the least awful approach is sadly to keep the vcpu_(un)blocking() hooks. > > 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=true but > vcpu->mode == 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 explain why I don't see problems, I'm pretty sure I've only run AVIC with a PREEMPT=n. svm_vcpu_{un}blocking() are called with preemption enabled, and avic_set_running() passes in vcpu->cpu. If the vCPU is preempted and scheduled in on a different CPU, avic_vcpu_load() will overwrite the vCPU's entry with the wrong CPU info.