Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3416925imm; Fri, 19 Oct 2018 10:12:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV611GBKULipYI3TieyyZtZ1Qz5xgWv2/jY9FMQRRInUD3k4QIwF/t2CD0bBqEbQ3Yw46/9qf X-Received: by 2002:a17:902:8bc3:: with SMTP id r3-v6mr34558020plo.218.1539969125477; Fri, 19 Oct 2018 10:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539969125; cv=none; d=google.com; s=arc-20160816; b=b61qJQGqgloWUE2eExct/zs9AkS92gEgVvemCFonIL1+nmDoqiDsDMmndzS+QNnOUi xhkC28U7u26ep+zDRPRPGT2uXPoYTkJYn4kUroHNJjEqwnJpd4rb5yvpNd+dHnNm7D2o e7lUvhsnYpdPglT2nZDOkul8DLlI3zG7Pgqj1ezH6L1NArEIgSLcdt3jJHv6E2jEUw12 F4ca6x0+bSjHmMgC7g9/kPWq/GeCF51VnQ61T9qHSRPuzcA4i5JUqUnPg+RDx7tCbXAZ BMcegk54G9eXy/yOtduB3yelWve6+KA2OiRAWlHS1ZWNI1Fc6OTGHN1u5T5b5a659xbd 7eUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=U8dPLfi72vzQd2z3AXvYa0hAMGrXoNazjKFrxoR0M60=; b=WO49Vn4y9t7GIl6AvqqLcBMMfzg0Z+8H6GFafYkNVoSRy+vJ4CLjv+PDc7t/mFWhLR O9Ld8vCf8oZ88Djqrnu+DLjcWP/GqmOiu4T0rmg6weTA1kK9QAlSDMagfqIFe3FewfRf 5RcYz2Q+Sl5/Y0+Twdrx/tL5lUHsWyQ9R+Zd0KPUCE9piQ7JU+vhw/kjy/p4BgnzrQlR j5bh01omv7+kYPn0ptmJBEt3y91+vgpLcHCTR//uCy6EV6Sf45xTrRRV3Htaafh9lT+u Hpyb99vLp+kIdfb6iCOn6w9fLCyIJkY+lojct+0CHdYGrBl2F2D4C+jPRBAh+BDj6dUf VI8Q== 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 p9-v6si23511832pls.378.2018.10.19.10.11.48; Fri, 19 Oct 2018 10:12:05 -0700 (PDT) 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 S1727787AbeJTAFw convert rfc822-to-8bit (ORCPT + 99 others); Fri, 19 Oct 2018 20:05:52 -0400 Received: from mx01.busymouse24.de ([83.246.107.19]:53149 "EHLO mx01.busymouse24.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbeJTAFw (ORCPT ); Fri, 19 Oct 2018 20:05:52 -0400 X-Greylist: delayed 365 seconds by postgrey-1.27 at vger.kernel.org; Fri, 19 Oct 2018 20:05:50 EDT Received: from maskedhost [127.0.0.1] by mx01.busymouse24.de stage1 with esmtps (Exim MailCleaner) id 1gDX5D-0008k6-Ny from ; Fri, 19 Oct 2018 17:53:03 +0200 Received: from SRV188.busymouse24.de (192.168.100.188) by SRV177.busymouse24.de (192.168.100.177) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 19 Oct 2018 17:53:03 +0200 Received: from SRV177.busymouse24.de (192.168.100.177) by SRV188.busymouse24.de (192.168.100.188) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 19 Oct 2018 17:53:02 +0200 Received: from SRV177.busymouse24.de ([fe80::f87a:2c8c:90ef:d29a]) by SRV177.busymouse24.de ([fe80::f87a:2c8c:90ef:d29a%14]) with mapi id 15.00.1263.000; Fri, 19 Oct 2018 17:53:02 +0200 From: Andreas Puhm To: Alan Tull , Moritz Fischer CC: "linux-fpga@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [Bug] altera_cvp registers a PCI device (Altera/Intel FPGA) without verifying that it supports CVP Thread-Topic: [Bug] altera_cvp registers a PCI device (Altera/Intel FPGA) without verifying that it supports CVP Thread-Index: AdRnw6sLsfLCE4NLQri3QW4UMzXDuw== Date: Fri, 19 Oct 2018 15:53:02 +0000 Message-ID: <2c6313a3f7c04b70b8a06a50934fe27a@SRV177.busymouse24.de> Accept-Language: de-AT, de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [83.246.107.135] x-exclaimer-md-config: 1802f3fe-bc94-4301-9dc2-d59a74e6de3a Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I hope the following information is descriptive enough. If this is no the case, I will provide further details. -------------------------------------------------------------------- Full description: The altera_cvp probe function only checks, if the Altera/Intel PCI device configuration space contains a vendor specific entry (VSEC Capability Header 0x000b) at offset 0x200. But the probe function does not verify, if the PCI device (and further the FPGA), for which it has been called, actually supports the Configure-via-Protocol feature. The PCI device (FPGA) can explicitly disable the Configur-via-Protocol (CvP) feature by setting the CVP_EN bit, index 20 of CVP_STATUS register, to '0'. As the altera_cvp probe function does not check this it registers the device in any way. At this point, the altera_cvp module cannot be used to program this device via CvP. In addition no other module can use the device, as it is still registered by altera_cvp. Keywords: altera_cvp module, PCI, Configure-via-Protocol Kernel version: problem occured with v4.15, should occur from 4.14+ Instructions to reproduce: Proper hardware is necessary to reproduce this, i.e., FPGA with instantiated Altera/Intel PCIe IP Core with disabled CvP feature. Workaround: It is possible to circumvent this problem by manually unloading or blacklisting the altera_cvp module. Suggested Patch: This patch was successfully build and tested for 4.15 and 4.18 Subject: [PATCH] register device only, if it supports CvP operation This patch is based on: git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tag/?h=v4.18 Signed-off-by: Andreas Puhm --- drivers/fpga/altera-cvp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 7fa793672a7a..838abcfca0fb 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -403,6 +403,7 @@ static int altera_cvp_probe(struct pci_dev *pdev, struct altera_cvp_conf *conf; struct fpga_manager *mgr; u16 cmd, val; + u32 val32; int ret; /* @@ -416,6 +417,14 @@ static int altera_cvp_probe(struct pci_dev *pdev, return -ENODEV; } + pci_read_config_dword(pdev, VSE_CVP_STATUS, &val32); + if (!(val32 & VSE_CVP_STATUS_CVP_EN)) { + dev_err(&pdev->dev, + "CVP is disabled for this device: CVP_STATUS Reg 0x%x\n", + val32); + return -ENODEV; + } + conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL); if (!conf) return -ENOMEM; -- With best regards, Andreas Puhm