mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-14 06:22:34 +02:00
Some early TDX-capable platforms have an erratum where a partial write to TDX private memory can cause a machine check on a subsequent read. On these platforms, kexec and kdump have been disabled in these cases, because the old kernel cannot safely hand off TDX state to the new kernel. Later TDX modules support the TDH.SYS.DISABLE SEAMCALL, which provides a way to cleanly disable TDX and allow kexec to proceed. The new SEAMCALL has an enumeration bit, but that is ignored. It is expected that users will be using the latest TDX module, and the failure mode for running the missing SEAMCALL on an older module is not fatal. This can be a long running operation, and the time needed largely depends on the amount of memory that has been allocated to TDs. If all TDs have been destroyed prior to the sys_disable call, then it is fast, with only needing to override the TDX module memory. After the SEAMCALL completes, the TDX module is disabled and all memory resources allocated to TDX are freed and reset. The next kernel can then re-initialize the TDX module from scratch via the normal TDX bring-up sequence. The SEAMCALL can return two different error codes that expect a retry. - TDX_INTERRUPTED_RESUMABLE can be returned in the case of a host interrupt. However, it will not return until it makes some forward progress, so we can expect to complete even in the case of interrupt storms. - TDX_SYS_BUSY will be returned on contention with other TDH.SYS.* SEAMCALLs, however a side effect of TDH.SYS.DISABLE is that it will block other SEAMCALLs once it gets going. So this contention will be short lived. So loop infinitely on either of these error codes, until success or other error. An error is printed if the SEAMCALL fails with anything other than the error codes that cause retries, or 'synthesized' error codes produced for #GP or #UD. e.g., an old module that has been properly initialized, that doesn't implement SYS_DISABLE, returns TDX_OPERAND_INVALID. This prints: virt/tdx: TDH.SYS.DISABLE failed: 0xc000010000000000 But a system that doesn't have any TDX support at all doesn't print anything. Co-developed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Chao Gao <chao.gao@intel.com> Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org> Acked-by: Kai Huang <kai.huang@intel.com> Link: https://patch.msgid.link/20260402-fuller_tdx_kexec_support-v3-3-34438d7094bf@intel.com
41 lines
1.6 KiB
C
41 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* architectural status code for SEAMCALL */
|
|
#ifndef _ASM_X86_SHARED_TDX_ERRNO_H
|
|
#define _ASM_X86_SHARED_TDX_ERRNO_H
|
|
|
|
#define TDX_SEAMCALL_STATUS_MASK 0xFFFFFFFF00000000ULL
|
|
|
|
/*
|
|
* TDX SEAMCALL Status Codes (returned in RAX)
|
|
*/
|
|
#define TDX_NON_RECOVERABLE_VCPU 0x4000000100000000ULL
|
|
#define TDX_NON_RECOVERABLE_TD 0x4000000200000000ULL
|
|
#define TDX_NON_RECOVERABLE_TD_NON_ACCESSIBLE 0x6000000500000000ULL
|
|
#define TDX_NON_RECOVERABLE_TD_WRONG_APIC_MODE 0x6000000700000000ULL
|
|
#define TDX_INTERRUPTED_RESUMABLE 0x8000000300000000ULL
|
|
#define TDX_SYS_BUSY 0x8000020200000000ULL
|
|
#define TDX_OPERAND_INVALID 0xC000010000000000ULL
|
|
#define TDX_OPERAND_BUSY 0x8000020000000000ULL
|
|
#define TDX_PREVIOUS_TLB_EPOCH_BUSY 0x8000020100000000ULL
|
|
#define TDX_PAGE_METADATA_INCORRECT 0xC000030000000000ULL
|
|
#define TDX_VCPU_NOT_ASSOCIATED 0x8000070200000000ULL
|
|
#define TDX_KEY_GENERATION_FAILED 0x8000080000000000ULL
|
|
#define TDX_KEY_STATE_INCORRECT 0xC000081100000000ULL
|
|
#define TDX_KEY_CONFIGURED 0x0000081500000000ULL
|
|
#define TDX_NO_HKID_READY_TO_WBCACHE 0x0000082100000000ULL
|
|
#define TDX_FLUSHVP_NOT_DONE 0x8000082400000000ULL
|
|
#define TDX_EPT_WALK_FAILED 0xC0000B0000000000ULL
|
|
#define TDX_EPT_ENTRY_STATE_INCORRECT 0xC0000B0D00000000ULL
|
|
#define TDX_METADATA_FIELD_NOT_READABLE 0xC0000C0200000000ULL
|
|
|
|
/*
|
|
* TDX module operand ID, appears in 31:0 part of error code as
|
|
* detail information
|
|
*/
|
|
#define TDX_OPERAND_ID_RCX 0x01
|
|
#define TDX_OPERAND_ID_TDR 0x80
|
|
#define TDX_OPERAND_ID_SEPT 0x92
|
|
#define TDX_OPERAND_ID_TD_EPOCH 0xa9
|
|
|
|
#endif /* _ASM_X86_SHARED_TDX_ERRNO_H */
|