Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp245438pxb; Mon, 25 Oct 2021 07:31:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO6doxbyn2dJvXuOlv4KZesAr+7KB/JXOhLx+b40UX/KJE6JCPnhSUl2ZMGxknfUYmhGi5 X-Received: by 2002:a17:90b:4b46:: with SMTP id mi6mr36198729pjb.161.1635172283354; Mon, 25 Oct 2021 07:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635172283; cv=none; d=google.com; s=arc-20160816; b=IUBu8P+AwfSE7LzJ+D1dH9dv4FGECclJglWxa6OUYpvB9rRo0i6yR4QYfiuiUzWQK8 HKNKeUc47CpdBO+haxXicLehTTiqqW2rcDLKNVRbjPvnLqiggtfBrQKjk7AK1X6LBo5m 2+UJJoTnA+oouOp0qmuNYIFo8Bnl8Tf7pYGJsrSP5/FgWLQZUq3ijnAryPlDw9OnvCYE HzxSmM/YeW+VcdVJDqebCwjIaYH5UPPNl3IEVPJDgHFFp8AnjfogBfvNuJjGcFSgOw/5 mahkEbcKzU5EuBYG0EYX6ZUC/u3J6MKIrIqxx8YId1MRjrpEyAU20urwaRysWDt5QJ/2 Fd+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ldvB0XPe33TqQvODn/mAyWJW6RTodpHfwe2FHTdvAFU=; b=w+NP4a/EiLyRzbF+MtAY4J4mthhuDaIMHHsHoSMEzXJfjHMbL+ggWgVc90Ww7iKxAJ OmhcJuDgGZpJ2SX7KOebmi6NYJVfzrlSvG/htc+XXZTxltGiNBRNT5uKkBIFW/YnmzJY VuF+YK3u0Swh2imR9XNZ9hH+Ycwnu3r7MZedqaL4REGPwATEreIK8HtSqQuI2OfHKfgs u5XrbPPxF9ci6NUI/cXWqPigleSg8vqefUaOAA1rWIYfc7txONw+I85s5V3W0xBSQbQ3 G9XzSE94L83WrwaKmfGyZWfooq/eIE4GHzCv4mPNpT6l7emwljzAL8MbJqUHQT5sAeo9 6PBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kfy54JnO; 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 q12si31024337plx.447.2021.10.25.07.30.57; Mon, 25 Oct 2021 07:31:23 -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=Kfy54JnO; 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 S232823AbhJYN4Q (ORCPT + 99 others); Mon, 25 Oct 2021 09:56:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25799 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbhJYN4M (ORCPT ); Mon, 25 Oct 2021 09:56:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635170030; 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=ldvB0XPe33TqQvODn/mAyWJW6RTodpHfwe2FHTdvAFU=; b=Kfy54JnOU/X7L7cHbwLRp/YMguFIjY+y3341pwufxofzg84Ya0uFzwRJDneWAezBdYOc/5 brt287vS30vUe+0ZujR94Telpo/wguR2vfZM+dlFYesYjyzfzsYV3nU08l8CaZTouYMH1Z LfIwKu21sWZPmvTGuWJNx1miu8O3Mq0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-ig91dNtYNYuEAJTElCJsJw-1; Mon, 25 Oct 2021 09:53:48 -0400 X-MC-Unique: ig91dNtYNYuEAJTElCJsJw-1 Received: by mail-wm1-f72.google.com with SMTP id s3-20020a1ca903000000b0032326edebe1so3548357wme.2 for ; Mon, 25 Oct 2021 06:53:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=ldvB0XPe33TqQvODn/mAyWJW6RTodpHfwe2FHTdvAFU=; b=2KYkb0AiNgmCND09W6D9RXXBodCvYVbaMmlOBo2s1QH4C8DpktagwU44bZSTeKccyU PHV4b/H55LycQOGCKfNXF1tXyk/DjqfeX3IFmXjV0XkyPOLde56pX386sXJPlRQNXmIu AthLZ4swvMAG6f8tocsYbVpYrSFp5uOkCBQnNtokS7V/Pog7/QIEiCZvFMhm/Hj9uMte aL0t49GkcqbeId5xLctT3z0czMyNDMIXMvFEMBeE663ORHvUrt4TRFTaX9TnMwVQsKQa URHtgzCfY7BJ/DfUUfFNgFBDkoCU83Ruwo4M18QXCsQUyCAH0q268N/zwxq8N3PUP44P ABbQ== X-Gm-Message-State: AOAM533vJ+LH+iDrNtLp5MQ+0KnuduiKGXLXPTEI9tvBD/fT0DdIU+AY Coh6yloCULJoRCBw5jiAzZKfW58Z+OdjWFnnsGl+dXAaOxTuSNtgCmczkTfhUxcYJM2IqfOuGmJ PfEVETtdYUZ4x4AbISWVup4Vg X-Received: by 2002:a5d:4a0a:: with SMTP id m10mr23195989wrq.8.1635170027185; Mon, 25 Oct 2021 06:53:47 -0700 (PDT) X-Received: by 2002:a5d:4a0a:: with SMTP id m10mr23195965wrq.8.1635170026960; Mon, 25 Oct 2021 06:53:46 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id l20sm21932937wmq.42.2021.10.25.06.53.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Oct 2021 06:53:46 -0700 (PDT) Message-ID: Date: Mon, 25 Oct 2021 15:53:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v2 22/43] KVM: VMX: Drop unnecessary PI logic to handle impossible conditions Content-Language: en-US To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank 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 References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-23-seanjc@google.com> From: Paolo Bonzini In-Reply-To: <20211009021236.4122790-23-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/21 04:12, 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(-) The idea here is to avoid making things worse by not making the list inconsistent. But that's impossible to do if pre_pcpu goes away, so fair enough. Paolo > 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"); >