From patchwork Tue Jun 23 19:55:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BC0C433E2 for ; Tue, 23 Jun 2020 20:27:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9988206C3 for ; Tue, 23 Jun 2020 20:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944054; bh=k8S4qt5sZ4V6p02+ugnEr7tIVmSWgelLF3gP97onpRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=flWy04atpA1Ar3o8zd9hLOMavoy1JrKDjk9NlTj2iIVuV7sawJHu0v1SzSVOdZnZf Kta151g2wNbE1yhGjoURhwsGMkiutzuXqv/pi8iBzhCJLl41+1ZtWEUEuY3tS7HTf5 Pb47cmsKv79xdqEbjfAZVA59ZmV2Ldir38xW+JPI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390743AbgFWU1d (ORCPT ); Tue, 23 Jun 2020 16:27:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:47032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388177AbgFWU12 (ORCPT ); Tue, 23 Jun 2020 16:27:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28D0920780; Tue, 23 Jun 2020 20:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944048; bh=k8S4qt5sZ4V6p02+ugnEr7tIVmSWgelLF3gP97onpRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ylGsmLLrm7m8ebPGeQmJKnZ0YeLLj3wLCw7D5xhb7Fw3kBFYmeEgZ3BEI/8QLhngr LAK5yJ1EDBZSp0lY2bx/TBPG0ZpwTuFJHC26/dj3j/GWE1JqzvMcId7DmjFvC/A2Su eFxKsxDmXZPuC4epf4R9Z8CkjTbVVQ0ENk1ai2GE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cornelia Huck , Alex Williamson , Sasha Levin Subject: [PATCH 5.4 152/314] vfio-pci: Mask cap zero Date: Tue, 23 Jun 2020 21:55:47 +0200 Message-Id: <20200623195346.107512109@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alex Williamson [ Upstream commit bc138db1b96264b9c1779cf18d5a3b186aa90066 ] The PCI Code and ID Assignment Specification changed capability ID 0 from reserved to a NULL capability in the v1.1 revision. The NULL capability is defined to include only the 16-bit capability header, ie. only the ID and next pointer. Unfortunately vfio-pci creates a map of config space, where ID 0 is used to reserve the standard type 0 header. Finding an actual capability with this ID therefore results in a bogus range marked in that map and conflicts with subsequent capabilities. As this seems to be a dummy capability anyway and we already support dropping capabilities, let's hide this one rather than delving into the potentially subtle dependencies within our map. Seen on an NVIDIA Tesla T4. Reviewed-by: Cornelia Huck Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/vfio/pci/vfio_pci_config.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index c4d0cf9a1ab94..d6359c37c9e55 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -1460,7 +1460,12 @@ static int vfio_cap_init(struct vfio_pci_device *vdev) if (ret) return ret; - if (cap <= PCI_CAP_ID_MAX) { + /* + * ID 0 is a NULL capability, conflicting with our fake + * PCI_CAP_ID_BASIC. As it has no content, consider it + * hidden for now. + */ + if (cap && cap <= PCI_CAP_ID_MAX) { len = pci_cap_length[cap]; if (len == 0xFF) { /* Variable length */ len = vfio_cap_len(vdev, cap, pos);