x86_64: no network on QEMU microvm with ACPI on

クローズ
#2,776 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #2777 @martijnhoekstra による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
rust

調査の方向性

The issue describes IRQ dispatch and virtio-mmio discovery through ACPI DSDT LNRO0005 devices, but names no source files or tests. Start by tracing the x86_64 interrupt handler and virtio-mmio probe path, then inspect the linked pull request #2777, which already implements the proposed fixes. Done means networking works on QEMU microvm with ACPI enabled and with ioapic2=off, under KVM and TCG.

索引モデルが issue の本文から書いたものです。

説明

On QEMU's microvm machine with ACPI on, which is QEMU's default, a Hermit application built without pci has no working network. Hermit's CI boots microvm with acpi=off, where this doesn't happen.

There are three separate problems:

  1. With the second IOAPIC (ioapic2=on, the default), Hermit panics at boot. #2775 fixes that.
  2. Hermit probes the virtio-mmio transports and assumes transport n uses IRQ 5 + n. QEMU only numbers them that way with acpi=off. With ACPI and ioapic2=off, transport n uses GSI 16 + n. With the second IOAPIC there are 24 transports on GSIs 24 to 47, and Hermit only probes the first 8. With ACPI on, QEMU puts no virtio_mmio.device= on the command line. Only the DSDT says where each transport is and which GSI it uses: each one is an LNRO0005 device with a memory range and an interrupt.
  3. Hermit only sends IRQs 0 to 15 to handle_interrupt. Any higher IRQ goes to the exception handler, which stops the core.

To reproduce on main, build an application without pci and boot it with -machine microvm,ioapic2=off -global virtio-mmio.force-legacy=false. Hermit finds the NIC, installs its handler on IRQ 12, and stops when the NIC raises GSI 23:

[INFO  mmio      ] Found Virtio Net device: 0xfeb00e00
[INFO  virtio    ] Virtio interrupt handler at line 12
[ERROR interrupts] Exception 55

With -machine microvm and #2775, Hermit boots but doesn't find the NIC, which is transport 23 at 0xfeb02e00. The application fails with "Network is down".

Fix

#2777 fixes 2 and 3 in two commits:

  1. Send IRQs 0 to 79 to handle_interrupt. The vectors from 112 up stay with the local APIC.
  2. Without virtio_mmio.device= arguments, read the LNRO0005 devices from the DSDT with the acpi crate's AML interpreter. Probe only if there are none.

With both commits and #2775, an echo application passes TCP and UDP tests on microvm with default options and with ioapic2=off, under KVM and TCG.

The cost is size. The second commit links the AML interpreter into x86_64 builds with acpi and without pci. The echo application grew by 227 KB, from 1.31 MB to 1.54 MB.

Only the first commit

The first commit could also go in on its own.

What it gains:

  • An IRQ above 15 no longer stops the core. That is a bug on any machine, not only on microvm.
  • No size cost.

What it loses:

  • The NIC still doesn't work on microvm with ACPI. With ioapic2=off, the application starts, but the NIC's handler is still on IRQ 12, so Hermit never sees its interrupts. In my test under KVM, every TCP and UDP echo failed. With the second IOAPIC, Hermit still doesn't find the NIC.
  • Networking on microvm would still need acpi=off, as in CI today.
主要言語
Rust
スター
1.5k
フォーク
138
平均マージ
1日 10時間
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hermit-os/kernel のほかの issue

hermit-os/kernel の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。