Skip to content

Commit

Permalink
Fixed MADT iteration infinity loop
Browse files Browse the repository at this point in the history
  • Loading branch information
bagggage committed Sep 28, 2024
1 parent 31ae5d0 commit 05d2f23
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kernel/arch/x86-64/intr/apic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ pub const Madt = extern struct {

while (@intFromPtr(entry) < end_addr)
: (entry = @ptrFromInt(@intFromPtr(entry) + entry.length)) {
// Don`t trust hardware, avoid infinity loop
if (entry.length == 0) break;

if (entry.type == ent_type) return entry;
}

Expand Down Expand Up @@ -105,7 +108,7 @@ pub inline fn getMadt() *Madt {
}

inline fn isAvail() bool {
return (arch.cpuid(arch.cpuid_features).d & c.bit_APIC) != 0;
return (arch.cpuid(arch.cpuid_features, undefined, undefined, undefined).d & c.bit_APIC) != 0;
}

fn bindIrq(irq: *const intr.Irq) void {
Expand Down

0 comments on commit 05d2f23

Please sign in to comment.