diff options
author | Evgeny Yakovlev <wrfsh@yandex-team.ru> | 2019-07-18 19:14:23 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2019-07-25 04:17:35 -0400 |
commit | 21e2acd583126db94f6d881005cd58e835160582 (patch) | |
tree | 53f19e1d19d5bfdb9646d940e8918df8cc7890d9 /hw | |
parent | df98d7ccc2e9e3e5080cce30a6d9c09dd827dc15 (diff) | |
download | qemu-21e2acd583126db94f6d881005cd58e835160582.zip qemu-21e2acd583126db94f6d881005cd58e835160582.tar.gz qemu-21e2acd583126db94f6d881005cd58e835160582.tar.bz2 |
i386/acpi: fix gint overflow in crs_range_compare
When very large regions (32GB sized in our case, PCI pass-through of GPUs)
are compared substraction result does not fit into gint.
As a result crs_replace_with_free_ranges does not get sorted ranges and
incorrectly computes PCI64 free space regions. Which then makes linux
guest complain about device and PCI64 hole intersection and device
becomes unusable.
Fix that by returning exactly fitting ranges.
Also fix indentation of an entire crs_replace_with_free_ranges to make
checkpatch happy.
Cc: qemu-stable@nongnu.org
Signed-off-by: Evgeny Yakovlev <wrfsh@yandex-team.ru>
Message-Id: <1563466463-26012-1-git-send-email-wrfsh@yandex-team.ru>
Signed-off-by: Evgeny Yakovlev <wrfsh@yandex-team.ru>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/i386/acpi-build.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d281ffa..e7b756b 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -755,10 +755,16 @@ static void crs_range_set_free(CrsRangeSet *range_set) static gint crs_range_compare(gconstpointer a, gconstpointer b) { - CrsRangeEntry *entry_a = *(CrsRangeEntry **)a; - CrsRangeEntry *entry_b = *(CrsRangeEntry **)b; + CrsRangeEntry *entry_a = *(CrsRangeEntry **)a; + CrsRangeEntry *entry_b = *(CrsRangeEntry **)b; - return (int64_t)entry_a->base - (int64_t)entry_b->base; + if (entry_a->base < entry_b->base) { + return -1; + } else if (entry_a->base > entry_b->base) { + return 1; + } else { + return 0; + } } /* |