Skip to content

Comments

ref(riscv): refactor vimsic interrupt injection#310

Open
josecm wants to merge 1 commit intomainfrom
ref/riscv_aia_msi_injection
Open

ref(riscv): refactor vimsic interrupt injection#310
josecm wants to merge 1 commit intomainfrom
ref/riscv_aia_msi_injection

Conversation

@josecm
Copy link
Member

@josecm josecm commented Feb 5, 2026

This PR refactors APLIC MSI injection in IMSIC guest interrupt files and fixes two issues:

  1. The previous implementation assumed that MSI injection into a guest interrupt file always targeted the local vCPU. If the target vCPU was remote, it sent a CPU message to the target core so the MSI could be injected locally. However, the IMSIC MMIO interface allows a CPU to inject an MSI directly into a remote (i.e., different core) guest IMSIC via its MMIO interface. Supporting this requires:

    • Mapping guest interrupt files in the hypervisor.
    • Introducing a function that injects an MSI by writing to the appropriate guest interrupt file MMIO interface based on the target CPU and its assigned guest interrupt file.

    Alternatively, local vCPU injection could still use the AIA CSRs (as before). To simplify the code, this optimization is intentionally avoided for now. Future work may evaluate whether MMIO-based injection is sufficiently costly to justify reintroducing this optimization.

  2. On updates to APLIC registers, the previous implementation iterated over all APLIC interrupts to determine whether an MSI should be forwarded to a vCPU. In most cases (e.g., enabling a single interrupt), only one interrupt needs to be considered. This PR addresses the issue by adding a third argument to vaplic_update_hart, indicating whether the call was triggered by a single interrupt state update. If the interrupt ID is invalid (e.g., when triggered by a global vAPLIC control update), the logic falls back to scanning all interrupts for forwarding.

@josecm josecm force-pushed the ref/riscv_aia_msi_injection branch from be6d849 to 89b61e6 Compare February 5, 2026 14:33
Signed-off-by: Jose Martins <josemartins90@gmail.com>
@josecm josecm force-pushed the ref/riscv_aia_msi_injection branch from 89b61e6 to 2b296f4 Compare February 5, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant