瀏覽代碼

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 年之前
父節點
當前提交
68169b820d
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      examples/aarch64/src/main.rs

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

@@ -262,7 +262,14 @@ impl PciMemory32Allocator {
                 cpu_physical,
                 cpu_physical,
                 size,
                 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);
                 assert_eq!(bus_address, cpu_physical);
                 memory_32_address = u32::try_from(cpu_physical).unwrap();
                 memory_32_address = u32::try_from(cpu_physical).unwrap();
                 memory_32_size = u32::try_from(size).unwrap();
                 memory_32_size = u32::try_from(size).unwrap();