x86/tdx: Add TDG.MR.KEY.GET ABI support - #153
Merged
mingweishih merged 1 commit intoJul 20, 2026
Merged
Conversation
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>
There was a problem hiding this comment.
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_GETioctl andstruct tdx_key_get_reqUAPI to pass a TDKEYREQUEST input buffer and receive the derived key + error code. - Implement the ioctl handler in the
tdx-guestdriver, including buffer allocation/alignment handling and sensitive-memory cleanup. - Add a low-level
tdx_mcall_key_get()wrapper and theTDG_MR_KEY_GETleaf 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.
mingweishih
merged commit Jul 20, 2026
0e0dd0d
into
microsoft:product/hcl-main/6.18
11 checks passed
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.
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]