cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
05bba0
From 46edd2ae852e19ee3a1b473be949691c6ce5694d Mon Sep 17 00:00:00 2001
05bba0
From: Alex Williamson <alex.williamson@redhat.com>
05bba0
Date: Fri, 1 May 2015 18:09:33 +0200
05bba0
Subject: [PATCH 09/14] vfio-pci: Further fix BAR size overflow
05bba0
05bba0
Message-id: <20150501180733.31334.63326.stgit@gimli.home>
05bba0
Patchwork-id: 64972
05bba0
O-Subject: [RHEL7.2 qemu-kvm PATCH 9/8] vfio-pci: Further fix BAR size overflow
05bba0
Bugzilla: 1181267
05bba0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
05bba0
RH-Acked-by: Bandan Das <bsd@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
Bugzilla: 1181267
05bba0
Upstream: 07ceaf98800519ef9c5dc893af00f1fe1f9144e4
05bba0
05bba0
In an analysis by Laszlo, the resulting type of our calculation for
05bba0
the end of the MSI-X table, and thus the start of memory after the
05bba0
table, is uint32_t.  We're therefore not correctly preventing the
05bba0
corner case overflow that we intended to fix here where a BAR >=4G
05bba0
could place the MSI-X table to end exactly at the 4G boundary.  The
05bba0
MSI-X table offset is defined by the hardware spec to 32bits, so we
05bba0
simply use a cast rather than changing data structure types.  This
05bba0
scenario is purely theoretically, typically the MSI-X table is located
05bba0
at the front of the BAR.
05bba0
05bba0
Reported-by: Laszlo Ersek <lersek@redhat.com>
05bba0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
05bba0
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
05bba0
---
05bba0
05bba0
Brew for series including 9 & 10:
05bba0
05bba0
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=9082147
05bba0
05bba0
 hw/misc/vfio.c |    2 +-
05bba0
 1 file changed, 1 insertion(+), 1 deletion(-)
05bba0
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 hw/misc/vfio.c | 2 +-
05bba0
 1 file changed, 1 insertion(+), 1 deletion(-)
05bba0
05bba0
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
05bba0
index cbc9d8a..e6f96db 100644
05bba0
--- a/hw/misc/vfio.c
05bba0
+++ b/hw/misc/vfio.c
05bba0
@@ -2634,7 +2634,7 @@ static void vfio_map_bar(VFIODevice *vdev, int nr)
05bba0
     if (vdev->msix && vdev->msix->table_bar == nr) {
05bba0
         uint64_t start;
05bba0
 
05bba0
-        start = TARGET_PAGE_ALIGN(vdev->msix->table_offset +
05bba0
+        start = TARGET_PAGE_ALIGN((uint64_t)vdev->msix->table_offset +
05bba0
                                   (vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
05bba0
 
05bba0
         size = start < bar->size ? bar->size - start : 0;
05bba0
-- 
05bba0
1.8.3.1
05bba0