Skip to content

feat(axvisor): support dynamic x86_64 QEMU guest boot#1166

Merged
ZR233 merged 10 commits into
devfrom
dyn_x86
Jun 9, 2026
Merged

feat(axvisor): support dynamic x86_64 QEMU guest boot#1166
ZR233 merged 10 commits into
devfrom
dyn_x86

Conversation

@Josen-B

@Josen-B Josen-B commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

背景

本 PR 接入 Axvisor 的 x86_64 动态平台,并补齐在 QEMU/KVM 下启动 x86_64 guest 的 VMX/SVM 支持。原有路径主要覆盖静态平台或单一启动形态,迁移到动态平台后会遇到以下问题:

  • x86_64 动态平台需要 UEFI/PIE 形式启动 Axvisor,并正确传递 VM config。
  • VMX/SVM 后端需要支持 Linux guest 的 APIC/IOAPIC、EPT/NPT MMIO、virtio PCI 中断注入路径。
  • QEMU q35 在不同 host/CI 环境下可能给 virtio PCI 64-bit BAR 分配不同高地址窗口,原先只覆盖单一窗口会导致 stage2/NPT/EPT 未映射异常。
  • linux-x86_64 setup 脚本输出的 --qemu-config 路径和仓库实际配置路径不一致,生成的命令不可直接运行。

改动内容

  • 增加 Axvisor x86_64 动态平台构建与 QEMU 测试适配:

    • 为 x86_64 动态平台选择 PIE/UEFI QEMU 启动路径。
    • 拆分 VMX/SVM smoke 测例构建配置,避免后端特性互相污染。
    • 保留并显式启用 VMX 所需的 nested virtualization CPU feature。
  • 调整 VMX/SVM 虚拟中断与 APIC/MMIO 处理:

    • 保留 VIRTUAL_INTERRUPT_DELIVERY,避免破坏依赖 virtual-APIC page VIRR/ISR/TPR 语义的中断投递路径。
    • 增加 APIC MMIO/MSR 访问处理,支持 Linux guest 在 EPT/NPT MMIO 路径下访问 LAPIC/IOAPIC。
    • 对 EOI 路径返回 InterruptEnd,让外层中断注入逻辑可以继续推进 pending interrupt。
  • 调整 x86_64 Linux guest 配置:

    • 保留 no_timer_check,避免 Linux 在 VMX 直接启动路径中因 TSC/PIT/HPET 校准问题卡住。
    • 将 virtio PCI device 3 的中断路由与 q35 实际 INTA# -> IRQ 18 路径对齐。
    • 同时覆盖 0x70_0000_00000x3800_0000_0000 两个已观察到的 q35 64-bit PCI MMIO BAR 窗口,避免本地和 CI 因 BAR 分配差异导致 NestedPageFault/NotMapped
  • 调整 QEMU 配置与脚本:

    • linux-x86_64 QEMU serial 使用 mon:stdio,恢复 Ctrl-a x 退出能力。
    • setup_qemu.sh 改为保存完整 qemu config path,并输出实际可运行的 --qemu-config
    • linux-x86_64 setup 路径增加 QEMU config 存在性检查,并将 rootfs 目标与 configs/qemu/qemu-x86_64-linux.toml 保持一致。

方案逻辑

x86_64 动态平台下,Axvisor 自身通过 UEFI/PIE 方式由 QEMU 启动,guest Linux 仍走 Axvisor 的直接启动路径。这里需要同时保证三层关系稳定:

  1. 外层 QEMU 能稳定启动动态平台 Axvisor。
  2. Axvisor 的 VMX/SVM 后端能正确处理 guest 的 APIC、IOAPIC、virtio PCI 中断和 MMIO。
  3. guest Linux 的 VM config 不能依赖某一台机器上观测到的 q35 BAR 地址。

因此本 PR 尽量把改动限制在 Axvisor x86_64/QEMU 相关配置、测试和 VMX/SVM 路径中,不修改其他架构 guest 的配置。对 q35 BAR 地址采用兼容两个已知窗口的方式,是为了覆盖本地与 CI 中不同 QEMU/host CPU/OVMF 组合下的分配差异。

验证

