Skip to content

virt_mshv_vtl: fix TDX legacy LGDT/LIDT descriptor decode panic - #5238

Open
Sunil Muthuswamy (sunilmut) wants to merge 1 commit into
microsoft:mainfrom
sunilmut:user/sunilmut/tdx-legacy-descriptor-repro
Open

Sunil Muthuswamy (sunilmut) wants to merge 1 commit into
microsoft:mainfrom
sunilmut:user/sunilmut/tdx-legacy-descriptor-repro

Conversation

@sunilmut

Copy link
Copy Markdown
Member

For LGDT/LIDT outside long mode, TDX descriptor-table emulation correctly
reads a 6-byte operand (2-byte limit, 4-byte base), but then converted the
4 base bytes with u64::from_le_bytes(buf[2..len].try_into().unwrap()),
which always panics for a valid legacy operand.

This change moves the decode into decode_table_register, which accepts only
6- or 10-byte descriptors and zero-extends the little-endian base into a
64-bit value. The decoding no longer contains any fallible conversions.

Test changes:

  • A legacy 6-byte descriptor decodes its limit and 32-bit base (panicked
    before the fix).
  • A long-mode 10-byte descriptor keeps its full 64-bit base.

@sunilmut
Sunil Muthuswamy (sunilmut) requested a review from a team as a code owner November 23, 2026 00:37
Copilot AI balanced review requested due to automatic review settings November 23, 2026 00:37

Copilot AI 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.

🟢 Approval recommended

No active review issues block approval of the legacy descriptor-decoding fix.

No open issues 🎉

What changed in this PR

Fixes a panic in OpenHCL’s TDX emulation of legacy LGDT/LIDT instructions while preserving long-mode descriptor decoding.

Changes:

  • Extracts descriptor decoding into a helper that zero-extends legacy 32-bit bases and preserves full 64-bit bases.
  • Adds regression tests for both descriptor formats and the tracing-enabled test dependency.
File Description
openhcl/​virt_mshv_vtl/​src/​processor/​tdx/​mod.rs Adds the decoding helper, integrates it into descriptor loads, and tests both formats.
openhcl/​virt_mshv_vtl/​Cargo.toml Adds test_with_tracing as a development dependency.
Cargo.lock Records the new test dependency for virt_mshv_vtl.

Review effort: Balanced

Legacy-mode LGDT/LIDT descriptors carry a 4-byte base, but the decoder
always converted the base bytes to a u64, panicking on valid input.
Zero-extend the legacy 32-bit base and validate the descriptor length.

Test changes:
- Verify a legacy 6-byte descriptor decodes without panicking.
- Verify a long-mode 10-byte descriptor keeps its full 64-bit base.
@sunilmut
Sunil Muthuswamy (sunilmut) force-pushed the user/sunilmut/tdx-legacy-descriptor-repro branch from 987e160 to af793ce Compare November 26, 2026 22:36
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:36

Copilot AI 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.

🟢 Approval recommended

No active review issues are recorded for the descriptor-table decoding fix.

No open issues 🎉

Review effort: Balanced

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.

3 participants