Skip to content

Commit b18651f

Browse files
kaihuanghansendc
authored andcommitted
x86/kexec: Disable kexec/kdump on platforms with TDX partial write erratum
Some early TDX-capable platforms have an erratum: A kernel partial write (a write transaction of less than cacheline lands at memory controller) to TDX private memory poisons that memory, and a subsequent read triggers a machine check. On those platforms, the old kernel must reset TDX private memory before jumping to the new kernel, otherwise the new kernel may see unexpected machine check. Currently the kernel doesn't track which page is a TDX private page. For simplicity just fail kexec/kdump for those platforms. Leverage the existing machine_kexec_prepare() to fail kexec/kdump by adding the check of the presence of the TDX erratum (which is only checked for if the kernel is built with TDX host support). This rejects kexec/kdump when the kernel is loading the kexec/kdump kernel image. The alternative is to reject kexec/kdump when the kernel is jumping to the new kernel. But for kexec this requires adding a new check (e.g., arch_kexec_allowed()) in the common code to fail kernel_kexec() at early stage. Kdump (crash_kexec()) needs similar check, but it's hard to justify because crash_kexec() is not supposed to abort. It's feasible to further relax this limitation, i.e., only fail kexec when TDX is actually enabled by the kernel. But this is still a half measure compared to resetting TDX private memory so just do the simplest thing for now. The impact to userspace is the users will get an error when loading the kexec/kdump kernel image: kexec_load failed: Operation not supported This might be confusing to the users, thus also print the reason in the dmesg: [..] kexec: Not allowed on platform with tdx_pw_mce bug. Signed-off-by: Kai Huang <kai.huang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Tested-by: Farrah Chen <farrah.chen@intel.com> Link: https://lore.kernel.org/all/20250901160930.1785244-5-pbonzini%40redhat.com
1 parent 10df860 commit b18651f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

arch/x86/kernel/machine_kexec_64.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,22 @@ int machine_kexec_prepare(struct kimage *image)
347347
unsigned long reloc_end = (unsigned long)__relocate_kernel_end;
348348
int result;
349349

350+
/*
351+
* Some early TDX-capable platforms have an erratum. A kernel
352+
* partial write (a write transaction of less than cacheline
353+
* lands at memory controller) to TDX private memory poisons that
354+
* memory, and a subsequent read triggers a machine check.
355+
*
356+
* On those platforms the old kernel must reset TDX private
357+
* memory before jumping to the new kernel otherwise the new
358+
* kernel may see unexpected machine check. For simplicity
359+
* just fail kexec/kdump on those platforms.
360+
*/
361+
if (boot_cpu_has_bug(X86_BUG_TDX_PW_MCE)) {
362+
pr_info_once("Not allowed on platform with tdx_pw_mce bug\n");
363+
return -EOPNOTSUPP;
364+
}
365+
350366
/* Setup the identity mapped 64bit page table */
351367
result = init_pgtable(image, __pa(control_page));
352368
if (result)

0 commit comments

Comments
 (0)