From 072d5ae3308bbf69d57a9bc987626fd423ecee47 Mon Sep 17 00:00:00 2001 From: joevt Date: Fri, 2 Sep 2022 00:54:08 -0700 Subject: [PATCH] Fix Expansion ROM BAR writes The bits that can be set are the enable bit (bit 0) plus the bits represented by exp_bar_cfg which is determined by the size of the ROM which is calculated to be a power of 2 and a minimum of 2K. --- devices/common/pci/pcidevice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devices/common/pci/pcidevice.cpp b/devices/common/pci/pcidevice.cpp index 53d7de8..ea060b0 100644 --- a/devices/common/pci/pcidevice.cpp +++ b/devices/common/pci/pcidevice.cpp @@ -137,10 +137,10 @@ void PCIDevice::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size) } break; case PCI_CFG_ROM_BAR: - if (data == 0xFFFFF800UL) { - this->exp_rom_bar = this->exp_bar_cfg; + if ((data & this->exp_bar_cfg) == this->exp_bar_cfg) { + this->exp_rom_bar = (data & (this->exp_bar_cfg | 1)); } else { - this->exp_rom_bar = (data & 0xFFFFF801UL); + this->exp_rom_bar = (data & (this->exp_bar_cfg | 1)); if (this->exp_rom_bar & 1) { this->map_exp_rom_mem(); } else { @@ -257,7 +257,7 @@ void PCIDevice::map_exp_rom_mem() { uint32_t rom_addr, rom_size; - rom_addr = this->exp_rom_bar & 0xFFFFF800UL; + rom_addr = this->exp_rom_bar & this->exp_bar_cfg; rom_size = ~this->exp_bar_cfg + 1; if (!this->exp_rom_addr || this->exp_rom_addr != rom_addr) {