Received: by 10.223.176.46 with SMTP id f43csp4123132wra; Tue, 23 Jan 2018 04:44:45 -0800 (PST) X-Google-Smtp-Source: AH8x225lwTApcTWGjzww3tZP99v2hlIeoB1eRxLqdXDIoMNbdWX535rCDmIUz9F7cgRXKeQj0uv+ X-Received: by 2002:a17:902:7f0b:: with SMTP id d11-v6mr1437379plm.70.1516711485895; Tue, 23 Jan 2018 04:44:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516711485; cv=none; d=google.com; s=arc-20160816; b=odY8W88twiLyLsYV2iIwPreenLVExT63DFz9qfXC40yhwwy+uItMm/69BHDuSkP83L qSI2tOTtswCzzJ/lmHhckOkGH8n3oezUJOcOeP5vqKq0GYtgX6rBDitUqwo1cnXUm/Ac Ef3Kt6yW057ugOAxDaJuah9D4il+vOfUxkuL2LDn+U0o/kSlOk0kVL9tbFqXmuEmxWfu 4aCLVBl6oMXebJ7pXnp5DTm4nEiDGf+N6DkqjZoZ38odIMPpDw8AhWRtpNwGRdW93NgZ RadKpOhEMM9Bgb60sH2o+uSsiCmu3na9yyqfXwZkXep8PEZsIebcQET6DcOnOeu7TeS1 JsWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=tgcPUZ68QEUm49Ayr1QO+57wxkZJmiRNpz2hG5rdVzs=; b=U9L6ufdreY1MWhAv/bdjLmRirgDkIx/H1WUjFINb0FMhVdKQtMs9FLa5EZkcowWPfR 2I5L16e0E589uvstfNS9MuD14AVOSigLJo5I+fYLrgs0+m3V1nwKlLLF6VnIahjfyCcJ /Kn82T44iDGJJuTRIA9ugdEcgNF0wQH6lDBwMVD64jXFC5Qzl3ccB6TuVjzWQ2Mux5uB QeRV116e2Pnsldf+2Vr0GiVxE+ivramQaz2toC+bfitnJ3G38JFrQL2AzlwrKxM/Qyw4 D+8nO7TpYJYiy6PrEkMafDODuxUyfeTDDNxCwrln4gJJgTY+kVbDrh4rUOBU8Tjiyl4h mt9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si9791948pgq.154.2018.01.23.04.44.31; Tue, 23 Jan 2018 04:44:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751793AbeAWMn1 (ORCPT + 99 others); Tue, 23 Jan 2018 07:43:27 -0500 Received: from stargate.chelsio.com ([12.32.117.8]:2427 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbeAWMnZ (ORCPT ); Tue, 23 Jan 2018 07:43:25 -0500 Received: from localhost (victim.blr.asicdesigners.com [10.193.185.129]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id w0NChDXg016476; Tue, 23 Jan 2018 04:43:14 -0800 Date: Tue, 23 Jan 2018 18:13:26 +0530 From: Ganesh Goudar To: Arjun Vynipadath Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, leedom@chelsio.com, santosh@chelsio.com, nirranjan@chelsio.com, kumaras@chelsio.com, swise@opengridcomputing.com, hare@suse.de Subject: Re: [REGRESSION, bisect] pci: cxgb4 probe fails after commit 104daa71b3961434 ("PCI: Determine actual VPD size on first access") Message-ID: <20180123124323.GA21413@chelsio.com> References: <1516710549-26660-1-git-send-email-arjun@chelsio.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516710549-26660-1-git-send-email-arjun@chelsio.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Hannes Reinecke On Tuesday, January 01/23/18, 2018 at 17:59:09 +0530, Arjun Vynipadath wrote: > Sending on behalf of "Casey Leedom " > > Way back on April 11, 2016 we reported a regression in Linux kernel 4.6-rc2 > brought on by kernel.org commit 104daa71b396. This commit calculates the > size of a PCI Device's VPD area by parsing the VPD Structure at offset 0x000, > and restricts accesses to the VPD to that computed size. > > Our devices have a second VPD structure which is located starting at offset > 0x400 which is the "real" VPD[1]. The 104daa71b396 commit (plus a follow on > commit 408641e93aa5) caused efforts to read past the end of that computed > length of the VPD to return silently without error leaving stack junk in the > VPD read buffers. > > We introduced kernel.org commit cb92148b to allow a driver to tell the > kernel how large the VPD area really is, introducing a new API > pci_set_vpd_size() for this purpose. > > Now we've discovered a new subtlety to the problem. > > We have a KVM Hypervisor running a 4.9.70 kernel. So it has all of the > above commits. When we attach our Physical Function 4 to a Virtual Machine > and attempt to run cxgb4 in that VM, we see the problem again. The issue is > that all of the VM Guest OS's efforts to access the PCIe VPD Capability are > trapped into the KVM 4.9.70 kernel and executed there, with the results > routed back to the VM Guest OS. The cxgb4 driver in the VM Guest OS uses > the new pci_set_vpd_size() to notify the OS of the true size of the VPD, but > that information of course is never sent to the KVM 4.9.70 Hypervisor. > (And, truth be told, if the Guest OS were older than 4.6, it wouldn't even > know that it needed to do this.) The result is that again we get silent VPD > read failures with random stack garbage in the VPD read buffers. (sigh) > > It strikes me that the only way to handle this issue is to have KVM > circumvent the VPD-Size Restricted logic which was added in kernel.org > commits 104daa71b396 and 408641e93aa5. Maybe via a __pci_read_vpd() or > similar API. But we are open to other suggestions. > > Thoughts? > > Casey. > > [1] Chelsio adapters actually have two VPD structures stored in the VPD. An > abbreviated on at Offset 0x0 and the complete VPD at Offset 0x400. The > abbreviated one only contains the PN, SN and EC Keywords, while the > complete VPD contains those plus various adapter constants contained in > V0, V1, etc. And it also contains the Base Ethernet MAC Address in the > "NA" Keyword which the cxgb4 driver needs when it can't contact the > adapter firmware. (We don't have the "NA" Keyword in the VPD Structure > at Offset 0x000 because that's not an allowed VPD Keyword in the PCI-E > 3.0 specification.) > > Note that two other drivers look like they may also do something > similar, the Broadcom bnx2x and tg3.