Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/tdx: Add tdx_mcall_extend_rtmr() interface

The TDX guest exposes one MRTD (Build-time Measurement Register) and four
RTMR (Run-time Measurement Register) registers to record the build and boot
measurements of a virtual machine (VM). These registers are similar to PCR
(Platform Configuration Register) registers in the TPM (Trusted Platform
Module) space. This measurement data is used to implement security features
like attestation and trusted boot.

To facilitate updating the RTMR registers, the TDX module provides support
for the `TDG.MR.RTMR.EXTEND` TDCALL which can be used to securely extend
the RTMR registers.

Add helper function to update RTMR registers. It will be used by the TDX
guest driver in enabling RTMR extension support.

Co-developed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Cedric Xing <cedric.xing@intel.com>
Acked-by: Dionna Amalie Glaze <dionnaglaze@google.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://patch.msgid.link/20250506-tdx-rtmr-v6-3-ac6ff5e9d58a@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Cedric Xing and committed by
Dan Williams
3f88ca96 f6953f1f

+40
+37
arch/x86/coco/tdx/tdx.c
··· 36 36 /* TDX Module call error codes */ 37 37 #define TDCALL_RETURN_CODE(a) ((a) >> 32) 38 38 #define TDCALL_INVALID_OPERAND 0xc0000100 39 + #define TDCALL_OPERAND_BUSY 0x80000200 39 40 40 41 #define TDREPORT_SUBTYPE_0 0 41 42 ··· 136 135 return 0; 137 136 } 138 137 EXPORT_SYMBOL_GPL(tdx_mcall_get_report0); 138 + 139 + /** 140 + * tdx_mcall_extend_rtmr() - Wrapper to extend RTMR registers using 141 + * TDG.MR.RTMR.EXTEND TDCALL. 142 + * @index: Index of RTMR register to be extended. 143 + * @data: Address of the input buffer with RTMR register extend data. 144 + * 145 + * Refer to section titled "TDG.MR.RTMR.EXTEND leaf" in the TDX Module v1.0 146 + * specification for more information on TDG.MR.RTMR.EXTEND TDCALL. 147 + * 148 + * It is used in the TDX guest driver module to allow user to extend the RTMR 149 + * registers. 150 + * 151 + * Return 0 on success, -ENXIO for invalid operands, -EBUSY for busy operation, 152 + * or -EIO on other TDCALL failures. 153 + */ 154 + int tdx_mcall_extend_rtmr(u8 index, u8 *data) 155 + { 156 + struct tdx_module_args args = { 157 + .rcx = virt_to_phys(data), 158 + .rdx = index, 159 + }; 160 + u64 ret; 161 + 162 + ret = __tdcall(TDG_MR_RTMR_EXTEND, &args); 163 + if (ret) { 164 + if (TDCALL_RETURN_CODE(ret) == TDCALL_INVALID_OPERAND) 165 + return -ENXIO; 166 + if (TDCALL_RETURN_CODE(ret) == TDCALL_OPERAND_BUSY) 167 + return -EBUSY; 168 + return -EIO; 169 + } 170 + 171 + return 0; 172 + } 173 + EXPORT_SYMBOL_GPL(tdx_mcall_extend_rtmr); 139 174 140 175 /** 141 176 * tdx_hcall_get_quote() - Wrapper to request TD Quote using GetQuote
+1
arch/x86/include/asm/shared/tdx.h
··· 13 13 /* TDX module Call Leaf IDs */ 14 14 #define TDG_VP_VMCALL 0 15 15 #define TDG_VP_INFO 1 16 + #define TDG_MR_RTMR_EXTEND 2 16 17 #define TDG_VP_VEINFO_GET 3 17 18 #define TDG_MR_REPORT 4 18 19 #define TDG_MEM_PAGE_ACCEPT 6
+2
arch/x86/include/asm/tdx.h
··· 64 64 65 65 int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport); 66 66 67 + int tdx_mcall_extend_rtmr(u8 index, u8 *data); 68 + 67 69 u64 tdx_hcall_get_quote(u8 *buf, size_t size); 68 70 69 71 void __init tdx_dump_attributes(u64 td_attr);