:: commit 7d11e911801254444c23bfaa57f1be3322987c95

mintsuki <mintsuki@protonmail.com> — 2023-10-23 03:11

parents: db8783ca09

limine/ioapic: Change spec to avoid masking IOAPIC RTEs unless Fixed or Lowest Priority

diff --git a/PROTOCOL.md b/PROTOCOL.md
index 18dd055f..77b609ca 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -197,7 +197,8 @@ If 5-level paging is requested and available, then 5-level paging is enabled
 
 The A20 gate is opened.
 
-Legacy PIC and IO APIC IRQs are all masked.
+Legacy PIC (if available) and IO APIC IRQs (only those with delivery mode fixed
+(0b000) or lowest priority (0b001)) are all masked.
 
 If booted by EFI/UEFI, boot services are exited.
 
diff --git a/common/sys/lapic.c b/common/sys/lapic.c
index 13e2d3fd..e68585f6 100644
--- a/common/sys/lapic.c
+++ b/common/sys/lapic.c
@@ -156,6 +156,14 @@ void io_apic_mask_all(void) {
         uint32_t gsi_count = io_apic_gsi_count(i);
         for (uint32_t j = 0; j < gsi_count; j++) {
             uintptr_t ioredtbl = j * 2 + 16;
+            switch ((io_apic_read(i, ioredtbl) >> 8) & 0b111) {
+                case 0b000: // Fixed
+                case 0b001: // Lowest Priority
+                    break;
+                default:
+                    continue;
+            }
+
             io_apic_write(i, ioredtbl, (1 << 16)); // mask
             io_apic_write(i, ioredtbl + 1, 0);
         }
tab: 248 wrap: offon