From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: Fix mmu_reload() clash with nested vmx event injection Date: Wed, 16 May 2012 18:12:44 -0300 Message-ID: <20120516211244.GA25397@amt.cnet> References: <1337008076-18956-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:44493 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932202Ab2EPV4o (ORCPT ); Wed, 16 May 2012 17:56:44 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4GLuijq028292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 May 2012 17:56:44 -0400 Content-Disposition: inline In-Reply-To: <1337008076-18956-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, May 14, 2012 at 06:07:56PM +0300, Avi Kivity wrote: > Currently the inject_pending_event() call during guest entry happens after > kvm_mmu_reload(). This is for historical reasons - we used to > inject_pending_event() in atomic context, while kvm_mmu_reload() needs task > context. > > A problem is that nested vmx can cause the mmu context to be reset, if event > injection is intercepted and causes a #VMEXIT instead (the #VMEXIT resets > CR0/CR3/CR4). If this happens, we end up with invalid root_hpa, and since > kvm_mmu_reload() has already run, no one will fix it and we end up entering > the guest this way. > > Fix by reordering event injection to be before kvm_mmu_reload(). Use > ->cancel_injection() to undo if kvm_mmu_reload() fails. > > https://bugzilla.kernel.org/show_bug.cgi?id=42980 > > Reported-by: Luke-Jr > Signed-off-by: Avi Kivity > --- > arch/x86/kvm/x86.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) Applied, thanks.