Repository navigation
Conversation
Route GICv2 and GICv3 guest SGIs through per-vCPU pending state, host-doorbell dispatch, and local LR flush.
| continue; | ||
| } | ||
| let lr = gich.get_lr(index) as usize; | ||
| let lr_source = (lr >> GICV2_GICH_LR_CPUID_SHIFT) & 0x7; |
There was a problem hiding this comment.
I suggest using bitvec or bitflags to achieve better readability.
There was a problem hiding this comment.
Sorry, use bit_field. I forget the name of this crate. bit_field would help reducing lots of MASK definition and bit-level operation, and it's already introduced in this repo (in Cargo.toml).
bit_field = "0.10"
|
|
||
| const VINTID_MASK: usize = 0x3ff; | ||
|
|
||
| fn try_install_software_sgi(irq_id: usize, source_cpu: usize) -> bool { |
There was a problem hiding this comment.
try_install_software_sgi() matches existing LRs by (vINTID, source), so when the same SGI is pending from two different source CPUs, each source gets its own LR.
The GICv2 architecture requires every valid interrupt in the List registers to have a unique VirtualID for a virtual CPU interface; violating this makes the LR set UNPREDICTABLE. KVM had exactly this bug in its GICv2 SGI injection and fixed it in commit 16ca6a607d84 ("KVM: arm/arm64: vgic: Don't populate multiple LRs with the same vintid").
| let width_mask = if mmio.size == 4 { | ||
| u32::MAX | ||
| } else { | ||
| ((1u32 << (mmio.size * 8)) - 1) << shift |
There was a problem hiding this comment.
Can mmio.size be 8 here? If can, an overflow would happen here.
Summary
This pull request starts the staged removal of
PERCPU_EVENTSby migrating AArch64 virtual IPIs to per-vCPU interrupt state.GuestCpuIrqStatepending bitmap and architecture-privateArchVcpustate.Motivation
Virtual IPIs describe guest interrupt state and do not require FIFO payload semantics. Routing them through
PERCPU_EVENTSadds locking, possible queue allocation, and unnecessary coupling between guest interrupt delivery and host CPU event dispatch.The new path publishes pending state before kicking the target CPU. Only the target CPU installs the interrupt into its local GIC list registers. This keeps interrupt state with the guest CPU, supports the current pinned pCPU:vCPU mapping, and provides a foundation for removing additional event categories without introducing a scheduler in this change.
The event ID update also removes collisions between virtio-pci events, vCPU suspend/resume events, and DWC MSI injection.
Verification
Risks and Limitations
PERCPU_EVENTSFIFO and GICPENDING_VIRQSqueue remain for unmigrated producers.