Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2920443pxb; Fri, 8 Oct 2021 19:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLOCmc25cYafNZdn9Bhiqa2/RaYMW5yKgAHPXS94zyzznB1XnZq7sL7wftiDa94OzCwtnx X-Received: by 2002:a17:906:f98c:: with SMTP id li12mr8781771ejb.108.1633746026683; Fri, 08 Oct 2021 19:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633746026; cv=none; d=google.com; s=arc-20160816; b=JroSEZa0/hq/rdpFk064MBM4HTsY7ttg/OEVPTF3GID0HUSJvUY6MzyFv5T6UmAQJ+ mldIdEwA1rYzSFIHyXx86QfPYAI1OKiAaUEs4DWociK5xhPxAMv67Cw77UxV3Up9k3jd efYbYUHNIAJ6Aiy4ZF5jcqPrXq38eRDzOY876iKMBwKI4I+AKX4yA3Sv0hmMbzh1lNcG P1zN42HmFxrmrtHRXVSnuihk1m3eJX71QmSdPMqcl6safwSaUgCOcKl4LGCy9PjfPant G2by340DL2VwuXMkJYNn7hrZskKPhpKpUhv0nAOkmfJwo+sCd9ex6WhbUpDFkL3qrJw2 SaKQ== 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=AlVgPkgkFYp3mdA0c8FeIFPE9R3iQYYLs6SQdF7DS7Y=; b=xitutkTHi8qNEPzIn4MBbKXy8tLYVdLfyOSrlh9h6uPgh3LON3WjmTyAAoMHxG5u1q MqmEqLq5DhwwWhPZAH7uDwvZZ/Oh08GVM5Rz1vOO6ewqEhD/4F8XJL86Vuw2MqLgGzug DJs9Vln/hcVXRkdboXbQEvA/RczAV9WunJp1FKTrobZgSzXwy1VzlpDZL56uvsL9yB6c PvLPR2NH721hjCgqaBBb6Zgjv7atp88cjF+vWqZjkyaPWKdSY/HkQQD9JyKEhCklL9cE r+eDadGY81uj8TAXKRYlEWcDix/eW2B3/UNZYE/zzKdrXeamlJ+S/aPYJb279atxJei8 womA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=iyDWCxyA; 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 28si1336370ejh.738.2021.10.08.19.19.58; Fri, 08 Oct 2021 19:20:26 -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=iyDWCxyA; 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 S244606AbhJICTc (ORCPT + 99 others); Fri, 8 Oct 2021 22:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244761AbhJICTI (ORCPT ); Fri, 8 Oct 2021 22:19:08 -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 A314AC0612F1 for ; Fri, 8 Oct 2021 19:14:25 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id v70-20020a256149000000b005ba4d61ea0fso11141680ybb.22 for ; Fri, 08 Oct 2021 19:14:25 -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=AlVgPkgkFYp3mdA0c8FeIFPE9R3iQYYLs6SQdF7DS7Y=; b=iyDWCxyALAJzTmrUWpKD0hm+MQGe0JbvQFQ+gPVY/mUdPcOBuJRTdijBOEaFZ+LAAb SDTgJ4oxCKVVc0nNYZIMuAMtCs0uQECNKotNLEWLcodTtHGOERifCGz75XQaYTAh1vxX neHo9EJwZRaNOXzY5g4EMe8hM39Md1Iy0bRnoPVZCfJilexl2bbxOCi5VnE5sdolV6eU NSIZQhgHuO3ZxoxUovFoBRAFe5hP7ZvZYuCsNm5sISOiG6xvPYGa1WB0B6RyfZX8HQo6 K97euHgjPX8JD6ljBA2834wXcBVVic3DkNPl89wT3euIRZ1CjF3KG79BaaaEoSx95D/a coZw== 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=AlVgPkgkFYp3mdA0c8FeIFPE9R3iQYYLs6SQdF7DS7Y=; b=Nre+slQRW+vr6F3rE1bBuxpJvkc5I2mxv714hAQcUOR0/4gCHUSI9UcyPpekxnBsnF GeokFVezCBzQyoM4eovV7Oahk3paxMnOZjpMklMPskqf/kFJYGvZ/2Qo7h+vi9bFX+41 ShaHZ6yEKD3jHIgmd8MVYFPBsV5l+kirHPJi4oV6kPLpHBPXRjv2PFEE+2tABRYoeH3e 9HuAQRzq7AuzcCQ+xZwD/SWjUJCns2G05QTKLJu52RQ1wCM1P8aoq9/tcR0CXRwybHb3 aDleSS7e+evZ8o7J8Uo4lfYMceYjFIiUtp5oCA39XC8DrgOk7B07s08bQMes8qSomWJB nnfg== X-Gm-Message-State: AOAM532C8A+8FgBNLSRzrQ7V3gWIEXUvRmkI33RoO3tHSaCysJQZ/Bq6 pek1xot/oq3QCDmKQeIrpdhgHrJFZEQ= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:e39b:6333:b001:cb]) (user=seanjc job=sendgmr) by 2002:a25:6908:: with SMTP id e8mr6568722ybc.337.1633745664741; Fri, 08 Oct 2021 19:14:24 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 8 Oct 2021 19:12:35 -0700 In-Reply-To: <20211009021236.4122790-1-seanjc@google.com> Message-Id: <20211009021236.4122790-43-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 42/43] KVM: VMX: Fold fallback path into triggering posted IRQ helper 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 fallback "wake_up" path into the helper to trigger posted interrupt helper now that the nested and non-nested paths are identical. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index f505fee3cf5c..b0d97cf18c34 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -3927,7 +3927,7 @@ static void vmx_msr_filter_changed(struct kvm_vcpu *vcpu) pt_update_intercept_for_msr(vcpu); } -static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu, +static inline void kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu, int pi_vec) { #ifdef CONFIG_SMP @@ -3958,10 +3958,15 @@ static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu, */ apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec); - return true; + return; } #endif - return false; + /* + * The vCPU isn't in the guest; wake the vCPU in case it is blocking, + * otherwise do nothing as KVM will grab the highest priority pending + * IRQ via ->sync_pir_to_irr() in vcpu_enter_guest(). + */ + kvm_vcpu_wake_up(vcpu); } static int vmx_deliver_nested_posted_interrupt(struct kvm_vcpu *vcpu, @@ -3984,8 +3989,7 @@ static int vmx_deliver_nested_posted_interrupt(struct kvm_vcpu *vcpu, */ kvm_make_request(KVM_REQ_EVENT, vcpu); /* the PIR and ON have been set by L1. */ - if (!kvm_vcpu_trigger_posted_interrupt(vcpu, POSTED_INTR_NESTED_VECTOR)) - kvm_vcpu_wake_up(vcpu); + kvm_vcpu_trigger_posted_interrupt(vcpu, POSTED_INTR_NESTED_VECTOR); return 0; } return -1; @@ -4022,9 +4026,7 @@ static int vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, int vector) * guaranteed to see PID.ON=1 and sync the PIR to IRR if triggering a * posted interrupt "fails" because vcpu->mode != IN_GUEST_MODE. */ - if (!kvm_vcpu_trigger_posted_interrupt(vcpu, POSTED_INTR_VECTOR)) - kvm_vcpu_wake_up(vcpu); - + kvm_vcpu_trigger_posted_interrupt(vcpu, POSTED_INTR_VECTOR); return 0; } -- 2.33.0.882.g93a45727a2-goog