Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2919779pxb; Fri, 8 Oct 2021 19:18:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh1G1Clcd45l0F+ABAOmeqZQOuL/MNQHM0Usn6OSmC7YxyX9M41vnxR5p5AFZb38JQH4f0 X-Received: by 2002:a17:906:3157:: with SMTP id e23mr9140143eje.29.1633745925660; Fri, 08 Oct 2021 19:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633745925; cv=none; d=google.com; s=arc-20160816; b=XPVXjtXWtuYWCgxKh4NjRICI/Lp+0ms1tu5griJx077m3Nozkqt7VC6I10KwbbSyfE GU+wkOcGGD6hXkXwakpAGGcSXjfvpLK0X1w3/1p0KA0jiUdg3fs/T6GsMeLHAW0zmBSj QZ9leWjg1Rwt8yE5EGmLhcYeFBC8CR1RdgKnS6MFKZ/SS3MGVNB1E9pfrJfmLA459dL2 ttCV9/VsEWjde6gxvigiygD/P0nP95O1dkK9vpJB3+8zXEe6+OSJLjwGaJejeVcv1kjZ N4Cr/56epsXCIXqpqkxncluCfEjWD1+exsRxI3ySByziCBBtsccnmqd0AuCMvZ7ow7q4 0aGA== 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=pLGnZNeCj1eofs1Tna8HvgfHGGH+OqNXhSkcDhwkBIw=; b=INX5zQZa+U3SPjzMl204D89C4/73/771gQZAeIk8BSocqToL7ePlHrxrPk2jEMHafM emFQnuraiK2Ere28kpBv2QNaaxOiHdBzqPzDKMTFooDa05Fp4VDYKf51uGHKNYFkDa8r 8AJ7PCsnWJxT2/9zwTzMmSluN/HmMoym0IOEVOWT1rbegUzZaNCs2sHEKY/dvWf+8k56 3+HYRDsb/nx3npd5WawfTV8rFZDF6AEYoLHFvkqpxwDswZXmejylxt6mAHpjk9RbBhZ8 nmZEOOYPilVkZLH7vnFqfgqq8vw8FlE6VSo7xGlGw2aZMyPPNGyd8jXeVtkBj1qHkJwU nZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VRo08TCu; 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 n2si1586098edi.385.2021.10.08.19.18.21; Fri, 08 Oct 2021 19:18:45 -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=VRo08TCu; 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 S244559AbhJICQa (ORCPT + 99 others); Fri, 8 Oct 2021 22:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244555AbhJICP6 (ORCPT ); Fri, 8 Oct 2021 22:15:58 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 830C5C06177A for ; Fri, 8 Oct 2021 19:13:34 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id q193-20020a252aca000000b005ba63482993so6521098ybq.0 for ; Fri, 08 Oct 2021 19:13:34 -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=pLGnZNeCj1eofs1Tna8HvgfHGGH+OqNXhSkcDhwkBIw=; b=VRo08TCu54WXCeWvaUHt/sk2e0vGE+t23O2jGFtKJrC8szlW29PyUVg9qa1gFeA7l/ xEskdCWXRSlglDPxzwJpI+hnS34D4TzLDKLZZJDH+vXneZUjJrJ2p6jMQ4+6yNusBF7P 6CJ8/rSwneH/NW0dEbzJkjR/ZnaiFW04wA6ydEJsYBVq9hwfsxkAk8UtewwAEpUXkOH2 gElF5Vx854/uDHSVGxe/9WkMnKTFMH6pK6EPC77dq53/WUYVeZkuMvVYcngIplHzpqzD mk15NWKmGwkAbgPYO3UA0b2d7qx8J738ZHLocYz+9s5CV0wLJv0e5T4wx+Q9y63P5xIW pwMQ== 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=pLGnZNeCj1eofs1Tna8HvgfHGGH+OqNXhSkcDhwkBIw=; b=PeJlI2wgVaqa1nVL0LydHWDuSdjDlukrBjgs617nWZUuGSos6YUmAFp1ropa/o0GWV 4ENDitK0LeAIEeiyGdP5gP+1n0GnxjsH6sr7FOs6TA3VMymq2n2RTFZ5vrprI5upxocZ HHGgFYxWdQZ5Zm/oIyYHwicvmWsoRyUT9ceuykcgvDeKE6ZXxhlvIan9F6aEn8O0wKBk pzOWAbP2PEj95pKw/hhRTrAupJc/1XL9gZ4SCcw3hGJYBSfosdPh/+EtAHMD3AUyXFrQ 4vRu30Ee2RPgJyTE02BskRhliUtoTDD085yQlR6TggjCOCO14az1jdnQjr1/n4fUxvaE Loug== X-Gm-Message-State: AOAM531rgvuIFREgMidgY1mjSYIZdGgKprhueaoSG+uQevCInEZMywuy 0EYh03TN2fZp50x4lRwkT7pQi12w4wI= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:e39b:6333:b001:cb]) (user=seanjc job=sendgmr) by 2002:a25:1b86:: with SMTP id b128mr7765690ybb.20.1633745613685; Fri, 08 Oct 2021 19:13:33 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 8 Oct 2021 19:12:14 -0700 In-Reply-To: <20211009021236.4122790-1-seanjc@google.com> Message-Id: <20211009021236.4122790-22-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 21/43] KVM: VMX: Clean up PI pre/post-block WARNs 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 Move the WARN sanity checks out of the PI descriptor update loop so as not to spam the kernel log if the condition is violated and the update takes multiple attempts due to another writer. This also eliminates a few extra uops from the retry path. Technically not checking every attempt could mean KVM will now fail to WARN in a scenario that would have failed before, but any such failure would be inherently racy as some other agent (CPU or device) would have to concurrent modify the PI descriptor. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/posted_intr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 351666c41bbc..67cbe6ab8f66 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -100,10 +100,11 @@ static void __pi_post_block(struct kvm_vcpu *vcpu) struct pi_desc old, new; unsigned int dest; + WARN(pi_desc->nv != POSTED_INTR_WAKEUP_VECTOR, + "Wakeup handler not enabled while the vCPU was blocking"); + do { old.control = new.control = pi_desc->control; - WARN(old.nv != POSTED_INTR_WAKEUP_VECTOR, - "Wakeup handler not enabled while the VCPU is blocked\n"); dest = cpu_physical_id(vcpu->cpu); @@ -161,13 +162,12 @@ int pi_pre_block(struct kvm_vcpu *vcpu) spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); } + WARN(pi_desc->sn == 1, + "Posted Interrupt Suppress Notification set before blocking"); + do { old.control = new.control = pi_desc->control; - WARN((pi_desc->sn == 1), - "Warning: SN field of posted-interrupts " - "is set before blocking\n"); - /* * Since vCPU can be preempted during this process, * vcpu->cpu could be different with pre_pcpu, we -- 2.33.0.882.g93a45727a2-goog