|
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,6 +137,42 @@ int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport)
|
136 | 137 | }
|
137 | 138 | EXPORT_SYMBOL_GPL(tdx_mcall_get_report0);
|
138 | 139 |
|
| 140 | +/** |
| 141 | + * tdx_mcall_extend_rtmr() - Wrapper to extend RTMR registers using |
| 142 | + * TDG.MR.RTMR.EXTEND TDCALL. |
| 143 | + * @index: Index of RTMR register to be extended. |
| 144 | + * @data: Address of the input buffer with RTMR register extend data. |
| 145 | + * |
| 146 | + * Refer to section titled "TDG.MR.RTMR.EXTEND leaf" in the TDX Module v1.0 |
| 147 | + * specification for more information on TDG.MR.RTMR.EXTEND TDCALL. |
| 148 | + * |
| 149 | + * It is used in the TDX guest driver module to allow user to extend the RTMR |
| 150 | + * registers. |
| 151 | + * |
| 152 | + * Return 0 on success, -ENXIO for invalid operands, -EBUSY for busy operation, |
| 153 | + * or -EIO on other TDCALL failures. |
| 154 | + */ |
| 155 | +int tdx_mcall_extend_rtmr(u8 index, u8 *data) |
| 156 | +{ |
| 157 | + struct tdx_module_args args = { |
| 158 | + .rcx = virt_to_phys(data), |
| 159 | + .rdx = index, |
| 160 | + }; |
| 161 | + u64 ret; |
| 162 | + |
| 163 | + ret = __tdcall(TDG_MR_RTMR_EXTEND, &args); |
| 164 | + if (ret) { |
| 165 | + if (TDCALL_RETURN_CODE(ret) == TDCALL_INVALID_OPERAND) |
| 166 | + return -ENXIO; |
| 167 | + if (TDCALL_RETURN_CODE(ret) == TDCALL_OPERAND_BUSY) |
| 168 | + return -EBUSY; |
| 169 | + return -EIO; |
| 170 | + } |
| 171 | + |
| 172 | + return 0; |
| 173 | +} |
| 174 | +EXPORT_SYMBOL_GPL(tdx_mcall_extend_rtmr); |
| 175 | + |
139 | 176 | /**
|
140 | 177 | * tdx_hcall_get_quote() - Wrapper to request TD Quote using GetQuote
|
141 | 178 | * hypercall.
|
|
0 commit comments