Page MenuHomeFreeBSD

riscv vmm: various fixes in APLIC
ClosedPublic

Authored by br on Feb 3 2025, 12:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 9, 8:45 AM
Unknown Object (File)
Sat, Mar 8, 4:16 AM
Unknown Object (File)
Fri, Mar 7, 10:34 PM
Unknown Object (File)
Fri, Mar 7, 12:33 AM
Unknown Object (File)
Wed, Mar 5, 11:33 AM
Unknown Object (File)
Wed, Mar 5, 7:22 AM
Unknown Object (File)
Tue, Mar 4, 5:56 PM
Unknown Object (File)
Sat, Mar 1, 7:36 PM
Subscribers

Details

Summary
  • Implement level-sensitive interrupts
  • Disable up to 32 interrupts by a single query (CLRIE register handling)
  • Implement reading from DOMAINCFG

This is a minimal set of changes needed to boot Linux guest.

More work TODO to handle other APLIC registers read/write.

Test Plan

Linux booting in 0.48s with this. FreeBSD also speeds up for some reason

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

br requested review of this revision.Feb 3 2025, 12:14 PM
sys/riscv/vmm/vmm_aplic.c
184
186

Do you want to check the return value here?

306

Why isn't the mutex required here?

Add spinlock around DOMAINCFG acccess.

sys/riscv/vmm/vmm_aplic.c
186

Do you want to check the return value here?

from the spec the write is ignored if value written is not an active interrupt source number in the domain
https://github.com/riscv/riscv-aia/releases/download/0.2-draft.24/riscv-interrupts-024.pdf

306

Indeed. Added!

sys/riscv/vmm/vmm_aplic.c
158

Why not just

if ((irq->sourcecfg & SOURCECFG_SM_M) != SOURCECFG_SM_INACTIVE) {
    if (enabled)
        ...
}

?

184

This change is required to avoid UB.

186

This would be useful to mention in a comment, along with a (void) cast for the aplic_set_enabled() call.

Address @markj comments. Thanks, Mark!

This revision was not accepted when it landed; it landed in state Needs Review.Feb 5 2025, 9:35 AM
This revision was automatically updated to reflect the committed changes.