From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM x86: Handle hypercalls for assigned PCI devices Date: Wed, 30 Apr 2008 01:48:38 +0300 Message-ID: <4817A5C6.7070704@qumranet.com> References: <1209465451-3758-1-git-send-email-amit.shah@qumranet.com> <1209465451-3758-3-git-send-email-amit.shah@qumranet.com> <48173440.304@redhat.com> <200804292128.52268.amit.shah@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: chrisw@redhat.com, kvm-devel@lists.sourceforge.net, allen.m.kay@intel.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Glauber Costa , BENAMI@il.ibm.com To: Amit Shah Return-path: In-Reply-To: <200804292128.52268.amit.shah@qumranet.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Amit Shah wrote: > >>> + if (is_error_page(host_page)) { >>> + printk(KERN_INFO "%s: gfn %p not valid\n", >>> + __func__, (void *)page_gfn); >>> + r = -1; >>> >> r = -1 is not really informative. Better use some meaningful error. >> > > The error's going to the guest. The guest, as we know, has already done a > successful DMA allocation. Something went wrong in the hypercall, and we > don't know why (bad page). Any kind of error here isn't going to be > intelligible to the guest anyway. It's mostly a host thing if we ever hit > this. > > If the guest is not able to handle it, why bother returning an error? Better to kill it. But in any case, -1 is not a good error number. >>> + if (find_pci_pt_dev(&vcpu->kvm->arch.pci_pt_dev_head, >>> + &pci_pt_info, 0, KVM_PT_SOURCE_ASSIGN)) >>> + r++; /* We have assigned the device */ >>> + >>> + kunmap(host_page); >>> >> better use atomic mappings here. >> > > We can't use atomic mappings for guest pages. They can be swapped out. > kmap()ed pages can't be swapped out either. The atomic in kmap_atomic() only refers to the context in which the pages are used. Atmoic kmaps are greatly preferable to the nonatomic ones. -- Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone