Skip to content

fix(loongarch64): harden virtio IRQ and zone startup - #111

Merged
enkerewpo merged 3 commits into
syswonder:mainfrom
li041:irq-fix-upstream
Aug 19, 2026
Merged

enkerewpo merged 3 commits into
syswonder:mainfrom
li041:irq-fix-upstream

Conversation

@li041

@li041 li041 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • model LoongArch virtio interrupt lines with explicit assertion state
  • harden IVC MMIO/IRQ initialization and isolate the canonical virtio sources
  • return a failure status when the zone-start ioctl fails

Validation

  • loaded hvisor.ko and started linux1 on the LS3A6000 board
  • verified /dev/pts/0 login, uname, and two guest CPUs
  • verified zone-start failures are visible to the calling script

@li041
li041 marked this pull request as draft July 21, 2026 12:32
@li041
li041 force-pushed the irq-fix-upstream branch 2 times, most recently from 980fa76 to 5f534bd Compare July 21, 2026 13:35
@li041
li041 marked this pull request as ready for review July 21, 2026 13:36
@caodg
caodg requested a review from enkerewpo July 21, 2026 21:42
Comment thread driver/ivc_driver.c Outdated
@li041
li041 force-pushed the irq-fix-upstream branch 2 times, most recently from 98f16ec to bc0240d Compare July 22, 2026 11:05
@li041

li041 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@enkerewpo Thanks for your review. I have addressed the comments and updated the PR accordingly. Could you please take another look when you have time?

@li041
li041 force-pushed the irq-fix-upstream branch from bc0240d to 4056c65 Compare July 29, 2026 06:23

@agicy agicy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently hit a console problem in my multi-zone setup: screen zone1 -> exit -> screen zone2 -> back to zone1, and the console is sometimes completely frozen after re-attach. So I'm glad to see this PR touching virtio-console - I did a careful review and left inline comments. Summary of what I found:

  1. TX backpressure is still missing. On EAGAIN (pty full), the descriptor is still completed via update_used_ring() and freed, so the guest is told its output was transmitted. A flooding guest never throttles and all output is silently dropped while the pty stays full - this is exactly the "console frozen after re-attach" symptom I observed. The RX changes in this PR don't address it.
  2. The RX rearm logic introduces a permanent stall. rxq_notify_handler calls disable_notify(), which sets VRING_USED_F_NO_NOTIFY. But the event handler only re-arms when the queue is non-empty. If it exits with an empty queue while input is still pending in the pty, the EPOLLONESHOT event stays disarmed forever and the guest's next kick never comes -> RX is permanently dead.
  3. The descriptor-error path never re-arms the event, so one transient process_descriptor_chain() failure also kills console RX permanently.

Since these console changes may carry a regression and the actual backpressure fix is still missing, I'd suggest extracting the virtio-console changes from this PR and landing them as a separate PR, so the console fix can be completed properly (RX improvements + rearm fix + TX backpressure via EPOLLOUT) and merged independently of the LoongArch/IVC work.

Comment thread tools/virtio/devices/console/virtio_console.c
Comment thread tools/virtio/devices/console/virtio_console.c
Comment thread tools/virtio/devices/console/virtio_console.c
Comment thread tools/virtio/devices/console/virtio_console.c Outdated
@li041
li041 force-pushed the irq-fix-upstream branch from 4056c65 to 6543d6e Compare August 11, 2026 13:25
@li041

li041 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Since these console changes may carry a regression and the actual backpressure fix is still missing, I'd suggest extracting the virtio-console changes from this PR and landing them as a separate PR, so the console fix can be completed properly (RX improvements + rearm fix + TX backpressure via EPOLLOUT) and merged independently of the LoongArch/IVC work.

Thanks. This PR now only includes fix on la irq and ivc. A Latter PR will focus on virtio console RX/TX. Maybe we can discuss in that PR carefully.

@enkerewpo enkerewpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix — the level-triggered interrupt model and the interrupt_status &= !value& ~ack correction are both clear improvements (the old logical-not was a real bug).

Two blocking issues before this can land, both about how the new deassert path is numbered, plus a leak on the ivc error path. Details inline.

Comment thread include/hvisor.h Outdated
Comment thread include/hvisor.h Outdated
Comment thread driver/ivc_driver.c
Comment thread driver/ivc_driver.c Outdated
Comment thread tools/Makefile Outdated
@li041
li041 force-pushed the irq-fix-upstream branch from 6543d6e to 7f91746 Compare August 18, 2026 14:35
enkerewpo

This comment was marked as off-topic.

@enkerewpo enkerewpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@enkerewpo
enkerewpo merged commit 95b3624 into syswonder:main Aug 19, 2026
1 check passed
agicy pushed a commit that referenced this pull request Aug 24, 2026
fix(loongarch64): harden virtio IRQ and zone startup
agicy pushed a commit that referenced this pull request Aug 24, 2026
fix(loongarch64): harden virtio IRQ and zone startup
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.

3 participants