Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2387050imw; Wed, 6 Jul 2022 05:13:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8YB7Ap3tzu0TkL/7aDWJZYOpY0zkf+gHlEaRtKLSJPhNCTFsSvI2D4al7KKrFC4D5LXnr X-Received: by 2002:a05:6402:3689:b0:43a:7c1c:8960 with SMTP id ej9-20020a056402368900b0043a7c1c8960mr9699695edb.79.1657109587226; Wed, 06 Jul 2022 05:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657109587; cv=none; d=google.com; s=arc-20160816; b=nSm+OXC+n7mONBpbStF2ezDC00mAJL9qBa25ETuR89zWE7caAT0a7b71KAct2egEyJ 7BfUt45tJ3EN8WFRWrxl/JK1//sIeWqxC7zCkZg9NOJ+PLICHTmy64DWvXAMLj5jQSwo yU5zc9pTtqlIYbHdr9BIqIi5b5TqF50PTgSAQTjmAMqLTKOow9IQgU3nMzjEu/ni/JS6 zyJ9rseL0ii/Ws/bm24wA7daW87ZJUIwxDOR3TmWQjnTy2ST3EIIYfjX3dt7s6ojMjLB ib1kAt25ADGE4N029CYpbKEGxtmH529t0QM8uCYBWq60jR/Bg4zXBhw7+iDiBVEIPPY+ XXbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=e+UeVNoDDIWPJg4xB4qyPAufcsuGQ6KT0GwIgobfcyw=; b=NfjhUhAdldZ1I95s7SAJ4614i803glp8VBXC7oZNsUB0aRO6pgbLKufFDKF0PdaMB2 d72KpG/76mZfYdoLUt/tkc6fT4OywoPgn3va/0oKtrEaeK/ujTu+arrzzvxd1L7O8ZPE x+Yq9EyCE0Bj5HIl94xF4NPIm2zY/ATbTDNN60WAw86SydD6WBuxCM/qgjm1nE943IWx ImTZcjWFd/reCN4mzOVzOgv04BL63/o7528tRsTa280ZOdkpcZgTO+QaGF8TwWUNL6dU fXcLLG7Jx4qqWlGLR0wesdJ7+t+bLCXz/yk12K4hjWzfOm9QcOtkQe8Ymb+v1MqfuEQW g7Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CJoXOCzt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg12-20020a170907970c00b006fefef9abd2si31248232ejc.366.2022.07.06.05.12.41; Wed, 06 Jul 2022 05:13:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CJoXOCzt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233465AbiGFMFp (ORCPT + 99 others); Wed, 6 Jul 2022 08:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233467AbiGFMFj (ORCPT ); Wed, 6 Jul 2022 08:05:39 -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 ESMTP id 3D7562A267 for ; Wed, 6 Jul 2022 05:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657109127; 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=e+UeVNoDDIWPJg4xB4qyPAufcsuGQ6KT0GwIgobfcyw=; b=CJoXOCzt/YvBy+O7KEEZD72K8xcJUphFse1t5a1lDt+uZGADeA1M70a82+4L4HPZyaYKXw Wu8YcFuEITcXhq0MEKF713CP078FzqwOS+0czBgBM8HOmN0yHrystn+8ynHnt9TVcoW1ri 02DYDPj6ThXhlxAyvMFtjM/F2zjNgA4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-609-6Zz0fdp-MveGMh3UjMHMVQ-1; Wed, 06 Jul 2022 08:05:21 -0400 X-MC-Unique: 6Zz0fdp-MveGMh3UjMHMVQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFB7C299E76E; Wed, 6 Jul 2022 12:05:20 +0000 (UTC) Received: from starship (unknown [10.40.194.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EBDB2EF97; Wed, 6 Jul 2022 12:05:18 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 16/21] KVM: x86: Evaluate ability to inject SMI/NMI/IRQ after potential VM-Exit From: Maxim Levitsky To: Sean Christopherson , Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Upton , Peter Shier Date: Wed, 06 Jul 2022 15:05:17 +0300 In-Reply-To: <20220614204730.3359543-17-seanjc@google.com> References: <20220614204730.3359543-1-seanjc@google.com> <20220614204730.3359543-17-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-06-14 at 20:47 +0000, Sean Christopherson wrote: > Determine whether or not new events can be injected after checking nested > events. If a VM-Exit occurred during nested event handling, any previous > event that needed re-injection is gone from's KVM perspective; the event > is captured in the vmc*12 VM-Exit information, but doesn't exist in terms > of what needs to be done for entry to L1. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/x86.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 930de833aa2b..1a301a1730a5 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9502,7 +9502,7 @@ static void kvm_inject_exception(struct kvm_vcpu *vcpu) > > static int inject_pending_event(struct kvm_vcpu *vcpu, bool *req_immediate_exit) > { > - bool can_inject = !kvm_event_needs_reinjection(vcpu); > + bool can_inject; > int r; > > /* > @@ -9567,7 +9567,13 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool *req_immediate_exit) > if (r < 0) > goto out; > > - /* try to inject new event if pending */ > + /* > + * New events, other than exceptions, cannot be injected if KVM needs > + * to re-inject a previous event. See above comments on re-injecting > + * for why pending exceptions get priority. > + */ > + can_inject = !kvm_event_needs_reinjection(vcpu); > + > if (vcpu->arch.exception.pending) { > /* > * Fault-class exceptions, except #DBs, set RF=1 in the RFLAGS Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky