From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Sheng" Subject: Re: [PATCH 5/7] KVM/userspace: Device Assignment: Support for assigning PCI devices to guests Date: Fri, 26 Sep 2008 09:34:24 +0800 Message-ID: <200809260934.25202.sheng.yang@intel.com> References: <1222181695-23418-1-git-send-email-amit.shah@redhat.com> <1222181695-23418-5-git-send-email-amit.shah@redhat.com> <1222181695-23418-6-git-send-email-amit.shah@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: Amit Shah , "avi@redhat.com" , "muli@il.ibm.com" , "anthony@codemonkey.ws" , "benami@il.ibm.com" , "Han, Weidong" , "Kay, Allen M" To: kvm@vger.kernel.org Return-path: Received: from mga09.intel.com ([134.134.136.24]:12368 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752229AbYIZBdo (ORCPT ); Thu, 25 Sep 2008 21:33:44 -0400 In-Reply-To: <1222181695-23418-6-git-send-email-amit.shah@redhat.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: On Tuesday 23 September 2008 22:54:53 Amit Shah wrote: > +static uint32_t assigned_dev_pci_read_config(PCIDevice *d, uint32_t > address, + int len) > +{ > + uint32_t val = 0; > + int fd, r; > + > + if ((address >= 0x10 && address <= 0x24) || address == 0x34 || > + address == 0x3c || address == 0x3d) { > + val = pci_default_read_config(d, address, len); > + DEBUG("(%x.%x): address=%04x val=0x%08x len=%d\n", > + (d->devfn >> 3) & 0x1F, (d->devfn & 0x7), address, > val, + len); > + return val; > + } > + > + /* vga specific, remove later */ > + if (address == 0xFC) > + goto do_log; > + > + fd = ((AssignedDevice *)d)->real_device.config_fd; > + r = lseek(fd, address, SEEK_SET); > + if (r < 0) { > + fprintf(stderr, "%s: bad seek, errno = %d\n", > + __func__, errno); > + return val; > + } This read from configuration space method got a little trouble: vender id and device id read from configuration space directly rather than "vender" and "device" file in the sysfs. That's cause trouble with some device that configuration space inconsistent with "vender" and "device" file, e.g. some fix up by host PCI subsystem in kernel. Maybe it can be delay a little for a following patch, but we should address this issue... Maybe we can use libpci? There are more fields than vender and device got this problem, like "irq". -- regards Yang, Sheng