|
22 | 22 |
|
23 | 23 | /* TDX hypercall Leaf IDs */
|
24 | 24 | #define TDVMCALL_MAP_GPA 0x10001
|
| 25 | +#define TDVMCALL_REPORT_FATAL_ERROR 0x10003 |
25 | 26 |
|
26 | 27 | /* MMIO direction */
|
27 | 28 | #define EPT_READ 0
|
@@ -140,6 +141,41 @@ int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport)
|
140 | 141 | }
|
141 | 142 | EXPORT_SYMBOL_GPL(tdx_mcall_get_report0);
|
142 | 143 |
|
| 144 | +static void __noreturn tdx_panic(const char *msg) |
| 145 | +{ |
| 146 | + struct tdx_hypercall_args args = { |
| 147 | + .r10 = TDX_HYPERCALL_STANDARD, |
| 148 | + .r11 = TDVMCALL_REPORT_FATAL_ERROR, |
| 149 | + .r12 = 0, /* Error code: 0 is Panic */ |
| 150 | + }; |
| 151 | + union { |
| 152 | + /* Define register order according to the GHCI */ |
| 153 | + struct { u64 r14, r15, rbx, rdi, rsi, r8, r9, rdx; }; |
| 154 | + |
| 155 | + char str[64]; |
| 156 | + } message; |
| 157 | + |
| 158 | + /* VMM assumes '\0' in byte 65, if the message took all 64 bytes */ |
| 159 | + strncpy(message.str, msg, 64); |
| 160 | + |
| 161 | + args.r8 = message.r8; |
| 162 | + args.r9 = message.r9; |
| 163 | + args.r14 = message.r14; |
| 164 | + args.r15 = message.r15; |
| 165 | + args.rdi = message.rdi; |
| 166 | + args.rsi = message.rsi; |
| 167 | + args.rbx = message.rbx; |
| 168 | + args.rdx = message.rdx; |
| 169 | + |
| 170 | + /* |
| 171 | + * This hypercall should never return and it is not safe |
| 172 | + * to keep the guest running. Call it forever if it |
| 173 | + * happens to return. |
| 174 | + */ |
| 175 | + while (1) |
| 176 | + __tdx_hypercall(&args, 0); |
| 177 | +} |
| 178 | + |
143 | 179 | static void tdx_parse_tdinfo(u64 *cc_mask)
|
144 | 180 | {
|
145 | 181 | struct tdx_module_output out;
|
@@ -172,7 +208,7 @@ static void tdx_parse_tdinfo(u64 *cc_mask)
|
172 | 208 | */
|
173 | 209 | td_attr = out.rdx;
|
174 | 210 | if (!(td_attr & ATTR_SEPT_VE_DISABLE))
|
175 |
| - panic("TD misconfiguration: SEPT_VE_DISABLE attibute must be set.\n"); |
| 211 | + tdx_panic("TD misconfiguration: SEPT_VE_DISABLE attribute must be set."); |
176 | 212 | }
|
177 | 213 |
|
178 | 214 | /*
|
|
0 commit comments