已验证:

  • cargo test --manifest-path scripts/axbuild/Cargo.toml
  • cargo test --manifest-path scripts/axbuild/Cargo.toml test::qemu::tests::static_x86_64_cargo_keeps_existing_qemu_boot
  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-vmx
  • bash -n os/axvisor/scripts/setup_qemu.sh

启动验证:

  • Axvisor x86_64 VMX smoke guest 可启动 Linux,并匹配 guest linux test pass!
  • NimbOS x86_64 guest 可启动
  • ArceOS x86_64 guest 可启动

CI 关注点:

  • VMX smoke 中 Linux 日志应出现 virtio-pci 0000:00:03.0: PCI->APIC IRQ transform: INT A -> IRQ 18
  • 不应再出现 gpa=0x380000000014 对应的 stage2/NPT/EPT NotMapped 循环
  • linux-x86_64 setup 脚本输出的命令应使用 configs/qemu/qemu-x86_64-linux.toml

@Josen-B
Josen-B requested review from Ivans-11, ZCShou and ZR233 June 6, 2026 12:34

@mai-team-app mai-team-app Bot 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.

PR #1166 审查意见

变更概述

本 PR 对 Axvisor x86_64 进行三项主要改动:

  1. 动态平台检测:移除 x86_64 board config 中的 ax-hal/x86-qemu-q35ax-driver/plat-static feature,改为 plat_dyn = true 运行时平台检测
  2. VMX vCPU 重构:手动保存/恢复 CR2、动态检测 secondary controls 可用性、APIC MMIO/MSR 处理内联到 EPT violation 路径、IOAPIC 远程 IRR 处理改进
  3. x86 Linux direct boot 改进:cmdline 从可选改为必填、新增 MMIO passthrough 地址段、PCI INTx GSI 调整、shell 脚本增加 QEMU x86_64 Linux 启动选项

CI 状态

⚠️ CI 失败Test axvisor x86_64 svm hosted / run_host (job 79877539801) 在 "Run command" 步骤失败 (exit code 1)。该 job 测试 Axvisor x86_64 SVM 配置,与本 PR 直接相关——SVM build config 已从 ax-hal/x86-qemu-q35 + ax-driver/plat-static 改为 plat_dyn = true,且 SVM VM config 新增了 MMIO passthrough 地址段。失败导致其他 CI job 级联取消。

成功的 CI job 包括:Check formatting (通过)、Run sync-lint (通过)、Test axvisor loongarch64 qemu (通过)。

无法获取 CI 日志(GitHub blob 存储连接失败),无法确定具体失败原因。请作者确认失败原因并修复后重新推送。

阻塞问题

  1. VIRTUAL_INTERRUPT_DELIVERY 被静默移除:base 分支中 VMX secondary controls 无条件包含 VIRTUALIZE_APIC | VIRTUAL_INTERRUPT_DELIVERY | ENABLE_EPT | UNRESTRICTED_GUEST,但本 PR 将其改为仅 ENABLE_EPT | UNRESTRICTED_GUEST 加条件性 VIRTUALIZE_APICVIRTUAL_INTERRUPT_DELIVERY 被完全移除,且 for feature 循环中没有包含它。按 Intel SDM,该控制位启用通过 virtual-APIC page 进行的虚拟中断评估和投递(VIRR/ISR/TPR 机制)。虽然 PR 增加了 EPT MMIO 路径下的 APIC 直接模拟,但该改动需要明确说明设计意图,或者将 VIRTUAL_INTERRUPT_DELIVERY 加入条件启用列表。

  2. PCI INTx GSI 从 23 改为 18 缺乏说明mptable.rs 中 device 3 pin 0 的 GSI 从 23 改为 18,直接影响 PCI virtio 设备的中断路由。PR body 和 commit message 均未解释此改动原因。如果这是为了匹配 QEMU q35 芯片组的 IOAPIC 路由表,请在代码注释或 commit message 中说明。

  3. 缺少 PR 描述:PR body 为空。对于涉及 VMX vCPU 重构、动态平台检测、中断路由变更等关键改动,需要在 PR body 中说明设计决策、验证方法和对现有行为的影响。

本地验证结果

  • cargo fmt --check:✅ 通过
  • cargo test -p axbuild:✅ 504 tests passed
  • cargo test -p x86_vlapic:✅ 8 tests passed
  • cargo test -p x86_vcpu⚠️ test_mock_contiguous_allocator 在全量测试时失败(隔离运行通过),疑似测试间全局状态干扰,为预存问题

