Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp10461ybt; Tue, 23 Jun 2020 13:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz/A+JMS1iyHNuLmjhqv9hfwdpt65rTaPqF6ZC740bCHjOBmdLb2zirnWQgLEHnSI6p+sH X-Received: by 2002:a05:6402:1d86:: with SMTP id dk6mr4751110edb.108.1592945786078; Tue, 23 Jun 2020 13:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592945786; cv=none; d=google.com; s=arc-20160816; b=BVi3EIX+9MRIgoureLXphRLSd++vAoCrGYbb35a5kXIw6ZwyPuZ40YmJoRdQKaAPR5 lGQIHRVpAwDbVxNmOUQF29ZGxCemBaqpf4gfZ2tmzukIOTj8UvKiacZ6j7E7UsAd2FZY 5WahaXm5Z03h/ubBMfiT2iAkFtZTQZzLzuYYWyh5g2Sj5UGj6/MhVw8TiCbJN+Gl58K2 EO8DFUKXCx3safGqLvTaU//hd+F0UEFNhuky80H84O2R5tT570Cw3d0jSv6ZGH5Zb/1v xgWw6Ylf7urQJD/PrUigmDiqbZ4BZMaITdRytNbhTBVp+VpyYLVQQGmwgFpouDYflsJX wcIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WhQaV78psbQWTbzQreD38R9L/8ZSlEqYW4phIM7lGPA=; b=nxb14UOyqxZ6QH0pH31lqyiPFyaEnVyeMg9nvTmjIXj27VEQkBACVZ02EiwNuFYdiG uKBywmPpayBub+KGQs0WamTLzzcu+TT28Qze26ajtDQx7pfbfSHLGMFFUs+8v6aXscbR xxcBkPimrVWiW0AMEawE1gPbKRwzNsy1+33n8vXpjea5Ansx5EyvTtGBlYq1el1HVb4x +R7tATbe0coDgAZU0sWIdqQ+FbX9UCjKesUhFv2dlkaMYLMt5fr5ZmPUQGRVhjv4hYTZ 6cvXAKrRYd6EEOIJjVQAgeCD1qgwIKwyfO6WSgV2f87LLXuPz753X6Y4T4x8jn9Yu7nM 6OWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qo87JOGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv10si79981ejb.373.2020.06.23.13.56.01; Tue, 23 Jun 2020 13:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qo87JOGE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392779AbgFWUp6 (ORCPT + 99 others); Tue, 23 Jun 2020 16:45:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392786AbgFWUpy (ORCPT ); Tue, 23 Jun 2020 16:45:54 -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 A851620656; Tue, 23 Jun 2020 20:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945155; bh=wicaoCAJNuk7XntjN2HU1xs0spmHSn5Q2EMQqELHpJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qo87JOGE2/PPOX5IgETZs72tWFlAhpGFJHxMrRhyo/tQzxLcHq5ti2j9JFnlZWZ6k 1CHqec7lAYmYYFiWNyNJRMBlvnVIj3J97+f2cqClArfYSd6W6s+pmwfOJ2xU+ICn9B Gy09AmYmTQrzNaAKvAG/jMGtNSLPPx1GrsmJ+ctA= 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 4.14 060/136] vfio-pci: Mask cap zero Date: Tue, 23 Jun 2020 21:58:36 +0200 Message-Id: <20200623195306.701731577@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 c2d300bc37f64..36bc8f104e42e 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -1464,7 +1464,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); -- 2.25.1