Skip to content

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

Merged
mingweishih merged 1 commit into
microsoft:product/hcl-main/6.18from
mingweishih:tdx-mr-key-get-6.18-main
Jul 20, 2026
Merged

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

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.

[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]

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>
Copilot AI review requested due to automatic review settings July 20, 2026 17:28

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

This PR adds guest-kernel support for the TDX TDG.MR.KEY.GET TDCALL by introducing a new UAPI ioctl and the corresponding kernel-side plumbing to derive and return a persistent, TD-bound sealing key to userspace.

Changes:

  • Add TDX_CMD_KEY_GET ioctl and struct tdx_key_get_req UAPI to pass a TDKEYREQUEST input buffer and receive the derived key + error code.
  • Implement the ioctl handler in the tdx-guest driver, including buffer allocation/alignment handling and sensitive-memory cleanup.
  • Add a low-level tdx_mcall_key_get() wrapper and the TDG_MR_KEY_GET leaf ID constant.

Reviewed changes

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

Show a summary per file
File Description
include/uapi/linux/tdx-guest.h Adds UAPI request struct, sizes, and ioctl definition for key derivation.
drivers/virt/coco/tdx-guest/tdx-guest.c Adds the ioctl handler that marshals TDKEYREQUEST/key buffers and returns results to userspace.
arch/x86/include/asm/tdx.h Exposes the new tdx_mcall_key_get() prototype to in-kernel callers.
arch/x86/include/asm/shared/tdx.h Adds the shared TDCALL leaf ID constant for TDG.MR.KEY.GET.
arch/x86/coco/tdx/tdx.c Implements the tdx_mcall_key_get() wrapper around __tdcall().

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

Comment thread include/uapi/linux/tdx-guest.h
Comment thread include/uapi/linux/tdx-guest.h
Comment thread drivers/virt/coco/tdx-guest/tdx-guest.c

@hargar19 hargar19 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR is a copy of dev branch PR #149
that was approved by Chris and Dexuan.

@mingweishih
mingweishih merged commit 0e0dd0d into microsoft:product/hcl-main/6.18 Jul 20, 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