Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp599531ybz; Sat, 25 Apr 2020 00:04:12 -0700 (PDT) X-Google-Smtp-Source: APiQypKXKKxrYOGQeO7PWXZPV1jYYYkeckfa8P7opHGpLuBjZY/U6dU1mYg1nqEZkLIFKzC9qniJ X-Received: by 2002:a17:906:1303:: with SMTP id w3mr10562869ejb.275.1587798252023; Sat, 25 Apr 2020 00:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587798252; cv=none; d=google.com; s=arc-20160816; b=w4bfQly91daaBoJwgRTRJXUyJI0tx/ugiR/sEOyAgfI1OxW2zRaeKyaEClKzKLmQTE urkNIecs05vBTilzX69IrI/XJqOUKPtLCfmlXZT6BfSU+3jfllWpKrHg7aZqREo7dIbL l4gNUhLaixi1cyt0A208mczd3z1g0JgdKNx3VTkdgLGspbv4C5vcOvwDEL+sn+kF4MiT eGg/xOpQyP72128GAmcPPXaY+hMdglgWiAw0liqgAYz1syjpvXpqQsSYyFcvD2QX7J/m 06W0sxWyOaV7o2To7UgZJx7irYXjqDuwou97mRnPActa45+0vnHeodFy0La5oVUslDpk vcLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=hOqzqNt3g35oGlWmdR+OwR0lzPFCoYe2O5p/oF2M6rc=; b=bhW7rqTYiCfNmjl4qdgUjDElMfAY0LiJJAzsQtjClZy3qdFkmemR/4Ro7tBhA59lPf yR54oj4mKXhPsg2FapB1eae/kzJ/BAKW+QAN34GOwuCNbjcnKVyx0PaaiXQz5BV7hEcE yNpftOx7JxLQf0qqCuspACj+WeDA1OPZOU8oj30TJAzN1pQFg7wFrg0MawhTOAdeotgI 07ElKL44UMlhQaZrtRTrIZJjezy++MD8B4WUX0mcZIc1SH+Djw3rlcy7t6fgeHcQbexJ 3NMpm/TCe8NuC9404qubMp21QbcvdVk2v+43nq6CiPCvKRY9Zfh8UZfB19aVwanMcBKg d3zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NRVTAHVU; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si4569647edo.105.2020.04.25.00.03.49; Sat, 25 Apr 2020 00:04:12 -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=@redhat.com header.s=mimecast20190719 header.b=NRVTAHVU; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbgDYHCO (ORCPT + 99 others); Sat, 25 Apr 2020 03:02:14 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40465 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726346AbgDYHCK (ORCPT ); Sat, 25 Apr 2020 03:02:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587798129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=hOqzqNt3g35oGlWmdR+OwR0lzPFCoYe2O5p/oF2M6rc=; b=NRVTAHVUtqgv0M8TvUSknRyq0T2yuOLsmygeB5+HskSSW2NIa20PMBBCEKS0F+YWARvRho 7nUtZxNQbdc3wrOLJDYlYddRnlZ2WYOekMIZaT4rztcH9K0SvMUZ0mf/qLM6siVrs8Pzdh XVqGjfDWLh0iBTupxGJAiIPsA9lsxFc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-496-x65JYobjPbyWxNDlk1wnuA-1; Sat, 25 Apr 2020 03:02:04 -0400 X-MC-Unique: x65JYobjPbyWxNDlk1wnuA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9381C800580; Sat, 25 Apr 2020 07:02:03 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7F285D9C5; Sat, 25 Apr 2020 07:02:02 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: wei.huang2@amd.com, cavery@redhat.com, vkuznets@redhat.com, Sean Christopherson , Oliver Upton , Jim Mattson Subject: [PATCH v2 19/22] KVM: x86: WARN on injected+pending exception even in nested case Date: Sat, 25 Apr 2020 03:01:51 -0400 Message-Id: <20200425070154.251290-10-pbonzini@redhat.com> In-Reply-To: <20200424172416.243870-1-pbonzini@redhat.com> References: <20200424172416.243870-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson WARN if a pending exception is coincident with an injected exception before calling check_nested_events() so that the WARN will fire even if inject_pending_event() bails early because check_nested_events() detects the conflict. Bailing early isn't problematic (quite the opposite), but suppressing the WARN is undesirable as it could mask a bug elsewhere in KVM. Signed-off-by: Sean Christopherson Message-Id: <20200423022550.15113-11-sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/x86.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e8469db6ccae..44b9d834621c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7693,6 +7693,9 @@ static int inject_pending_event(struct kvm_vcpu *vcpu) kvm_x86_ops.set_irq(vcpu); } + WARN_ON_ONCE(vcpu->arch.exception.injected && + vcpu->arch.exception.pending); + /* * Call check_nested_events() even if we reinjected a previous event * in order for caller to determine if it should require immediate-exit @@ -7711,7 +7714,6 @@ static int inject_pending_event(struct kvm_vcpu *vcpu) vcpu->arch.exception.has_error_code, vcpu->arch.exception.error_code); - WARN_ON_ONCE(vcpu->arch.exception.injected); vcpu->arch.exception.pending = false; vcpu->arch.exception.injected = true; -- 2.18.2