From 00c0b9e17065a28785a8fb1dbcbf83af52e4ebfe Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 6 Oct 2020 15:57:45 +0100 Subject: [PATCH] devices: ioapic: Tolerate Windows writing zero to version register Windows will write zero to the IOAPIC version register as part of probing if the device is there. Fixes: #1791 Signed-off-by: Rob Bradford --- devices/src/ioapic.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/devices/src/ioapic.rs b/devices/src/ioapic.rs index bb3a904ba..283f645ed 100644 --- a/devices/src/ioapic.rs +++ b/devices/src/ioapic.rs @@ -214,6 +214,16 @@ impl Ioapic { debug!("IOAPIC_W reg 0x{:x}, val 0x{:x}", self.reg_sel, val); match self.reg_sel as u8 { + IOAPIC_REG_VERSION => { + if val == 0 { + // Windows writes zero here (see #1791) + } else { + error!( + "IOAPIC: invalid write to version register (0x{:x}): 0x{:x}", + self.reg_sel, val + ); + } + } IOAPIC_REG_ID => self.id_reg = (val >> 24) & 0xf, IOWIN_OFF..=REG_MAX_OFFSET => { let (index, is_high_bits) = decode_irq_from_selector(self.reg_sel as u8); @@ -235,7 +245,10 @@ impl Ioapic { // Store the information this IRQ is now being used. self.used_entries[index] = true; } - _ => error!("IOAPIC: invalid write to register offset"), + _ => error!( + "IOAPIC: invalid write to register offset 0x{:x}", + self.reg_sel + ), } } @@ -254,7 +267,10 @@ impl Ioapic { } } _ => { - error!("IOAPIC: invalid read from register offset"); + error!( + "IOAPIC: invalid read from register offset 0x{:x}", + self.reg_sel + ); 0 } }