x86/tdx: Use ReportFatalError to report missing SEPT_VE_DISABLE
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Thu, 26 Jan 2023 22:11:57 +0000 (01:11 +0300)
committerDave Hansen <dave.hansen@linux.intel.com>
Fri, 27 Jan 2023 17:45:55 +0000 (09:45 -0800)
commit71acdcd7cd0abee7698c2d5e5a8a66602a00b12c
treece9455eaa669a1235d78fd0f996b38b366e34a46
parent752d13305c78b2f0f0d783132f94acc9ce93d38e
x86/tdx: Use ReportFatalError to report missing SEPT_VE_DISABLE

Linux TDX guests require that the SEPT_VE_DISABLE "attribute" be set.
If it is not set, the kernel is theoretically required to handle
exceptions anywhere that kernel memory is accessed, including places
like NMI handlers and in the syscall entry gap.

Rather than even try to handle these exceptions, the kernel refuses to
run if SEPT_VE_DISABLE is unset.

However, the SEPT_VE_DISABLE detection and refusal code happens very
early in boot, even before earlyprintk runs.  Calling panic() will
effectively just hang the system.

Instead, call a TDX-specific panic() function.  This makes a very simple
TDVMCALL which gets a short error string out to the hypervisor without
any console infrastructure.

Use TDG.VP.VMCALL<ReportFatalError> to report the error. The hypercall
can encode message up to 64 bytes in eight registers.

[ dhansen: tweak comment and remove while loop brackets. ]

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/20230126221159.8635-6-kirill.shutemov%40linux.intel.com
arch/x86/coco/tdx/tdx.c