]> mj.ucw.cz Git - pciutils.git/commitdiff
libpci: ecam: Fix big address range mappings
authorPali Rohár <pali@kernel.org>
Thu, 18 May 2023 19:36:50 +0000 (21:36 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 29 Dec 2023 13:30:02 +0000 (14:30 +0100)
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.

lib/ecam.c

index f4d2e9b6a3906c6c57050614072824e9efd8686d..e2b941246d09224da5e64bbb1e4db19c05a58b17 100644 (file)
@@ -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;
 }