You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We go through `pci_config_space_address`, which makes sure the physical addresses are valid
197
196
let pci_start = self.pci_config_space_address(0,0,0).as_u64();
198
197
let pci_end = self.pci_config_space_address(PCI_MAX_BUS_NUMBER, u8::MAX, u8::MAX).as_u64() + 0x1000;
198
+
let pci_range = pci_start..pci_end;
199
199
200
200
let all_memory_regions = fdt
201
201
.find_all_nodes("/memory")
@@ -204,13 +204,11 @@ mod pcie {
204
204
for mem_region in all_memory_regions {
205
205
let region_start = u64::try_from(mem_region.starting_address.addr()).unwrap();
206
206
let region_end = region_start + u64::try_from(mem_region.size.expect("found a memory region with no declared size")).unwrap();
207
+
let region_range = region_start..region_end;
207
208
208
-
if
209
-
(pci_start >= region_start && pci_start <= region_end)// PCI region starts within the memory region
210
-
|| (pci_end >= region_start && pci_end <= region_end)// PCI region ends within the memory region
211
-
|| (pci_start <= region_start && pci_end >= region_end)// PCI region contains the memory region
212
-
{
213
-
error!("The declared PCI region {pci_start:x}-{pci_end:x} may overlap with physical memory region {region_start:x}-{region_end:x}");
209
+
let intersection = region_range.intersect(pci_range);
210
+
if !intersection.is_empty(){
211
+
error!("The declared PCI region {pci_start:x}-{pci_end:x} overlaps with physical memory region {region_start:x}-{region_end:x}. Intersection: {intersection:?}");
0 commit comments