Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2918880pxb; Fri, 8 Oct 2021 19:16:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ0ANsDVFs9itpLE3pL9QbZmfGq4tQnlKvMPuuArFIhK8weXlu+46wVlaxDdZA9T/hNbA9 X-Received: by 2002:a05:6402:11cb:: with SMTP id j11mr8144020edw.124.1633745813945; Fri, 08 Oct 2021 19:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633745813; cv=none; d=google.com; s=arc-20160816; b=illX9btVL47MqbeBTBzEeWXt0I3Sw5urM8UbFfF1c7aIqBX4kbiNNIAHKG91nT+WBo If46fyYDhbqqYsLG7vV1Qnb4y2nDIpwQYdq62xkLVw8h+KIlkBwLsFkE1QGJSva4Ut48 68jOyA8l7o3ZKibRoT10l3Z+uy9Rt0E9YrPypQiqiYwuep3zGdV7oXZ5sKWXNdzFHIsR F5zdCWcWMqDFCWAYInezHVVpK1OnjoNSyajTwMjKYW28MiKUce1T9pBwUTfy49vkjYxn PdJJPW0qY6aMgZUELmRCW/LppiVwFJQKPVP2Ej54vusN/FtDNQ77zk60DmZWhXJpZmPK O4Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=SdOYPzkyfZrBWx1GJeur2Vwb7zEvl7JYNbVbQ0SB2Gg=; b=AH0wRBzq88g0ryIotU77F1Klr26Irwc9LK+M4l9Nw8uL6sEjKn4V+gpdqIK5BIwXPy poIWP1QX+Qwfm+Y6n139WO02IcFWYvv/nyBy+ENivbBtnYQ82BWBgmrI4QtoGdG7RsPf jAqS/3u1lUjUBa/lOQoAj3FKNsgc3UluA7UAfS161YN0ox/ZFg9XBAQ+uWb4wsT7ULgw uP4R4ZLwBQZdz0Zj9xDmOWulw+f1S4RUsUL28Cl5ClO14WUElhsBv33CSJozevcAdkYC OSBzRuk1/kIbXvmrwqpwqCiTptNv83AgIvewscN6BFuFduMN6xutUvtNFkl0xcsyzpxA mQyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="aUvGN/4A"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si1357428edt.280.2021.10.08.19.16.30; Fri, 08 Oct 2021 19:16:53 -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=@google.com header.s=20210112 header.b="aUvGN/4A"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244435AbhJICQm (ORCPT + 99 others); Fri, 8 Oct 2021 22:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244511AbhJICQO (ORCPT ); Fri, 8 Oct 2021 22:16:14 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2B8CC0617A9 for ; Fri, 8 Oct 2021 19:13:36 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id v203-20020a25c5d4000000b005bb21580411so2358565ybe.19 for ; Fri, 08 Oct 2021 19:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=SdOYPzkyfZrBWx1GJeur2Vwb7zEvl7JYNbVbQ0SB2Gg=; b=aUvGN/4AFgJcKIBF9LBWgDwhCHQZYEJ03JrconxIXHeAq0mSobvx5eFsN2IhEk7hMF 07jWDFM9e+ezgnVy0PqTHsU8wjkF0Sq/uHjyc0w84aIFVqAcJRuuc8LQH3WxNpDQiA8J 1gOwXo6k1Mjhlm2dzNYz4rr2omGOTIv9FMsD0TA3lqfU/1iEz7W8Tub84Aqukc87X1xM piXJImDfP3oyBzKVi6TuZiCoM21cARPSFti7XJOcRw2PuPbisGedjpLV+YL9vQi2purC N3om2H5mKJxeus7ZcbgIF+EPMNOHqwS7dYW8kbDAw9PWlIpsbYSk0g7cYENwS5oOjCiw mX3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=SdOYPzkyfZrBWx1GJeur2Vwb7zEvl7JYNbVbQ0SB2Gg=; b=t0xUsmzC3U1SgRIFyrBD5pWW6X8NgH1W3n6EbMxfK1dtMjeYXtIVR7n0y/sqP2VtnO /hYjpDnAmFj5cJP2dR9ch//u+77Kqa0NFsrArL5qxWihlxvywwhtSGMLZNOk9r0Lgj8K MUnN02XV84uWYGPVNVrlWXb3dcfNfHK5gVD4uUUxtpscxQ9aDmm8uEADtv4dOxJ49z2p i9xnp2YWgLRGVoKfbq60Dr1fu/Qu9AE8kSvG0Y2nDtxYLXhFObGWdI3nW5EJmmDeYwCF WQ1eaCXO1LKG8NuBFSfgvkrqtAFePYuvvRBfRBlxHc83cO84GfETDmYVqKbGxWfS7Wq6 Uu7w== X-Gm-Message-State: AOAM532Zw/iDduXDTD0HFV/4eTI+LvVafYaINHWIWxGsKZl1otnn5Y6m qT9ACiziHnGd3G5PWT4WcwFSzfhsNds= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:e39b:6333:b001:cb]) (user=seanjc job=sendgmr) by 2002:a25:6e06:: with SMTP id j6mr7636609ybc.311.1633745615988; Fri, 08 Oct 2021 19:13:35 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 8 Oct 2021 19:12:15 -0700 In-Reply-To: <20211009021236.4122790-1-seanjc@google.com> Message-Id: <20211009021236.4122790-23-seanjc@google.com> Mime-Version: 1.0 References: <20211009021236.4122790-1-seanjc@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v2 22/43] KVM: VMX: Drop unnecessary PI logic to handle impossible conditions From: Sean Christopherson To: 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 , Sean Christopherson , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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"); -- 2.33.0.882.g93a45727a2-goog