[Bug]: Windows NEM guest restart hangs with an accepted TRPM_NMI pending (candidate patch)
維護者通常 6 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 30/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- c
研究方向
Read src/VBox/VMM/VMMR3/target-x86/NEMR3Native-win-x86.cpp at NEMR3RunGC, then trace the TRPM and IEM event handling in EMR3.cpp and the native NEM run path. Review whether an accepted TRPM event needs delivery before WHP execution, including state imports and status propagation. Done means a reviewed fix builds and passes five consecutive ordinary guest restarts at three active vCPUs with fresh boot records and guest readiness after each.
由索引模型根據 Issue 內容生成。
描述
Version
7.2.12 r174389 (the captured runtime). The v7.2.22 and current main source paths were also inspected; those versions have not been tested live here.
Host OS Type
Windows
Host OS name + version
Windows 11 Pro, 10.0.26200.9550 in the captured VBox.log. Intel Core i7-13700F, 24 logical host processors, approximately 32 GiB RAM. Hyper-V is active; VirtualBox uses the NEM/WHP backend.
Host Architecture
x86-64
Guest OS Type
Windows
Guest Architecture
x86-64
Guest OS name + version
Windows 11, build 26100 (Guest Additions logs report 10.0.26100.4349); ntoskrnl file version 10.0.26100.4343.
Component
Guest SMP / VMM (Windows NEM)
What happened?
Repeated normal guest-initiated restarts can stop before the VM reset. In the captured failed run, one target vCPU was idle with a pending TRPM event of type 3 (TRPM_NMI), while the NMI force flag was already cleared.
A candidate patch is included below. It has not been built as a complete VMM or validated in a live VM. We are asking for review and, if the approach is suitable, a normal Oracle-signed Windows x64 test build so that we can perform the real acceptance test without changing host security settings.
The existing VM used 3 vCPUs, 4096 MiB RAM, EFI64, PIIX3, VirtualBox software APIC, and HPET enabled for this capture. A development storage filter and service were loaded in the guest. This is not an established clean-guest minimum reproduction, and the proposed hypervisor cause should be treated as a candidate rather than proof that guest drivers cannot contribute.
Expected: each ordinary Windows restart completes, all active processors participate, and a fresh guest boot becomes observable.
Observed: three restarts completed in approximately 102, 108 and 100 seconds; the fourth failed to reach a VM reset within 242 seconds. The VM reset-transition count remained at 3. A later forced power-off was recovery only and was not counted as a successful restart.
How can we reproduce this?
- On a Windows host with Hyper-V active, run an existing Windows 11 guest using the Windows NEM/WHP backend, with the configuration above.
- Issue an ordinary guest-side
shutdown /r /t 10. - Wait for a fresh Windows boot record and guest readiness, then repeat on the same running VM. Do not replace the guest restart with a VirtualBox reset.
- If it hangs, use the public
VBoxManage debugvm <vm> info cpumguest,info trpmevent,info fflags, and APIC diagnostics to inspect the halted processors. - In the captured failure, vCPU2 was the restart initiator, vCPU0 had acknowledged it, and vCPU1 remained idle with the accepted NMI still in TRPM.
This is intermittent: a short passing sequence is not sufficient evidence of a fix. We do not claim that every earlier SMP hang has this same cause.
Captured diagnostic evidence
Relevant backend lines from the failed run:
OS Product: Windows 11
OS Release: 10.0.26200.9550
HM: HMR3Init: Attempting fall back to NEM: VT-x is not available
NEM: Created partition [address omitted]. APIC emulation mode: VirtualBox
NEM: NEMR3Init: Snail execution mode is active!
CPUM: Logical host processors: 24 present, 24 max, 24 online
Guest instruction pointers resolved against the matching kernel symbols:
vCPU0: nt!HalpInterruptResetThisProcessor+0x5e
vCPU1: nt!HalProcessorIdle+0xf
vCPU2: nt!HalpNmiReboot+0xde
The following TRPM state was observed in two separate reads during the failure:
CPU[0]: TRPM event (None)
CPU[1]: TRPM event
Type = 0x3 (Invalid!)
CPU[2]: TRPM event (None)
In this version, enum value 3 is TRPM_NMI. The diagnostic name table omits that value, so the displayed Invalid! text is not by itself evidence of corrupt event data.
Force flags from the failure:
Global FFs: 0x0
CPU 0 FFs: 0x80000
TLB_FLUSH
CPU 1 FFs: 0x80000
TLB_FLUSH
CPU 2 FFs: 0x80005
INTERRUPT_APIC, TIMER, TLB_FLUSH
vCPU1 repeatedly exited through HLT. The initiating CPU's APIC ICR was consistent with targeting vCPU0/vCPU1 (NMI logical destination; low 0x0c00, high 0x03000000; LDR values 1/2/4). Please distinguish an injection-attempt counter from proof that the guest handler actually ran.
These are selected diagnostic excerpts. A full unredacted VBox.log, VM disks, credentials and memory dumps are not attached. I have not marked the template's “all pertinent files uploaded” checkbox as completed.
Suspected code path
In v7.2.12 EMR3.cpp, EM can accept an NMI into TRPM with TRPMAssertTrap(..., TRPM_NMI), clear VMCPU_FF_INTERRUPT_NMI, and request rescheduling.
Windows NEMR3RunGC then directly enters nemHCWinRunGC. The native interrupt force-flag path handles an NMI which has not already been transferred into TRPM, and asserts that there is no pending TRPM event. This appears to leave an already accepted event without a delivery step at that transition.
The v7.2.22 NEM/EM/EMR3Nem paths and current main NEM entry were inspected on 2026-10-27 and still lack the candidate delivery step below. This is source inspection, not a claim to have reproduced the failure on those binaries.
Candidate patch against v7.2.12
The intended change is to import the IEM exception state, invalidate IEM TLB state, and inject an accepted TRPM event before native execution. Non-success status is propagated. VINF_IEM_RAISED_XCPT is an alias of VINF_EM_RESCHEDULE, so successful NMI injection can return to EM for rescheduling.
--- a/src/VBox/VMM/VMMR3/target-x86/NEMR3Native-win-x86.cpp
+++ b/src/VBox/VMM/VMMR3/target-x86/NEMR3Native-win-x86.cpp
@@ -5266,6 +5266,21 @@
VMMR3_INT_DECL(VBOXSTRICTRC) NEMR3RunGC(PVM pVM, PVMCPU pVCpu)
{
Assert(VM_IS_NEM_ENABLED(pVM));
+
+ /* EM may have accepted an NMI into TRPM while leaving the halted state.
+ Consume that accepted event before entering WHP: the native FF path
+ only sees interrupts which have not yet been transferred into TRPM. */
+ if (TRPMHasTrap(pVCpu))
+ {
+ VBOXSTRICTRC rcStrict = nemHCWinImportStateIfNeededStrict(pVCpu,
+ NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM_XCPT, "TRPM");
+ if (rcStrict != VINF_SUCCESS)
+ return rcStrict;
+ IEMTlbInvalidateAll(pVCpu);
+ rcStrict = IEMInjectTrpmEvent(pVCpu);
+ if (rcStrict != VINF_SUCCESS)
+ return rcStrict;
+ }
return nemHCWinRunGC(pVM, pVCpu);
}
Validation performed and request
An extracted-entry regression test failed on the old body and passed five cases on this candidate. It used substituted import/IEM/native boundaries. It therefore checks ordering and status propagation only: it does not exercise real IEM, EM, WHP, NMI blocking or a running guest. Source review did not identify a confirmed functional error, but full build and integration validation remain open.
Could the VirtualBox team review this candidate and provide an Oracle-signed Windows x64 test build containing either this change or an equivalent fix? We can validate it on the existing VM with five consecutive normal guest-initiated restarts at three active vCPUs, checking a new boot record and service/driver readiness after each. No forced reset, pause/resume, injected NMI or host security changes would count as passing.
Related report #799 concerns a different primary symptom (EFI boot hang). We have not established that it shares this exact cause.
This report and the candidate patch were prepared with AI assistance from captured diagnostics and source review. Original upstream licensing/notices remain applicable. This is not presented as a verified fix or an Oracle release.
- 主要語言
- C
- 星號
- 1.4k
- 分支
- 219
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
VirtualBox/virtualbox 的其他 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
VirtualBox/virtualbox#979 ·
維護者通常 6 天內回覆
-
[Bug]: Guest Additions 7.2.20 vboxvideo fails to build on Linux kernel 6.12.113 (drm_fb_helper_restore_fbdev_mode_unlocked: too few arguments)可能已有人在做 @Berbe 於 11 天前認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
VirtualBox/virtualbox#918 · 9 則留言 ·
維護者通常 6 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 12/100
VirtualBox/virtualbox#981 ·
維護者通常 6 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 8/100
VirtualBox/virtualbox#980 ·
維護者通常 6 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 18/100
VirtualBox/virtualbox#977 ·
維護者通常 6 天內回覆
查看 VirtualBox/virtualbox 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
ROCm/rocm-libraries#15866 ·
維護者通常 2 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 62/100
adafruit/circuitpython#11877 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 75/100
-
[Qt] Fix QString conversion for game name in game_list_actions.cpp可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 1/5 1 小時以內 新手友好度 66/100
維護者通常 1 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