From 7d8b7501ba0bab073c8e173bf78e79c1bcd0a257 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 22 Sep 2018 16:42:34 -0400 Subject: [PATCH] kernel: Treat 255 as an invalid interrupt line on x86. From mmlr's analysis in #13370 comment:22: "We actually do ignore a missing routing in case the interrupt line is 0. In this case it isn't 0 but 0xff, which is invalid and generally treated the same as 0 in the rest of the code. Ignoring the missing routing on 0xff seems like the way to go here." Indeed, I managed to locate a footnote in the PCI 3.0 specification which confirms that this is the case on x86, and a commit in the Linux kernel which essentially does the same thing this change does: https://github.com/torvalds/linux/commit/e237a5518425155faa508a087f2826 Interestingly, that commit is only from 2016, while PCI 3.0 is from 2004. This probably fixes #13370 ("Haiku doesn't MBR boot on Ryzen"), and potentially other interrupt-routing-related boot failures. Change-Id: I88129f6507c62d24cb50cf5c78597ca7bd7872d7 Reviewed-on: https://review.haiku-os.org/590 Reviewed-by: waddlesplash --- src/system/kernel/arch/x86/irq_routing_table.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/arch/x86/irq_routing_table.cpp b/src/system/kernel/arch/x86/irq_routing_table.cpp index c442fac456..578896baef 100644 --- a/src/system/kernel/arch/x86/irq_routing_table.cpp +++ b/src/system/kernel/arch/x86/irq_routing_table.cpp @@ -578,8 +578,11 @@ ensure_all_functions_matched(pci_module_info* pci, uint8 bus, } if (!matched) { - if (pci->read_pci_config(bus, device, function, - PCI_interrupt_line, 1) == 0) { + uint32 interrupt_line = pci->read_pci_config(bus, device, + function, PCI_interrupt_line, 1); + // On x86, interrupt line 255 means "unknown" or "no connection" + // (PCI Local Bus spec 3.0, section 6.2.4 / page 223, footnote.) + if (interrupt_line == 0 || interrupt_line == 255) { dprintf("assuming no interrupt use on PCI device" " %u:%u:%u (bios irq 0, no routing information)\n", bus, device, function);