diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index 2a905e19b..8973c3883 100644 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -987,7 +987,7 @@ impl PciConfiguration { return None; } - let bar_idx = reg_idx - 4; + let bar_idx = reg_idx - BAR0_REG; // Handle special case where the address being written is // different from the address initially provided. This is a // BAR reprogramming case which needs to be properly caught. @@ -1025,7 +1025,7 @@ impl PciConfiguration { len, region_type, }); - } else if (reg_idx > BAR0_REG) + } else if (bar_idx > 0) && ((self.registers[reg_idx - 1] & self.writable_bits[reg_idx - 1]) != (self.bars[bar_idx - 1].addr & self.writable_bits[reg_idx - 1]) || (value & mask) != (self.bars[bar_idx].addr & mask))