From 81f8976500ddd4f31dd141e007df23e355f08a17 Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 21 Jul 2022 22:05:22 +0900 Subject: [PATCH] pci: Don't allow mapping to isa ports --- src/pci.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pci.js b/src/pci.js index 0903c15b..f708f7c7 100644 --- a/src/pci.js +++ b/src/pci.js @@ -547,7 +547,11 @@ PCI.prototype.set_io_bars = function(bar, from, to) for(var i = 0; i < count; i++) { var old_entry = ports[from + i]; - ports[from + i] = this.io.create_empty_entry(); + + if(from + i >= 0x1000) + { + ports[from + i] = this.io.create_empty_entry(); + } if(old_entry.read8 === this.io.empty_port_read8 && old_entry.read16 === this.io.empty_port_read16 && @@ -556,6 +560,7 @@ PCI.prototype.set_io_bars = function(bar, from, to) old_entry.write16 === this.io.empty_port_write && old_entry.write32 === this.io.empty_port_write) { + // happens when a device doesn't register its full range (currently ne2k and virtio) dbg_log("Warning: Bad IO bar: Source not mapped, port=" + h(from + i, 4), LOG_PCI); } @@ -563,7 +568,10 @@ PCI.prototype.set_io_bars = function(bar, from, to) var empty_entry = ports[to + i]; dbg_assert(entry && empty_entry); - ports[to + i] = entry; + if(to + i >= 0x1000) + { + ports[to + i] = entry; + } if(empty_entry.read8 === this.io.empty_port_read8 || empty_entry.read16 === this.io.empty_port_read16 ||