Pārlūkot izejas kodu

Use 64-bit memory range for 32-bit BARs if it is low enough.

This is necessary under crosvm because it doesn't provide any 32-bit
ranges.
Andrew Walbran 2 gadi atpakaļ
vecāks
revīzija
68169b820d
1 mainītis faili ar 8 papildinājumiem un 1 dzēšanām
  1. 8 1
      examples/aarch64/src/main.rs

+ 8 - 1
examples/aarch64/src/main.rs

@@ -262,7 +262,14 @@ impl PciMemory32Allocator {
                 cpu_physical,
                 size,
             );
-            if range_type == PciRangeType::Memory32 && size > memory_32_size.into() {
+            // Use the largest range within the 32-bit address space for 32-bit memory, even if it
+            // is marked as a 64-bit range. This is necessary because crosvm doesn't currently
+            // provide any 32-bit ranges.
+            if !prefetchable
+                && matches!(range_type, PciRangeType::Memory32 | PciRangeType::Memory64)
+                && size > memory_32_size.into()
+                && bus_address + size < u32::MAX.into()
+            {
                 assert_eq!(bus_address, cpu_physical);
                 memory_32_address = u32::try_from(cpu_physical).unwrap();
                 memory_32_size = u32::try_from(size).unwrap();