Repository navigation
virt_support_x86emu: inject descriptor operand faults into the guest - #5239
Open
Sunil Muthuswamy (sunilmut) wants to merge 2 commits into
Open
Sunil Muthuswamy (sunilmut) wants to merge 2 commits into
Sunil Muthuswamy (sunilmut) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical descriptor-operand page-fault path drops the fault address in TDX, leaving CR2 stale and risking incorrect or repeated guest faults; CR2 propagation and a regression check are needed.
1 open issue
What changed in this PR
This PR changes OpenHCL’s TDX descriptor-operand emulation to inject guest exceptions instead of treating ordinary access faults as fatal errors.
Changes:
- Adds
MemoryOpOutcometo distinguish completed accesses from injected faults while preserving fatal host-side errors. - Updates all four TDX callers to stop before changing registers or advancing RIP after a fault.
- Adds tests for page faults, non-canonical addresses, successful accesses, and fatal host-memory failures.
| File | Description |
|---|---|
vmm_core/virt_support_x86emu/tests/tests/translate.rs |
Adds memory-only emulation success and fault regression tests. |
vmm_core/virt_support_x86emu/src/emulate.rs |
Injects operand exceptions and returns an explicit completion outcome. |
openhcl/virt_mshv_vtl/src/processor/tdx/mod.rs |
Stops descriptor-instruction completion when an operand fault is injected. |
Review effort: Balanced
The memory-only emulation helper used by TDX descriptor-table instructions treated every error as fatal, so an ordinary guest page fault on an SGDT/SIDT/LGDT/LIDT/SLDT/STR/LLDT/LTR operand stopped OpenHCL. Inject architectural exceptions into the guest instead and report the outcome, so TDX callers skip state updates and leave RIP on the faulting instruction. Host-side memory failures remain fatal. Test changes: - Verify a non-present operand page injects #PF, not a fatal error. - Verify a non-canonical operand address injects #GP. - Verify host-side memory failures remain fatal. - Verify mapped operands still read and write correctly.
Copy the pending exception's fault address to the runner's shared CR2 state before injecting a page fault. Leave CR2 unchanged for other exceptions so descriptor operand faults reach the guest with the correct faulting linear address.
Sunil Muthuswamy (sunilmut)
force-pushed
the
user/sunilmut/tdx-descriptor-fault-repro
branch
from
November 26, 2026 22:41
fcb4b3d to
fd88dcb
Compare
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The change affects TDX exception delivery and CR2 state across the OpenHCL/VTL0 trust boundary, while mock tests leave VM-entry delivery and instruction retry unverified, requiring hardware-backed validation and domain review.
1 open issue
Review effort: Balanced
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.

emulate_insn_memory_op, the memory-only emulation helper used by TDXdescriptor-table instructions, passed every error to
fatal_error. Anordinary guest fault on an SGDT/SIDT/LGDT/LIDT/SLDT/STR/LLDT/LTR operand (for
example a non-present page) therefore stopped OpenHCL instead of delivering
the architectural exception to the guest. The full instruction emulation path
already injects these.
This change:
#[must_use]MemoryOpOutcome:Completed, orFaultInjectedwhen the access faulted and the exception was injected.InstructionExceptionerrors (segmentation, canonical, alignment)and
MemoryAccesserrors throughinject_memory_access_fault, matching thefull emulation path. Failures with no guest event, such as host-side memory
errors, remain fatal.
RIP on
FaultInjected, so the guest re-executes the instruction afterhandling the fault. This matches their existing CPL/UMIP #GP early returns.
On TDX,
check_vtl_accessalways succeeds and translation errors are #PF or#GP, so only exception events reach TDX's
inject_pending_event.Test changes:
address, leaving memory and RIP unchanged (fatal
TripleFaultbefore).