cryptospore / rpms / qemu-kvm

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