aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2023-05-18 21:36:50 +0200
committerMartin Mares <mj@ucw.cz>2023-12-29 14:30:02 +0100
commit93c1c6bcc9e2b52652b859986354ddd54ef34058 (patch)
treebc34f12119c3bf55c31e67ad9cfa7e7896c1bdf6
parentd4d889711556eaea294ca52a9a1d539a7d505d93 (diff)
downloadpciutils-93c1c6bcc9e2b52652b859986354ddd54ef34058.tar.gz
libpci: ecam: Fix big address range mappings
If more buses span continuous address space then there can be up to the 256 MB long address range which ecam backend tries to map. Such huge space cannot be mapped on some memory limited systems. And also it is not needed to map whole 256 MB long address range because ecam backend cache uses mapping only for one bus. One bus has maximal mapping size just 32*8*4096 bytes. So adjust size calculation when mapping ecam bus.
-rw-r--r--lib/ecam.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ecam.c b/lib/ecam.c
index f4d2e9b..e2b9412 100644
--- a/lib/ecam.c
+++ b/lib/ecam.c
@@ -630,6 +630,9 @@ calculate_bus_addr(u8 start_bus, off_t start_addr, u32 total_length, u8 bus, off
*addr = start_addr + offset;
*length = total_length - offset;
+ if (*length > 32*8*4096)
+ *length = 32*8*4096;
+
return 1;
}