From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PATCH 01/10] KVM: SVM: Don't use kmap_atomic in nested_svm_map Date: Thu, 18 Feb 2010 17:16:37 +0100 Message-ID: <20100218161637.GP22141@amd.com> References: <1266493115-28386-1-git-send-email-joerg.roedel@amd.com> <1266493115-28386-2-git-send-email-joerg.roedel@amd.com> <4B7D4368.6020903@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: Marcelo Tosatti , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@kernel.org To: Avi Kivity Return-path: Content-Disposition: inline In-Reply-To: <4B7D4368.6020903@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, Feb 18, 2010 at 03:40:56PM +0200, Avi Kivity wrote: > On 02/18/2010 01:38 PM, Joerg Roedel wrote: > >Use of kmap_atomic disables preemption but if we run in > >shadow-shadow mode the vmrun emulation executes kvm_set_cr3 > >which might sleep or fault. So use kmap instead for > >nested_svm_map. > > > > > > > >-static void nested_svm_unmap(void *addr, enum km_type idx) > >+static void nested_svm_unmap(void *addr) > > { > > struct page *page; > > > >@@ -1443,7 +1443,7 @@ static void nested_svm_unmap(void *addr, enum km_type idx) > > > > page = kmap_atomic_to_page(addr); > > > >- kunmap_atomic(addr, idx); > >+ kunmap(addr); > > kvm_release_page_dirty(page); > > } > > kunmap() takes a struct page *, not the virtual address (a > consistent source of bugs). Ah true, thanks. I'll fix that. > kmap() is generally an unloved interface, it is slow and possibly > deadlock prone, but it's better than sleeping in atomic context. If > you can hack your way around it, that is preferred. Best would be to use kvm_read_guest, but I fear that this will have an performance impact. Maybe I'll try this and measure if it really has a significant performance impact. Joerg