Skip to content

[Bug]: NEM/Windows: APIC TPR loses its low 4 bits on every exit under Hyper-V #932

Open

Description

@ctrondlp

Version

trunk/main

Host OS Type

Windows

Host OS name + version

Windows 11 Home 25H2 (build 26200)

Host Architecture

x86

Guest OS Type

other

Guest Architecture

x86

Guest OS name + version

Validation Kit bootsector test bs3-apic-1

Component

VMM

What happened?

When VirtualBox runs a VM through Hyper-V (NEM), the guest's APIC TPR loses bits 3:0. The guest writes 0xff to the TPR and reads back 0xf0.

In NEMR3Native-win-x86.cpp, nemR3WinCopyStateFromX64Header (on nearly every exit) and nemHCWinCopyStateFromHyperV copy CR8 into VirtualBox's APIC with PDMApicSetTpr(pVCpu, cr8 << 4). CR8 only holds TPR bits 7:4, so this overwrites the low nibble the guest wrote through the APIC, even when CR8 didn't change.

Expected: the TPR keeps the value the guest wrote, as on real hardware and with VT-x/AMD-V. Only a MOV to CR8 should replace it (and clear bits 3:0).

Why it matters: guests that read back the TPR, for example to save and restore it, get a different value than they wrote. Interrupt acceptance only uses bits 7:4, so delivery itself isn't affected. It also means the APIC test bs3-apic-1 can't pass on Windows hosts with Hyper-V active, which is common on Windows 11.

How can we reproduce this?

  1. On a Windows host with Hyper-V active (VirtualBox shows the turtle icon / uses NEM), run the Validation Kit test bs3-apic-1.
  2. On trunk b6bea72 (Intel Core Ultra 7 270K Plus), it fails with 1202 errors. 1200 of them are "Setting TPR to 0x.. failed, read back 0x.0".

Only updating the APIC TPR when CR8 actually changed removes those 1200 errors. I'll open a PR with that fix.

The other 2 errors ("Disabling the APIC did not work (0xfee00900)", once in real mode and once in protected mode) are a separate problem and not part of this issue.

Attachment:
bs3-apic-1-trunk-hyperv.txt - bs3-apic-1 output on unpatched trunk b6bea72, run through Hyper-V (NEM); the TPR failures are lines 15-1218, the 2 other errors are lines 5 and 9.

Did you upload all of your necessary log files, screenshots, etc.?

  • Yes, I've uploaded all pertinent files to this issue.

Activity

  1. added
    bug
    on Oct 24, 2026
  2. ctrondlp commented on Oct 24, 2026

    @ctrondlp
    Author

    Fix: #933

  3. ctrondlp commented on Oct 24, 2026

    @ctrondlp
    Author

    Update: the fix in #933 keeps TPR bits 3:0 while CR8 still equals TPR bits 7:4, but it still calls PDMApicSetTpr on every exit rather than only when CR8 changed (as written above), because setting the TPR also updates the PPR and signals pending interrupts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions