From patchwork Tue Jul 18 09:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 13316904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8D28EB64DC for ; Tue, 18 Jul 2023 09:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbjGRJON (ORCPT ); Tue, 18 Jul 2023 05:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbjGRJOL (ORCPT ); Tue, 18 Jul 2023 05:14:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F8310C2 for ; Tue, 18 Jul 2023 02:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689671605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4C0D24d2FC1TYs50FyhHTmpHwv4hCv9vozKRBzYFkPk=; b=UwJ/38koG/XjnlPzIYTGcjLcmuqZkHWffD0fR1IheDPe7qKDTGo7ib3Zizg6DR9ABBpMv2 C94dD44chJiMV0Wniv1F9OO2+RKZPfUyPry9WzmKN1Y7YwCUqYVl41kAZfXUF2DK0DMan3 bSKVkUz+7h9jSM7QlJmu5PKuhCWLtfE= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-423-Hs3Upf_oN22Bel_I6Zw-CQ-1; Tue, 18 Jul 2023 05:13:21 -0400 X-MC-Unique: Hs3Upf_oN22Bel_I6Zw-CQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D0082A59542; Tue, 18 Jul 2023 09:13:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.224.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id C14791454142; Tue, 18 Jul 2023 09:13:18 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: "H. Peter Anvin" , Sean Christopherson , linux-kernel@vger.kernel.org, Thomas Gleixner , Paolo Bonzini , Ingo Molnar , Dave Hansen , x86@kernel.org, Borislav Petkov , Maxim Levitsky Subject: [PATCH 2/3] KVM: x86: VMX: set irr_pending in kvm_apic_update_irr Date: Tue, 18 Jul 2023 12:13:09 +0300 Message-Id: <20230718091310.119672-3-mlevitsk@redhat.com> In-Reply-To: <20230718091310.119672-1-mlevitsk@redhat.com> References: <20230718091310.119672-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When the APICv is inhibited, the irr_pending optimization is used. Therefore, when kvm_apic_update_irr sets bits in the IRR, it must set irr_pending to true as well. Signed-off-by: Maxim Levitsky --- arch/x86/kvm/lapic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index b3f57e0f0d64ae..613830ba2d8cef 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -653,8 +653,11 @@ EXPORT_SYMBOL_GPL(__kvm_apic_update_irr); bool kvm_apic_update_irr(struct kvm_vcpu *vcpu, u32 *pir, int *max_irr) { struct kvm_lapic *apic = vcpu->arch.apic; + bool irr_updated = __kvm_apic_update_irr(pir, apic->regs, max_irr); - return __kvm_apic_update_irr(pir, apic->regs, max_irr); + if (unlikely(!apic->apicv_active && irr_updated)) + apic->irr_pending = true; + return irr_updated; } EXPORT_SYMBOL_GPL(kvm_apic_update_irr);