Files
RedBear-OS/local/patches/kernel/P9-ioapic-irq-affinity.patch
T
vasilito cee25393d8 fix: boot process improvements — dependency cycle, INIT_NOTIFY, probing loop, and log spam fixes
- Fix P15-8-init-cycle-detection.patch: replace visiting+error with seen+silent-skip
  to eliminate 11 false-positive 'dependency cycle detected' errors on shared deps
- Fix P0-daemon-fix-init-notify-unwrap.patch: remove eprintln! for missing
  INIT_NOTIFY (expected for oneshot_async services, ~7 daemons affected)
- Fix driver-manager hotplug loop: add PERMANENTLY_SKIPPED static set shared
  between hotplug handler and DriverConfig::probe() to stop infinite re-probing
  of Fatal/NotSupported/deferred-exhausted device+driver pairs (e.g. ided)
- Fix driver-manager log_timeline: suppress repeated EPIPE/ENOENT errors with
  AtomicI32 dedup and AtomicBool one-shot guards for boot timeline JSON
- Add driver-manager SIGTERM handler, ACPI bus registration, --status mode,
  driver reap loop, graceful shutdown, and reduced deferred retries (30→3)
2026-05-17 12:34:02 +03:00

40 lines
1.5 KiB
Diff

--- a/src/arch/x86_shared/device/ioapic.rs
+++ b/src/arch/x86_shared/device/ioapic.rs
@@ -120,6 +120,21 @@
reg |= u64::from(mask) << 16;
let _ = guard.write_ioredtbl(idx, reg);
}
+ /// Change the destination APIC for a GSI by reprogramming the redirection table entry.
+ /// Preserves all other fields (vector, polarity, trigger mode, delivery mode, mask).
+ /// Returns true if the entry was successfully updated.
+ pub fn set_irq_affinity(&self, gsi: u32, dest: ApicId) -> bool {
+ let idx = (gsi - self.gsi_start) as u8;
+ let mut guard = self.regs.lock();
+ let Some(mut entry) = guard.read_ioredtbl(idx) else {
+ return false;
+ };
+ // Clear destination field (bits 63:56 for xAPIC physical mode)
+ // and set new destination APIC ID
+ entry &= !(0xFF_u64 << 56);
+ entry |= u64::from(dest.get()) << 56;
+ guard.write_ioredtbl(idx, entry)
+ }
}
#[repr(u8)]
@@ -474,3 +489,14 @@
};
apic.set_mask(gsi, false);
}
+
+/// Change the destination CPU for an IRQ by reprogramming the IOAPIC redirection entry.
+/// Resolves the legacy IRQ to its GSI, finds the owning IOAPIC, and updates the destination
+/// APIC ID in the redirection table while preserving all other fields.
+pub unsafe fn set_affinity(irq: u8, dest: ApicId) -> bool {
+ let gsi = resolve(irq);
+ match find_ioapic(gsi) {
+ Some(apic) => apic.set_irq_affinity(gsi, dest),
+ None => false,
+ }
+}