Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1653264pxb; Thu, 28 Oct 2021 07:40:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyuhy0eFMElCjZEGZZq5p6aQ0XEv+8FbTnI7+nLbOyFtAQWW1BWhzMtfMAZoi7Q6Cjsk6b X-Received: by 2002:a50:e108:: with SMTP id h8mr6631139edl.42.1635432018645; Thu, 28 Oct 2021 07:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635432018; cv=none; d=google.com; s=arc-20160816; b=t5NBntA+GzGpJRdxcULvfWInKRuWuzPsT52wo/nip1KzmtGFQn77aoLnrXMi/GCG5j nLXdfMPYyoTipgZMrERB8OqGK0HHU2ukARe4Bds1xcGLukS5x6+NHKGP5E7Vw0CBjrGT GHxtxaD5a6gi1FiOiWejGiKnt6fNPHB5UjanyXGmdV8OIiFgBr2KlbI9fggZQAEFGHmy RvMp4PqD8UqYsrfFSLtNWaNXopoi2B6/AyCPUblshGztL4uB6IhmdhDF/WQno4MtSG9N j1yRPuWlYMsPrdKTH1eOV+mN2ADRzPNeDGXkc67gNRU92l/vjefEdoyBds3wtr84Tlry n8ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=rIPy/P0MkwnX24RiVT8XHV56FyrWxedIt/Yy+pyq4E4=; b=Xu8fk9ALKvSnVdJ1k8A7ylJW8CzdUu+upRp4RvtMxekh/ol2RLrm6gSXKzpGhQEAaq sfUzXfXiywR2KUE1OR7yItibt8+UZxv0hlqCp+KDISOEdJWeGNpX0/4BHGV61Axbv/ZE 7Z6gKpCmMaA6AHNjvfcnOd8p4qZLEsJcbj3nVgQD6Y54Oga/kplnfjuKaMJhAFczyPq6 f9lhRBZ6tQ+81Ip4xUnnziuZQeKY5CjR8XIfqgI11DY4cETt4oxfzdF3029lOs/trK/2 JBXZc6OD6EzALNF5bV+fboRmhWHJl9uJi3ZIUqCsd+t20j+h30rhyPEdctoAm1zXp3yz y5/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SMD62PWb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si5431367edk.367.2021.10.28.07.39.53; Thu, 28 Oct 2021 07:40:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SMD62PWb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbhJ1Oiy (ORCPT + 99 others); Thu, 28 Oct 2021 10:38:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26932 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhJ1Oix (ORCPT ); Thu, 28 Oct 2021 10:38:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635431785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rIPy/P0MkwnX24RiVT8XHV56FyrWxedIt/Yy+pyq4E4=; b=SMD62PWblhhSX3tgimyLNIpB0WRIOMAOHYQsaYHKx4YxY6WRgW7MgaKl5K04QM3eB+BQbI k0iJmCkaKISRTbcw8khw3rq68sCs6If63Np0xpG5MhsvBTCWPutOgwQy+2Axy1UPAQeGQd 42ItOmFYMlP3kboAvnX4I921aL9wImc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-LuCRe9MpMnC4avaZ8uFX4w-1; Thu, 28 Oct 2021 10:36:24 -0400 X-MC-Unique: LuCRe9MpMnC4avaZ8uFX4w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE73C10A8E01; Thu, 28 Oct 2021 14:36:19 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18EDF100EA05; Thu, 28 Oct 2021 14:36:03 +0000 (UTC) Message-ID: <33860db1f4951386347913d126ef7c8bc1655440.camel@redhat.com> Subject: Re: [PATCH v2 22/43] KVM: VMX: Drop unnecessary PI logic to handle impossible conditions From: Maxim Levitsky To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: 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 Date: Thu, 28 Oct 2021 17:36:02 +0300 In-Reply-To: <20211009021236.4122790-23-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-23-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > Drop sanity checks on the validity of the previous pCPU when handling > vCPU block/unlock for posted interrupts. Barring a code bug or memory > corruption, the sanity checks will never fire, and any code bug that does > trip the WARN is all but guaranteed to completely break posted interrupts, > i.e. should never get anywhere near production. > > This is the first of several steps toward eliminating kvm_vcpu.pre_cpu. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/posted_intr.c | 24 ++++++++++-------------- > 1 file changed, 10 insertions(+), 14 deletions(-) > > diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c > index 67cbe6ab8f66..6c2110d91b06 100644 > --- a/arch/x86/kvm/vmx/posted_intr.c > +++ b/arch/x86/kvm/vmx/posted_intr.c > @@ -118,12 +118,10 @@ static void __pi_post_block(struct kvm_vcpu *vcpu) > } while (cmpxchg64(&pi_desc->control, old.control, > new.control) != old.control); > > - if (!WARN_ON_ONCE(vcpu->pre_pcpu == -1)) { > - spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > - list_del(&vcpu->blocked_vcpu_list); > - spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > - vcpu->pre_pcpu = -1; > - } > + spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > + list_del(&vcpu->blocked_vcpu_list); > + spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > + vcpu->pre_pcpu = -1; > } > > /* > @@ -153,14 +151,12 @@ int pi_pre_block(struct kvm_vcpu *vcpu) > > WARN_ON(irqs_disabled()); > local_irq_disable(); > - if (!WARN_ON_ONCE(vcpu->pre_pcpu != -1)) { > - vcpu->pre_pcpu = vcpu->cpu; > - spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > - list_add_tail(&vcpu->blocked_vcpu_list, > - &per_cpu(blocked_vcpu_on_cpu, > - vcpu->pre_pcpu)); > - spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > - } > + > + vcpu->pre_pcpu = vcpu->cpu; > + spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > + list_add_tail(&vcpu->blocked_vcpu_list, > + &per_cpu(blocked_vcpu_on_cpu, vcpu->pre_pcpu)); > + spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > > WARN(pi_desc->sn == 1, > "Posted Interrupt Suppress Notification set before blocking"); Reviewed-by: Maxim Levitsky