提交 c1ebe562 编写于 作者: A Alex Williamson 提交者: Xibo.Wang

vfio-pci: Mask cap zero

mainline inclusion
from mainline-v5.8
commit bc138db1
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WW3D
CVE: NA

--------------------------------

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: NCornelia Huck <cohuck@redhat.com>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NXibo.Wang <wangxb12@chinatelecom.cn>
上级 b2297d93
......@@ -1494,7 +1494,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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册