lkml.org 
[lkml]   [2021]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] vfio/pci: Sanity check IGD OpRegion Size
From
Date
The size field of the IGD OpRegion table is supposed to indicate table
size in KB, but we've seen at least one report of a BIOS that appears
to incorrectly report size in bytes. The default size is 8 (*1024 =
8KB), but an incorrect implementation may report 8192 (*1024 = 8MB)
and can cause a variety of mapping errors.

It's believed that 8MB would be an implausible, if not absurd, actual
size, so we can probably be pretty safe in assuming this is a BIOS bug
where the intended size is likely 8KB.

Reported-by: Travis Faulhaber <tkffaul@outlook.com>
Tested-by: Travis Faulhaber <tkffaul@outlook.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/vfio/pci/vfio_pci_igd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
index 228df565e9bc..c89a4797cd18 100644
--- a/drivers/vfio/pci/vfio_pci_igd.c
+++ b/drivers/vfio/pci/vfio_pci_igd.c
@@ -86,7 +86,16 @@ static int vfio_pci_igd_opregion_init(struct vfio_pci_device *vdev)
return -EINVAL;
}

- size *= 1024; /* In KB */
+ /*
+ * The OpRegion size field is specified as size in KB, but there have been
+ * user reports where this field appears to report size in bytes. If we
+ * read 8192, assume this is the case.
+ */
+ if (size == OPREGION_SIZE)
+ pci_warn(vdev->pdev,
+ "BIOS Bug, IGD OpRegion reports invalid size, assuming default 8KB\n");
+ else
+ size *= 1024; /* In KB */

/*
* Support opregion v2.1+

\
 
 \ /
  Last update: 2021-05-07 20:54    [W:0.242 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site