angry-goose-initiative / wiki

AGI Wiki
0 stars 0 forks source link

Debug smode interrupts #43

Closed JZJisawesome closed 3 months ago

JZJisawesome commented 4 months ago

Things seem to be broken with delegating interrupts to s-mode.

I guess the kernel actually hasn't been using them for the timer either, but I discovered the issue when trying to get UART external interrupts stuffs working.

This goes hand in hand with the Seb's UART work. Unfortunately it now appears likely that use of a UART requires interrupts from it. This may complicate LETC slightly.

JZJisawesome commented 4 months ago

Sort-of-fixed in my branch, but I realized that just using the C interrupt handlers pushes registers to the kernel's sp rather than OGSBI's. This will need to be fixed.

Curiously adding the UART's parent interrupt as the m-mode and s-mode external interrupt bits in mip to the device tree causes us to encounter an ebreak (kernel bug) in the request_threaded_irq function. This needs investigation as well, as this is occuring even though no interrupt is actually firing (external, timer, or software).

JZJisawesome commented 4 months ago

Reason for the issue:

Program received signal SIGINT, Interrupt.
Cannot remove breakpoints because program is no longer writable.
Further execution is probably impossible.
request_threaded_irq (irq=1, handler=handler@entry=0xc01a87ac <serial8250_interrupt>, thread_fn=thread_fn@entry=0x0, irqflags=128, devname=0xc0806d08 "ttyS0", 
    dev_id=dev_id@entry=0xc081b8e0) at kernel/irq/manage.c:2181
2181                WARN_ON(irq_settings_is_per_cpu_devid(desc)))

Now to root cause it...

JZJisawesome commented 3 months ago

We're abandoning UART interrupts. Likely this was caused by linux probably mandating a plic/second level interrupt controller for external interrupts. Perhaps something to keep in mind for a future project...