其他观察

  • CR2 手动保存/恢复改动正确,VMX 硬件不自动保存 CR2
  • secondary_control_bits_allowed() 动态检查是有价值的改进,避免在不支持的 CPU 上启用高级 VMX 功能
  • CommandLineMissing 错误取代默认 cmdline 是合理的架构改进
  • linux-smp1.toml 重命名为 linux-vmx-smp1.toml 并添加显式 cmdline 配置正确
  • IOAPIC remote_irr 处理改进逻辑正确:仅在低 32 位实际值变化时清除 pending level

Powered by mimo-v2.5-pro

Comment thread virtualization/x86_vcpu/src/vmx/vcpu.rs
Comment thread os/axvisor/src/images/x86/mptable.rs

@mai-team-app mai-team-app Bot 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.

PR #1166 审查意见(第二轮)

变更概述

本 PR 对 Axvisor x86_64 进行三项主要改动:

  1. 动态平台检测:移除 x86_64 board config 中的 ax-hal/x86-qemu-q35ax-driver/plat-static feature,改为 plat_dyn = true 运行时平台检测
  2. VMX vCPU 重构:手动保存/恢复 CR2、动态检测 secondary controls 可用性、APIC MMIO/MSR 处理内联到 EPT violation 路径、IOAPIC 远程 IRR 处理改进
  3. x86 Linux direct boot 改进:cmdline 从可选改为必填、新增 MMIO passthrough 地址段、PCI INTx GSI 调整、shell 脚本增加 QEMU x86_64 Linux 启动选项

CI 状态

CI 失败Test axvisor x86_64 svm hosted / run_host(job 79877539801)在 "Run command" 步骤失败(conclusion: failure)。该 job 测试 Axvisor x86_64 SVM 配置,与本 PR 直接相关——SVM board config 已从 ax-hal/x86-qemu-q35 + ax-driver/plat-static 改为 plat_dyn = true,SVM VM config 新增了 MMIO passthrough 地址段,PCI INTx GSI 从 23 改为 18。此失败导致多个下游 CI job 级联取消。

成功的 CI job 包括:Check formatting(通过)、Run sync-lint(通过)、Test axvisor loongarch64 qemu / run_container(通过)。大部分 run_container 和 run_host job 因上游失败而被取消(conclusion: cancelled),这是预期的级联行为。

CI 日志无法通过 API 获取(GitHub blob 存储连接失败)。请作者确认 SVM hosted 测试的具体失败原因并修复后重新推送。

本地验证结果

  • cargo fmt --check:✅ 通过
  • cargo test -p axbuild:✅ 504 tests passed
  • cargo test -p x86_vlapic:✅ 8 tests passed

