From patchwork Thu Mar 24 13:27:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 658781 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2ODRLhn002765 for ; Thu, 24 Mar 2011 13:27:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755785Ab1CXN1T (ORCPT ); Thu, 24 Mar 2011 09:27:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63554 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751930Ab1CXN1S (ORCPT ); Thu, 24 Mar 2011 09:27:18 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2ODRISM031524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Mar 2011 09:27:18 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2ODRHxx027819; Thu, 24 Mar 2011 09:27:18 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id B892F18D3E9; Thu, 24 Mar 2011 15:27:16 +0200 (IST) Date: Thu, 24 Mar 2011 15:27:16 +0200 From: Gleb Natapov To: Marcelo Tosatti Cc: kvm , Avi Kivity Subject: Re: KVM: x86: vcpu state writeback should be aware of REQ_NMI Message-ID: <20110324132716.GA13195@redhat.com> References: <20110324124700.GA26882@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110324124700.GA26882@amt.cnet> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Mar 2011 13:27:22 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1b8b16a..6a66d19 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5151,6 +5151,7 @@ static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu) static int vcpu_enter_guest(struct kvm_vcpu *vcpu) { int r; + int nmi_pending; bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && vcpu->run->request_interrupt_window; @@ -5188,19 +5189,19 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) r = 1; goto out; } - if (kvm_check_request(KVM_REQ_NMI, vcpu)) - vcpu->arch.nmi_pending = true; } r = kvm_mmu_reload(vcpu); if (unlikely(r)) goto out; + nmi_pending = vcpu->arch.nmi_pending; + if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) { inject_pending_event(vcpu); /* enable NMI/IRQ window open exits if needed */ - if (vcpu->arch.nmi_pending) + if (nmi_pending) kvm_x86_ops->enable_nmi_window(vcpu); else if (kvm_cpu_has_interrupt(vcpu) || req_int_win) kvm_x86_ops->enable_irq_window(vcpu);