Skip to content

x86/tdx: Add TDG.MR.KEY.GET ABI support#149

Merged
mingweishih merged 1 commit into
microsoft:project/hcl-dev/6.18from
mingweishih:tdx-mr-key-get-hcl-dev-6.18
Jun 30, 2026
Merged

x86/tdx: Add TDG.MR.KEY.GET ABI support#149
mingweishih merged 1 commit into
microsoft:project/hcl-dev/6.18from
mingweishih:tdx-mr-key-get-hcl-dev-6.18

Conversation

@mingweishih

Copy link
Copy Markdown

Add support for the TDG.MR.KEY.GET TDCALL, which derives a persistent, hardware-bound sealing key for the TD customized to its measurements and policy. Add the tdx_mcall_key_get() wrapper, the TDX_CMD_KEY_GET ioctl with its tdx_key_get_req UAPI structure, and the tdx_guest driver handler that marshals the TDKEYREQUEST input and key output buffers with the alignment required by the TDX module ABI.

Copilot AI review requested due to automatic review settings June 26, 2026 00:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds TDG.MR.KEY.GET support to the x86 TDX guest stack by exposing a new userspace ioctl and wiring it to a new in-kernel TDCALL wrapper, enabling derivation of a persistent sealing key bound to TD measurements/policy.

Changes:

  • Introduces struct tdx_key_get_req and TDX_CMD_KEY_GET ioctl in the TDX guest UAPI.
  • Implements TDX_CMD_KEY_GET handling in the tdx-guest driver, including userspace marshalling of TDKEYREQUEST and key output buffers.
  • Adds the TDG_MR_KEY_GET leaf ID and a tdx_mcall_key_get() wrapper for invoking the TDCALL.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
include/uapi/linux/tdx-guest.h Adds the KEY.GET ioctl UAPI struct and command definition.
drivers/virt/coco/tdx-guest/tdx-guest.c Adds ioctl handler that allocates/marshals KEY.GET buffers and calls into the TDX module wrapper.
arch/x86/include/asm/tdx.h Declares the new tdx_mcall_key_get() wrapper.
arch/x86/include/asm/shared/tdx.h Adds the TDG.MR.KEY.GET TDCALL leaf ID constant.
arch/x86/coco/tdx/tdx.c Implements tdx_mcall_key_get() wrapper calling __tdcall().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/uapi/linux/tdx-guest.h Outdated
Comment thread drivers/virt/coco/tdx-guest/tdx-guest.c Outdated
Comment thread drivers/virt/coco/tdx-guest/tdx-guest.c Outdated
Comment thread drivers/virt/coco/tdx-guest/tdx-guest.c Outdated
Add support for the TDG.MR.KEY.GET TDCALL, which derives a persistent,
hardware-bound sealing key for the TD customized to its measurements and
policy. Add the tdx_mcall_key_get() wrapper, the TDX_CMD_KEY_GET ioctl
with its tdx_key_get_req UAPI structure, and the tdx_guest driver handler
that marshals the TDKEYREQUEST input and key output buffers with the
alignment required by the TDX module ABI.

[mishih: fix typos and a misplaced apostrophe from the original patch;
 use _IOWR since the ioctl both reads the request and writes back the
 key and error code; document that kmalloc()/kzalloc() satisfy the 128B
 and 32B buffer alignment for these power-of-two sizes; write err_code
 back on success so callers do not observe a stale value; and use
 kfree_sensitive() to clear keying material]

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Ming-Wei Shih <mishih@microsoft.com>
@mingweishih mingweishih force-pushed the tdx-mr-key-get-hcl-dev-6.18 branch from 5b96828 to b674e6c Compare June 26, 2026 18:56
@mingweishih mingweishih merged commit c67dbc1 into microsoft:project/hcl-dev/6.18 Jun 30, 2026
11 checks passed
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