Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3035599ybt; Mon, 29 Jun 2020 13:31:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTil3vGGbn3L51e9HIL9xgh7EFOF37FIVM6V9htAghyOstqaj/429f1qYgFVnCZ9GNNgJy X-Received: by 2002:a17:906:fac3:: with SMTP id lu3mr7771122ejb.374.1593462695469; Mon, 29 Jun 2020 13:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593462695; cv=none; d=google.com; s=arc-20160816; b=Zq3LY0q0Vm1+mjQVhPg2+jqBYM+FzqJEXEQCnwLcg6j2V/FEajggA9rkzNi0K3BbAz JcgIijMzhZolKcRWPMcLvnPcAdjRLP+Y0E/H0W1N1295zZGbTfF3vASBLSlfzOng4kNr 2UzjLkpvBE3bHXD4zWvGN2buP6PscfA+AWccVy7wLuGAPQQhPWJgssP9ghckslmXN/VO SrAkG24klAFqZyrReeIy6sEthbP/v5QQYAVZNHfXHvbZGxuOt+jFpYcZ8jUwHeW/Xbrd OKzQHUWL57niqjoB7IP68Oxk/yFoa7K40cyM0rwrgB5hnE5MXL3Gru335QhgmXnA3/lM 6elw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0BsfwC/uvxD8FYDsIhMNCDpgi0QSHwfqeu9klthpdBo=; b=xW3pGHnOQ0zbmxhwB4HDXqvpOe7c4vFGjfSS8MIDOCYLUyyFNBxnqe52/ByZ13pt3Z uKhq/z4olzPvJR0c/D8uVUpMd0qkAtA6VFTVjR+JrdFS9fo96XNARuHEXkRrgb7qrlnA P8KZ62MbRELsiByhfuR9iiUTBYSk8J/AmEmyEDei/HaKWoSSnZm34rB18t53gvfguKKw MBYKwYKF1ss8nmcnztb9tEUY6SookefJ0oU5gPN/YzQDiRIqzLhnS7OtpSQLs7TM/QVU SOgTqUjGj8keOBGRRGVSx867sHGuCkqqSrcwjhf4JXt6QRyBJeWy7j4VJafW8VjyPA2G Vo/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wpc6pJUK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz2si455065ejb.70.2020.06.29.13.31.12; Mon, 29 Jun 2020 13:31:35 -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=Wpc6pJUK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389055AbgF2U3z (ORCPT + 99 others); Mon, 29 Jun 2020 16:29:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:37042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732494AbgF2TZV (ORCPT ); Mon, 29 Jun 2020 15:25:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC43925398; Mon, 29 Jun 2020 15:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593445263; bh=o/qUZQFam9A5VJ5KITQFxGBldNgpWr/uOXYmmbB8AaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wpc6pJUKGmEvGQ0IugRF3UTeb4TvsdsX9zXchdHX9V1+8c6gIInv/35JBZD24WdrU /aexJnHEQJ4XJiKobAn7TTavc7G9kGUex9+UTQw1AIg4uDX0ksnzFvfEnS4WOx2mol IR2EWjhZBHRT28WjHApetKMtjPcIDGDop1n7krL4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alex Williamson , Cornelia Huck , Sasha Levin Subject: [PATCH 4.9 044/191] vfio-pci: Mask cap zero Date: Mon, 29 Jun 2020 11:37:40 -0400 Message-Id: <20200629154007.2495120-45-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629154007.2495120-1-sashal@kernel.org> References: <20200629154007.2495120-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.229-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.229-rc1 X-KernelTest-Deadline: 2020-07-01T15:39+00:00 X-stable: review X-Patchwork-Hint: Ignore 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 608b94a0ee0e0..ef45b8f5bf510 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -1461,7 +1461,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