Repository navigation
refactor(riscv64/plic): replace IPI_EVENT_UPDATE_HART_LINE with a VSEIP level line - #438
Conversation
| true | ||
| } | ||
| Some(IPI_EVENT_CLEAR_INJECT_IRQ) | Some(IPI_EVENT_UPDATE_HART_LINE) => { | ||
| Some(IPI_EVENT_CLEAR_INJECT_IRQ) => { |
There was a problem hiding this comment.
Is this path still needed?
Now I can't find any producer of IPI_EVENT_CLEAR_INJECT_IRQ in the tree. The HvClearInjectIrq hypercall goes through hv_virtio_deassert_irq(), which updates the IRQ line directly and never calls send_event().
On RISC-V, arch_check_events() is now just a panic!(), so if this event were ever queued, hvisor would panic instead of handling or ignoring it.
Since the event appears unused, can we remove IPI_EVENT_CLEAR_INJECT_IRQ and its dispatch branch in this PR? That would also let us drop arch_check_events() entirely on RISC-V.
|
By the way, I noticed this is stage 3 of the Using a stack would keep this PR's review diff limited to stage 3 while making the later work and its dependencies easier to track. When this PR changes, GitHub can also retarget and rebase the downstream PRs automatically, as long as there are no conflicts. |
d689a3e to
1c896c1
Compare
Good suggestion. I will try it next time. |
| let irq_id = value; | ||
| if inner.hw[value] { |
There was a problem hiding this comment.
Guest-controlled value is used as a BitVec index without a bounds check (hw/active are sized max_interrupts + 1), so any out-of-range store to the complete register (e.g. sw 0xffffffff, 0x200004) panics the hypervisor; mirror the priority-arm guard at line 185:
| let irq_id = value; | |
| if inner.hw[value] { | |
| let irq_id = value; | |
| if irq_id == 0 || irq_id > self.max_interrupts { | |
| error!("vplic_complete_access: invalid interrupt ID: {}", irq_id); | |
| return 0; | |
| } | |
| if inner.hw[irq_id] { |
li041
left a comment
There was a problem hiding this comment.
LGTM! Only a small nit inherits from previous code.
1c896c1 to
e6746a4
Compare
Summary
Continues removing
PERCPU_EVENTS(follow-up to #407 and #415). The RISC-V vPLIC no longer sendsIPI_EVENT_UPDATE_HART_LINEto update a remote hart's external interrupt line. Instead, it posts VSEIP as a level line on the target vCPU, using the level-line support added in #415.GUEST_LINES = &[IRQ_VS_EXT](VSEIP,hvipbit 10).flush_guest_irqs()writes dirty lines tohvip(set_vseip/clear_vseip) before raising posted edge IRQs.VirtualPLIC::update_hart_line()computesvplic_get_next_pending(vcontext) != 0and callspost_guest_irq(pcpu, IRQ_VS_EXT, None, Level(..)). It runs under the vPLICinnerlock, so the last posted level always matches the latest vPLIC state. Local and remote targets now take the same path.VirtualPLICstores the zone's pCPU list at creation. vcontext ↔ pCPU/pcontext conversion now uses that list. Previously, every call collectedcpu_set()into aVecand read it fromthis_cpu_data().hvipwrite for local targets,send_event(IPI_EVENT_UPDATE_HART_LINE),plic::update_hart_line(), the free functionsvcontext_to_pcontext()/pcontext_to_vcontext(), thearch_check_events()branch and theIPI_EVENT_UPDATE_HART_LINEconstant.plic::inject_irq()drops the IRQ with a warning when the current CPU is not in the zone. Previously the lookup fell back to vcontext 0.AIA is not affected.
Motivation
The vPLIC output to a hart is a level signal. Sending it through the event FIFO means taking the queue lock, possibly allocating, and dispatching through
arch_check_events()just to recompute the line on the target. Posting the level on the target vCPU publishes the state first and then kicks the target. Repeated updates to an unchanged level do not kick again.Verification
insmod hvisor.ko→ virtio backend →zone start→ zone1 shell and load →zone shutdown -id 1→ zone0 loadzone shutdownnot run (GICv2arch_irqchip_reset()is unimplemented).smp_affinityset to its second CPU, then 3 rounds of virtio-blk O_DIRECT reads (1 MiB × 64, 4 KiB × 2000) and a 4-process load. virtio0 took 6,221 interrupts on the second CPUAll runs had no hypervisor panic and no ERROR logs.
cargo fmt --all -- --checkpasses."Load" runs more shell busy-loop processes than the zone has vCPUs (8 in zone0, 4 in zone1).
Risks and Limitations