Repository navigation
Conversation
Clear the undefined VM-exit instruction length in the EPT MMIO emulation branch so the existing emulator determines the decoded length and next RIP. Add an IOAPIC regression covering native and injected lengths 0, 1, 2, 6, and 15. All six cases pass with the fix. With an identical separate GS workaround, three minimal Linux boots and three LinuxKit shell/poweroff tests also pass. Bare-metal Intel Mac validation is still unavailable. Signed-off-by: MrXhh <2791341417@qq.com>
z-xhh
marked this pull request as ready for review
November 24, 2026 02:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
HyperKit uses the VM-exit instruction-length field when fetching an instruction for EPT MMIO emulation. Intel SDM Volume 3C, section 28.2.5, does not define that field for an ordinary EPT violation caused by a memory access. A stale nonzero value can therefore truncate the fetched instruction or advance RIP by the wrong amount.
For example, the regression guest performs six-byte IOAPIC accesses. Supplying a stale length of 1 causes the unmodified build to fail with
Failed to emulate instruction [0x89]; supplying 15 advances RIP into a halt guard without completing the test.Change
Set
vmexit->inst_lengthto zero in the EPT MMIO emulation branch, allowing the existing instruction emulator to fetch, decode, and determine the actual instruction length. Other exit branches are unchanged. Software-event reinjection consumes its required instruction length before this branch.Add a regression guest that writes and reads an IOAPIC register using six-byte instructions, validates the read result, and powers off. A test-only interposer supplies lengths 0, 1, 2, 6, and 15 for the target EPT exits; the native path is also tested. Success requires the guest marker and exit status 0; injected cases must also reach both MMIO exits. A timeout is a failure.
Validation
Validation covers a standalone IOAPIC regression and Linux boot comparisons, run in a Hyper-V nested-virtualization environment.
The GS-state workaround used for the Linux comparisons does not modify EPT instruction lengths. The standalone MMIO regression does not load that workaround and requires no downloaded guest kernel or disk image.
Build and regression command used for both variants:
The warning override accommodates existing upstream warnings with clang 17; this PR does not change the production build flags. The test interposer itself builds with
-Wall -Wextra -Werror.Bare-metal Intel Mac testing has not been performed.
Specification reference: Intel SDM Volume 3C, section 28.2.5.