阻塞问题

  1. VIRTUAL_INTERRUPT_DELIVERY 被静默移除(见 inline comment #1
  2. PCI INTx GSI 从 23 改为 18 缺乏说明(见 inline comment #2
  3. cmdline 从可选改为必填——破坏性 API 变更(见 inline comment #3
  4. CI 失败Test axvisor x86_64 svm hosted / run_host 失败,需修复
  5. 缺少 PR 描述:PR body 为空。对于涉及 VMX vCPU 重构、动态平台检测、中断路由变更等关键改动,需要在 PR body 中说明设计决策、验证方法和对现有行为的影响

正面观察

  • secondary_control_bits_allowed() 动态检查是有价值的改进,避免在不支持的 CPU 上启用高级 VMX 功能
  • CR2 手动保存/restore 改动正确,VMX 硬件不自动保存 CR2
  • EPT violation 路径增加 local APIC MMIO 直接处理(不再依赖 APIC_ACCESS VM exit),提升了在不支持 VIRTUALIZE_APIC 的 CPU 上的兼容性
  • IOAPIC remote_irr 处理改进逻辑正确:仅在低 32 位实际值变化时清除 pending level
  • linux-smp1.toml 重命名为 linux-vmx-smp1.toml 并添加显式 cmdline 配置是好的改进
  • resolve.rs 中 vmconfigs 优先级修复(显式 CLI 参数优先于 snapshot)是正确的

重复/重叠分析

检查了当前 dev 分支和相关 open PR:

  • PR #1160(Wayland app case)和 PR #1165(AIO 修复)与本 PR 不重叠
  • 本 PR 建立在已合并的 PR #930(x86_64 Linux guest boot)、PR #1019(Axvisor 重构)和 PR #1024(CI 默认值切换到动态平台)之上,不重复

总结

请修复 CI 失败、补充 PR 描述中对 VIRTUAL_INTERRUPT_DELIVERY 移除和 GSI 变更的设计理由,并确认所有 x86 Linux VM config 都已包含 cmdline 字段。

Powered by mimo-v2.5-pro

Comment thread virtualization/x86_vcpu/src/vmx/vcpu.rs
Comment thread os/axvisor/src/images/x86/mptable.rs
Comment thread os/axvisor/src/images/mod.rs
Comment thread os/axvisor/configs/vms/qemu/x86_64/linux-vmx-smp1.toml

@ZR233 ZR233 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.

这版还不能合入,主要阻塞在 x86 Axvisor 的新增验证路径和脚本输出路径。

我已确认最新 diff 已补回/解释了几个旧问题:VIRTUAL_INTERRUPT_DELIVERY 条件启用、q35 virtio-blk GSI 18 的注释、以及 VMX cmdline 中的 no_timer_check,这些旧 thread 已关闭。cmdline 从默认值改为必填虽然仓库内现有 x86 Linux direct boot 配置都已补字段,但 PR body 仍为空;这类破坏性行为变化和动态 x86/UEFI boot 取舍需要在 PR 描述里说明清楚。

阻塞项:

  1. SVM smoke 的 build config 被切到 plat_dyn = true 后,最新 CI 的 Test axvisor x86_64 svm hostedrust-objcopy 后立即失败:No such file or directory (os error 2),结果 0/1 case(s) passed。这是本 PR 直接修改到的 x86 SVM 覆盖面,需要先修到 CI 可通过,或者把 SVM smoke 保持在可运行的 boot 配置并补充验证。
  2. setup_qemu.sh linux-x86_64 输出的 --qemu-config .github/workflows/qemu-x86_64-linux.toml 路径不存在;实际配置在 configs/qemu/qemu-x86_64-linux.toml,用户按脚本输出执行会失败。
  3. PR body 为空,不足以说明这次大范围 Axvisor/x86 动态平台改动的兼容性、验证矩阵、以及 cmdline 必填这类行为变化。

本地验证:cargo fmt --check 通过;cargo test -p axbuild dynamic_x86_64_qemu_boot --lib 通过 6 个测试;cargo xtask axvisor test qemu --arch x86_64 --test-group svm --test-case smoke --list 能发现 svm/smoke;完整本地 SVM smoke 已构建并启动到 Axvisor,但当前机器不支持所需硬件虚拟化,最终以 hardware virtualization is not supported 失败,不能替代 CI 通过证据。

Comment thread test-suit/axvisor/normal/qemu/build-x86_64-unknown-none-svm.toml
Comment thread os/axvisor/scripts/setup_qemu.sh Outdated
arceos) CFG="qemu_aarch64_arceos|qemu/aarch64/arceos-smp1.toml|arceos-aarch64-qemu-smp1.toml|qemu-aarch64.toml|qemu-aarch64.toml|qemu-aarch64|Hello, world!" ;;
arceos-riscv64) CFG="qemu_riscv64_arceos|qemu/riscv64/arceos-smp1.toml|arceos-riscv64-qemu-smp1.toml|qemu-riscv64.toml|qemu-riscv64.toml|qemu-riscv64|Hello, world!" ;;
linux) CFG="qemu_aarch64_linux|qemu/aarch64/linux-smp1.toml|linux-aarch64-qemu-smp1.toml|qemu-aarch64.toml|qemu-aarch64.toml|qemu-aarch64|test pass!" ;;
linux-x86_64) CFG="qemu_x86_64_linux|qemu/x86_64/linux-vmx-smp1.toml|linux-x86_64-qemu-smp1.toml|qemu-x86_64-linux.toml|qemu-x86_64-linux.toml|linux-qemu|test pass!" ;;

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.

linux-x86_64 这里把 QEMU_CONFIG 设成 qemu-x86_64-linux.toml,但脚本最后输出的运行命令固定使用 .github/workflows/${QEMU_CONFIG}。仓库里没有 os/axvisor/.github/workflows/qemu-x86_64-linux.toml,实际配置在 os/axvisor/configs/qemu/qemu-x86_64-linux.toml,所以用户按脚本生成的命令执行会在 --qemu-config 路径处失败。请把配置路径和最终输出命令统一起来,例如保存完整 qemu config path,或生成/输出 tmp 下的 runtime qemu config,并给 linux-x86_64 路径加一个脚本级检查。

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.

复查当前 head 4faad0e684b291606fbdecb0da277d5287f2e8ac,这里仍然有效:linux-x86_64 仍把 QEMU_CONFIG 设为 qemu-x86_64-linux.toml,而最终提示命令仍固定输出 --qemu-config .github/workflows/${QEMU_CONFIG}。该路径在仓库中不存在,实际 qemu 配置在 configs/qemu/qemu-x86_64-linux.toml,所以按脚本提示运行仍会失败。

@ZR233 ZR233 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.

这版仍然不能合入。PR 的方向是把 Axvisor x86_64 切到动态平台、拆分 VMX/SVM QEMU 用例,并继续调整 Linux direct boot / APIC / IOAPIC 相关路径;其中 VMX secondary control 条件启用、q35 GSI 说明、cmdline 必填等旧问题在代码上已有改善。但当前 head 仍有几个阻塞项:

  1. 当前 CI Test axvisor x86_64 svm hosted / run_host 仍失败,且该 job 正是本 PR 修改的 SVM hosted 路径。日志显示构建完成并执行 rust-objcopy ... axvisor.bin 后,smoke-svm 立即失败:No such file or directory (os error 2),最终 result: 0/1 case(s) passed。这说明旧的 SVM blocker 还没有解除,相关 review thread 需要保持打开。
  2. setup_qemu.sh linux-x86_64 的旧 blocker 也仍然有效:脚本最后仍输出 --qemu-config .github/workflows/${QEMU_CONFIG},但 qemu-x86_64-linux.toml 实际不在 os/axvisor/.github/workflows/ 下,用户按脚本输出执行会失败。
  3. 新的共享 QEMU case 发现逻辑让 cargo test -p axbuild --lib qemu 中两个现有单测失败,见 inline comment。这个回归会影响 Axvisor 和 Starry 对“指定 case 存在但缺少对应 arch qemu config”错误的诊断。
  4. PR body 仍为空;这次改动跨 VMX/SVM、动态 x86 boot、Linux cmdline 必填、QEMU 脚本和测试矩阵,至少需要说明设计取舍、兼容性影响和验证矩阵。

本地验证:

  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-svm --list 通过,能发现 normal/smoke-svm
  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-vmx --list 通过,能发现 normal/smoke-vmx
  • bash -n os/axvisor/scripts/setup_qemu.sh os/axvisor/scripts/quick-start.sh 通过。
  • git diff --check origin/dev...HEAD 通过。
  • cargo test -p axbuild --lib checked_in_test_build_vmconfigs_exist 通过。
  • cargo test -p axbuild --lib qemu 失败:axvisor::test::tests::selected_case_requires_matching_qemu_configstarry::test::tests::selected_case_requires_matching_qemu_config 未通过。

CI 状态:当前 head 的 formatting、sync-lint、Axvisor riscv64/loongarch64 qemu 已通过;Test axvisor x86_64 svm hosted / run_host 失败,Run clippy / run_host、Axvisor aarch64/self-hosted/x86_64 UEFI/board 等多个相关 job 因此取消。由于失败 job 覆盖本 PR 修改面,不能按无关 CI 处理。

重复/重叠检查:base 分支没有当前这种 smoke-svm/smoke-vmx variant 拆分;#1135 同样触及 Axvisor x86/VMX/IRQ/bootloader,属于明显 conflict-risk;#1160 触及共享 scripts/axbuild/src/test/qemu.rs 但语义是 Starry Wayland app case,属于共享 helper 层面的部分重叠;#1174 是 ArceOS QEMU suite 整理,相关但不是同一 Axvisor SVM/VMX 行为。当前问题仍应在本 PR 内修复。

Comment thread scripts/axbuild/src/test/qemu.rs Outdated

@ZR233 ZR233 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.

这次基于当前 HEAD b89f6db95f7f0cc1932e93eb17e1613d39301814 重新审查。

