Fix issues with vGIC LR management#334
Open
josecm wants to merge 7 commits into
Open
Conversation
When a guest disables an interrupt that is currently active in an LR, vgic_route() and vgic_add_lr() were returning early due to the !interrupt->enabled check, leaving the interrupt untracked. On re-enable, Bao would re-inject it as active causing incorrect state. Allow disabled-but-active interrupts through so the guest can EOI them directly via the LR, avoiding a spurious LRENP maintenance interrupt trap. Signed-off-by: Jose Martins <josemartins90@gmail.com>
vgic_eoir_highest_spilled_active() was clearing the ACT state of the highest-priority spilled active interrupt but never removing it from the spilled list, causing it to be re-processed on subsequent maintenance interrupts or LR refills. Add list_rm() after gaining ownership. vgic_spilled_lock is held around the search and removal; it is released before vgic_add_lr() to avoid a deadlock with vgic_add_spilled() on the SW+PEND path. Signed-off-by: Jose Martins <josemartins90@gmail.com>
When vgic_route() fails to place an interrupt in an LR or forward it to another CPU (e.g. no target configured), the interrupt was left untracked — not in any LR and not in the spilled list — causing it to be missed on future LR refills. Add in_spilled flag to vgic_int to prevent double-adds. vgic_add_spilled() guards on !in_lr && !in_spilled, and clears/sets the flag alongside list operations. vgic_route() unconditionally calls vgic_add_spilled() as a fallback after routing, which is a no-op if the interrupt was already placed in an LR or spilled by vgic_add_lr(). Signed-off-by: Jose Martins <josemartins90@gmail.com>
When vgic_add_lr() successfully placed an interrupt into an LR, it left a stale entry in the spilled list, causing vgic_refill_lrs() to find and attempt to re-process an already-tracked interrupt. Introduce vgic_remove_spilled() to wrap list_rm() and the in_spilled flag update in one place. Call it in vgic_add_lr() before vgic_write_lr(), and replace the open-coded equivalents in vgic_refill_lrs() and vgic_eoir_highest_spilled_active(). Drop the now-unused outlist parameter from vgic_highest_prio_spilled(). Signed-off-by: Jose Martins <josemartins90@gmail.com>
Sending an IPI for an active interrupt is pointless: vgic_yield_ownership() refuses to yield ownership while the interrupt is active, so the receiving CPU will fail to acquire ownership and do nothing. Avoid the unnecessary IPI by guarding the forwarding path with !(interrupt->state & ACT). Signed-off-by: Jose Martins <josemartins90@gmail.com>
… state When a disabled PENDACT interrupt is placed in an LR, the LR was written with both ACT and PEND set. On guest EOI the LR would transition from PENDACT to PEND and re-deliver the interrupt even though it is disabled. Strip PEND from the LR state written for disabled non-HW interrupts, and preserve it in interrupt->state so it is restored when the interrupt is re-enabled. HW PENDACT is impossible (the physical GIC prevents re-assertion while active), so state & PEND is always 0 for HW — no special case needed. Also fix vgic_remove_lr() to OR in the preserved PEND when updating interrupt->state from the LR, so that an early removal (e.g. on re-enable before the guest EOIs) does not overwrite the preserved pending state. Signed-off-by: Jose Martins <josemartins90@gmail.com>
…illed When all LRs are full and pend_found > 1 but all pending LRs have higher priority than the new interrupt (pend_ind == -1), the spill selection set lr_ind = -1 and skipped eviction entirely, even if a lower-priority active LR was available to spill. Add pend_ind >= 0 to the condition so the selection falls through to act_ind when no eligible pending candidate exists. Signed-off-by: Jose Martins <josemartins90@gmail.com>
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a set of fixes related to issues with vGIC List Register management. Among others, it addresses issues #162.