From patchwork Fri Jun 3 14:20:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9153221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 135DE60221 for ; Fri, 3 Jun 2016 14:24:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 041652780C for ; Fri, 3 Jun 2016 14:24:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECEA0282E8; Fri, 3 Jun 2016 14:23:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73DBD2780C for ; Fri, 3 Jun 2016 14:23:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8py5-00039v-F1; Fri, 03 Jun 2016 14:20:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8py4-00039m-24 for xen-devel@lists.xen.org; Fri, 03 Jun 2016 14:20:56 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 9A/E2-25578-74291575; Fri, 03 Jun 2016 14:20:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsXS6fjDS9dtUmC 4QfcLWYslHxezODB6HN39mymAMYo1My8pvyKBNeNe317GgmsKFTOvbGVpYLwl3cXIwSEkkCdx fzprFyMnB6+AncTmn7vZQGwJAUOJffNXgdksAqoSi6c9Ywex2QTUJdqebQerFxGQkPj08SgLi M0s4CVx/P1LsBphAX+JTQ0TgWq4gMYfY5T4smY6E0iCU8BeovPSU1aQvbwCghJ/dwhD9NpJ3N vxgH0CI88shMwsJBkIW0vi4a9bLBC2tsSyha+ZQcqZBaQllv/jgClvOPeREVUJiO0psXTVZtY FjByrGDWKU4vKUot0DS30kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECw7WegYFx B+Pv056HGCU5mJREec+fDQgX4kvKT6nMSCzOiC8qzUktPsQow8GhJMFbNiEwXEiwKDU9tSItM wcYOTBpCQ4eJRFeXZA0b3FBYm5xZjpE6hSjopQ4rw1IQgAkkVGaB9cGi9ZLjLJSwryMDAwMQj wFqUW5mSWo8q8YxTkYlYR5N4NM4cnMK4Gb/gpoMRPQ4oJH/iCLSxIRUlINjPImmwvlfRQFWLl vPDv5iHuau9pKq2ZuR7lYL9dLy1MzA9yag3I3cUe5zV2S3R6o5tOwqTp/uYXvsWu9D02mJnQ+ nK+RGPhWLZapKdh0QR3zs7ZbpdqP3nHIX9tpESJZ8FZ2Y/J3/cLsl1znbsjLlsfsrJip4hzkb Lq9b8InjdPel/W/misosRRnJBpqMRcVJwIA/Z0R+dECAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1464963652!43717746!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55258 invoked from network); 3 Jun 2016 14:20:54 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Jun 2016 14:20:54 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 03 Jun 2016 08:20:51 -0600 Message-Id: <5751AE6402000078000F1A07@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Fri, 03 Jun 2016 08:20:52 -0600 From: "Jan Beulich" To: References: <57509021.1060506@datanoise.net> <57518B9202000078000F18C7@prv-mh.provo.novell.com> <5751A19502000078000F1982@prv-mh.provo.novell.com> In-Reply-To: <5751A19502000078000F1982@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Sylwester Sosnowski , xen-devel@lists.xen.org Subject: Re: [Xen-devel] Issues with PCI-Passtrough (VT-d) in HVM with Xen 4.6 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP >>> On 03.06.16 at 15:26, wrote: >>>> On 03.06.16 at 14:02, wrote: >> or is this just some method the overwrite all registers with >> "ffffffff" first and then set the actual value? >> >> [914572] xbk: 06:00.0: write request 4 bytes at 0x10 = ffffffff >> [914574] xbk: 06:00.0: read 4 bytes at 0x10 >> [914582] xbk: 06:00.0: read 4 bytes at 0x10 = f7a00000 >> [914591] xbk: 06:00.0: read 4 bytes at 0x10 >> [914599] xbk: 06:00.0: read 4 bytes at 0x10 = 10000 <---- fail > > That's an unexpected value, indeed (but seems to match up with > the source, so there's definitely something wrong here - this > presumably ought to be 0xffff0000, meaning the size of that > region is 64k). Mind trying out the attached patch? Jan xen-pciback: return proper values during BAR sizing Reads following writes with all address bits set to 1 should return all changeable address bits as one, not the BAR size (nor, as was the case for the upper half of 64-bit BARs, the high half of the region's end address). Presumably this didn't cause any problems so far because consumers use the value to calculate the size (usually via val & -val), and do nothing else with it. But also consider the exception here: Unimplemented BARs should always return all zeroes. And finally, the check for whether to return the sizing address on read for the ROM BAR should ignore all non-address bits, not just the ROM Enable one. Signed-off-by: Jan Beulich --- head.orig/drivers/xen/xen-pciback/conf_space_header.c 2015-03-16 15:38:59.000000000 +0100 +++ head/drivers/xen/xen-pciback/conf_space_header.c 2016-06-03 15:55:27.629520779 +0200 @@ -149,7 +149,7 @@ static int rom_write(struct pci_dev *dev /* A write to obtain the length must happen as a 32-bit write. * This does not (yet) support writing individual bytes */ - if (value == ~PCI_ROM_ADDRESS_ENABLE) + if ((value | ~PCI_ROM_ADDRESS_MASK) == ~0) bar->which = 1; else { u32 tmpval; @@ -229,38 +229,42 @@ static inline void read_dev_bar(struct p (PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64))) { bar_info->val = res[pos - 1].start >> 32; - bar_info->len_val = res[pos - 1].end >> 32; + bar_info->len_val = -resource_size(&res[pos - 1]) >> 32; return; } } + if (!res[pos].flags || + (res[pos].flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET | + IORESOURCE_BUSY))) + return; + bar_info->val = res[pos].start | (res[pos].flags & PCI_REGION_FLAG_MASK); - bar_info->len_val = resource_size(&res[pos]); + bar_info->len_val = -resource_size(&res[pos]) | + (res[pos].flags & PCI_REGION_FLAG_MASK); } static void *bar_init(struct pci_dev *dev, int offset) { - struct pci_bar_info *bar = kmalloc(sizeof(*bar), GFP_KERNEL); + struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL); if (!bar) return ERR_PTR(-ENOMEM); read_dev_bar(dev, bar, offset, ~0); - bar->which = 0; return bar; } static void *rom_init(struct pci_dev *dev, int offset) { - struct pci_bar_info *bar = kmalloc(sizeof(*bar), GFP_KERNEL); + struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL); if (!bar) return ERR_PTR(-ENOMEM); read_dev_bar(dev, bar, offset, ~PCI_ROM_ADDRESS_ENABLE); - bar->which = 0; return bar; }