新提交 fix(qemu): enhance error context for QEMU execution failure 已经让 Test axvisor x86_64 svm hosted / run_host 在当前 CI run 27123091792 中转为通过,我已将对应的旧 SVM blocker review thread 标记为 resolved。smoke-svmsmoke-vmx 的发现路径也能正常列出:

  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-svm --list:通过,输出 normal/smoke-svm
  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-vmx --list:通过,输出 normal/smoke-vmx

但当前 head 仍不能合入,剩余两个阻塞项都还对应未解决 review thread:

  1. os/axvisor/scripts/setup_qemu.shlinux-x86_64 路径仍把 QEMU_CONFIG 设为 qemu-x86_64-linux.toml,最终输出命令仍固定使用 --qemu-config .github/workflows/${QEMU_CONFIG}。仓库中没有 os/axvisor/.github/workflows/qemu-x86_64-linux.toml,真实配置在 configs/qemu/ 下;用户按脚本提示执行仍会失败。
  2. scripts/axbuild/src/test/qemu.rs 仍把“指定 case 存在但目标 arch qemu config 不存在”的错误信息改成通用 none provide a qemu config for arch ...,不再包含现有测试期待的具体 qemu-<arch>.toml 文件名。当前 cargo test -p axbuild --lib qemu 仍失败 2 个测试:axvisor::test::tests::selected_case_requires_matching_qemu_configstarry::test::tests::selected_case_requires_matching_qemu_config

本地验证:

  • bash -n os/axvisor/scripts/setup_qemu.sh os/axvisor/scripts/quick-start.sh:通过。
  • git diff --check origin/dev...HEAD:通过。
  • cargo test -p axbuild --lib checked_in_test_build_vmconfigs_exist:通过。
  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-svm --list:通过。
  • cargo xtask axvisor test qemu --arch x86_64 --test-case smoke-vmx --list:通过。
  • cargo test -p axbuild --lib qemu:失败,2 个失败如上。

CI 状态:当前 head 上 formatting、sync-lint、Axvisor riscv64/loongarch64、Axvisor x86_64 SVM hosted 已通过;还有多项 host/container 矩阵仍在 running/pending。当前 request changes 不是因为 CI 未结束,而是因为本地 targeted test 仍失败、脚本输出路径仍错误。

重复/重叠检查:base 分支没有当前这种 smoke-svm/smoke-vmx variant 拆分;#1135 同样触及 Axvisor x86/VMX/IRQ/bootloader,属于 conflict-risk;#1160 触及共享 scripts/axbuild/src/test/qemu.rs,属于共享 helper 层部分重叠;#1174 是 ArceOS QEMU suite 整理,相关但不是同一 Axvisor SVM/VMX 行为。剩余问题仍应在本 PR 内修复后再合入。

PR body 仍为空。考虑到这次跨 Axvisor x86 dynamic platform、VMX/SVM 用例拆分、Linux direct boot、QEMU 脚本和 CI 矩阵,建议在修复上述阻塞项时也补充设计说明和验证矩阵。

mai-team-app[bot]
mai-team-app Bot previously requested changes Jun 8, 2026

@mai-team-app mai-team-app Bot 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.

PR #1166 审查报告

概述

本 PR 重构 Axvisor 以支持动态平台特性,修复 x86_64 页表和虚拟化多个关键问题,并增加 QEMU x86_64 Linux 直接启动支持。共 30 个文件,+801/-239 行。

CI 状态

  • 总检查数: 54 个 check runs
  • 成功: Test axvisor riscv64 qemu / run_hostTest axvisor loongarch64 qemu / run_container 等非 x86_64 架构检查全部通过
  • 跳过: 大量 self-hosted board 和 run_host/run_container 互斥 job(预期行为,路径过滤和矩阵互斥)
  • 失败: 无远程 CI 失败
  • 本地 cargo fmt --check: ✅ 通过

本地测试验证

运行 cargo test --manifest-path scripts/axbuild/Cargo.toml 发现 2 个单元测试失败

  1. axvisor::test::tests::selected_case_requires_matching_qemu_config — 断言 err.contains("none provide \qemu-aarch64.toml`")` 不再匹配新错误信息格式
  2. starry::test::tests::selected_case_requires_matching_qemu_config — 断言 err.contains("none provide \qemu-x86_64.toml`")` 不再匹配新错误信息格式

原因: PR 在 scripts/axbuild/src/test/qemu.rs 中将错误信息从 "none provide \{config_name}` for arch `{arch}`"改为"none provide a qemu config for arch `{arch}`"`,但未同步更新上述两个测试中的断言。

修复方向: 更新以下两处测试断言以匹配新错误信息格式:

  • scripts/axbuild/src/axvisor/test.rsselected_case_requires_matching_qemu_config 测试
  • scripts/axbuild/src/starry/test.rsselected_case_requires_matching_qemu_config 测试

代码质量评价(修复测试失败后可 APPROVE)

页表修复(正确且重要):

  • 非叶页表项不应继承 dirty/global/cache 属性,符合 x86_64 SDM 规范
  • NXE 必须在加载含 NX 映射的页表之前启用,避免保留位异常

动态平台重构(合理):

  • 移除硬编码 ax-hal/x86-qemu-q35ax-driver/plat-static,改用 plat_dyn = true
  • 测试用例从 svm 独立组迁移到 normal 组并拆分 VMX/SVM 变体

VMX 改进(正确):

  • CR2 保存/恢复(VMX 硬件不自动保存 CR2)
  • 次级控制位能力检查,兼容不同硬件
  • x2APIC EOI 处理重构

MP 表修复: PCI INTx GSI 从 23 改为 18,匹配 q35 00:03.0 virtio-blk 的实际 IOAPIC 路由

vIOAPIC remote IRR 修复: 低 32 位重写时正确处理 remote IRR 清除逻辑

重叠分析

其他 open PR(#1173 RSS accounting、#1174 ArceOS test consolidation)与此 PR 修改表面无交集。

结论

请求修改:修复 2 个失败的单元测试后可合并。代码质量整体优秀,修复方向明确。

Powered by mimo-v2.5-pro

@Josen-B
Josen-B force-pushed the dyn_x86 branch 9 times, most recently from e09d0c7 to b54e2bd Compare June 9, 2026 02:59
@Josen-B
Josen-B requested a review from ZR233 June 9, 2026 05:59

@ZR233 ZR233 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.

复查当前 head 4faad0e684b291606fbdecb0da277d5287f2e8ac 后,仍需修改后再合入。

  1. os/axvisor/scripts/setup_qemu.shlinux-x86_64 路径仍会输出不可运行的 QEMU 配置路径。该分支仍把 QEMU_CONFIG 设为 qemu-x86_64-linux.toml,但最终提示命令固定使用 --qemu-config .github/workflows/${QEMU_CONFIG};仓库实际配置在 configs/qemu/qemu-x86_64-linux.toml。请统一配置路径与最终输出命令,例如保存完整 qemu config path,或生成/输出 tmp 下的 runtime qemu config,并给 linux-x86_64 加脚本级检查。

  2. PR body 仍为空。这个 PR 同时改动 Axvisor x86 dynamic platform、VMX/SVM、QEMU 配置、CI 和脚本,按项目要求需要在 PR 描述中说明问题、改动、方案逻辑和验证矩阵,方便后续维护和回归判断。

  3. PR title 目前不是 type(scope): content 形式。合入前请同步改成 Conventional Commits 风格,例如以 refactor(axvisor): ... 或更贴近最终语义的 feat(axvisor): ... 开头。

本轮已核对 current-head CI:format、sync-lint、clippy、Axvisor x86_64 SVM hosted、自托管 x86_64/UEFI、Axvisor 其他架构和相关 Starry/ArceOS jobs 当前均为 success,之前的 SVM blocker 已解除。scripts/axbuild/src/test/qemu.rs 的旧错误信息问题也已恢复到包含具体 qemu-*.toml 文件名,相关过期 thread 已标记 resolved。

本地 shell 工具当前无法启动,因此没有在本机创建 review worktree 或重复跑 cargo/脚本命令;本轮结论基于 current-head CI、源码和 review thread 复核。

@Josen-B Josen-B changed the title Refactor Axvisor for dynamic features and improve QEMU integration feat(axvisor): support dynamic x86_64 QEMU guest boot Jun 9, 2026
@Josen-B
Josen-B requested a review from ZR233 June 9, 2026 07:07

@ZR233 ZR233 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.

PR #1166 Review:Axvisor x86_64 动态平台 QEMU guest 启动支持

本 PR 为 Axvisor 添加了 x86_64 动态平台的 QEMU guest 启动支持,核心改动包括 VMX/SVM 后端的中断/MMIO 处理完善、EPT MMIO 指令解码改进、guest CR2 保存恢复、以及 Linux guest 的 QEMU 配置和测试拆分。

代码审查要点

  1. VMX secondary controls 可移植性:使用 secondary_control_bits_allowed() 在启用 VIRTUALIZE_APIC、VIRTUAL_INTERRUPT_DELIVERY、RDTSCP、INVPCID、XSAVES 等特性前先检查硬件是否支持,避免在不同 KVM/VMX 环境下执行 VM-entry 失败。

  2. APIC MSR/MMIO 路由:x2APIC MSR 访问和 APIC MMIO 访问现在都正确路由到 handle_apic_msr_access / handle_apic_access,且 EOI 路径返回 InterruptEnd 让中断注入逻辑可以推进 pending interrupt。

  3. EPT MMIO 解码decode_ept_mmio_access 新增了 local APIC 地址范围的识别,直接在 VMX 层处理 APIC MMIO 读写(包括 EOI),不再依赖上层通用 MMIO 路径。指令长度也从实际解码结果计算而非依赖 exit_instruction_length

  4. Guest CR2:VMX 不自动保存/恢复 CR2,新增 guest_cr2 字段在 VM entry/exit 时手动处理,正确。

  5. setup_qemu.sh 路径修复linux-x86_64 的 QEMU config 路径已从 .github/workflows/... 改为 configs/qemu/qemu-x86_64-linux.toml,并增加了文件存在性检查。

本地验证

检查 结果
cargo fmt --check ✓ PASS
git diff --check ✓ PASS

CI 覆盖

CI 全部通过:fmt、sync-lint、clippy 通过;axvisor x86_64 SVM hosted、self-hosted x86_64/UEFI、aarch64/riscv64/loongarch64 qemu 均通过。28 个 skipped 为正常的 matrix 互斥/path filter 行为。

重复/重叠分析

与 PR #1135(Asus NUC 板级支持)在 5 个文件上有 partial-overlap(主要是 vmx/vcpu.rsaxvisor/images/mod.rs、axbuild context)。#1166 是基础动态平台支持,应先于 #1135 合入。

前轮 review thread

唯一未解决 thread 是 setup_qemu.sh 的 QEMU config 路径问题,已在当前 head 修复(路径改为 configs/qemu/qemu-x86_64-linux.toml + 存在性检查)。

@ZR233
ZR233 merged commit 9d83465 into dev Jun 9, 2026
61 of 62 checks passed
@ZR233
ZR233 deleted the dyn_x86 branch June 9, 2026 08:16
@github-actions github-actions Bot mentioned this pull request Jun 9, 2026
aptacc2421 pushed a commit to aptacc2421/tgoskits that referenced this pull request Jun 14, 2026
* feat: Refactor Axvisor to support dynamic platform features and improve QEMU integration

* feat: update VM configuration to use linux-vmx-smp1.toml for x86_64

* fix(x86): enforce command line requirement for direct boot configuration

* feat: update command line parameters for Linux direct boot and enhance MP table alignment

* feat(x86): enhance paging logic and add NXE support for boot page tables

* feat(qemu): restruct testcase for VMX and SVM on qemu

* feat(qemu): enhance error message for missing QEMU configs in test case discovery

* fix(qemu): improve target suffix handling in dynamic x86_64 check

* fix(qemu): update monitor configuration and clarify passthrough address comments

* fix(qemu): update QEMU configuration paths in guest setup script
luodeb pushed a commit that referenced this pull request Jun 30, 2026
* feat: Refactor Axvisor to support dynamic platform features and improve QEMU integration

* feat: update VM configuration to use linux-vmx-smp1.toml for x86_64

* fix(x86): enforce command line requirement for direct boot configuration

* feat: update command line parameters for Linux direct boot and enhance MP table alignment

* feat(x86): enhance paging logic and add NXE support for boot page tables

* feat(qemu): restruct testcase for VMX and SVM on qemu

* feat(qemu): enhance error message for missing QEMU configs in test case discovery

* fix(qemu): improve target suffix handling in dynamic x86_64 check

* fix(qemu): update monitor configuration and clarify passthrough address comments

* fix(qemu): update QEMU configuration paths in guest setup script
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.

2 participants