summaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/compressed/tdx.c
diff options
context:
space:
mode:
authorKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>2022-04-06 02:29:21 +0300
committerDave Hansen <dave.hansen@linux.intel.com>2022-04-07 08:27:51 -0700
commit4b05f81504bfcaab51083d3a271fada75e6b8904 (patch)
treefcb76e069a285a4bf3c11b78560754cd46aa931a /arch/x86/boot/compressed/tdx.c
parent31d58c4e557d46fa7f8557714250fb6f89c941ae (diff)
downloadlinux-stable-4b05f81504bfcaab51083d3a271fada75e6b8904.tar.gz
linux-stable-4b05f81504bfcaab51083d3a271fada75e6b8904.tar.bz2
linux-stable-4b05f81504bfcaab51083d3a271fada75e6b8904.zip
x86/tdx: Detect TDX at early kernel decompression time
The early decompression code does port I/O for its console output. But, handling the decompression-time port I/O demands a different approach from normal runtime because the IDT required to support #VE based port I/O emulation is not yet set up. Paravirtualizing I/O calls during the decompression step is acceptable because the decompression code doesn't have a lot of call sites to IO instruction. To support port I/O in decompression code, TDX must be detected before the decompression code might do port I/O. Detect whether the kernel runs in a TDX guest. Add an early_is_tdx_guest() interface to query the cached TDX guest status in the decompression code. TDX is detected with CPUID. Make cpuid_count() accessible outside boot/cpuflags.c. TDX detection in the main kernel is very similar. Move common bits into <asm/shared/tdx.h>. The actual port I/O paravirtualization will come later in the series. Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lkml.kernel.org/r/20220405232939.73860-13-kirill.shutemov@linux.intel.com
Diffstat (limited to 'arch/x86/boot/compressed/tdx.c')
-rw-r--r--arch/x86/boot/compressed/tdx.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/boot/compressed/tdx.c b/arch/x86/boot/compressed/tdx.c
new file mode 100644
index 000000000000..5f6d01a2f1f4
--- /dev/null
+++ b/arch/x86/boot/compressed/tdx.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include "../cpuflags.h"
+#include "../string.h"
+
+#include <asm/shared/tdx.h>
+
+void early_tdx_detect(void)
+{
+ u32 eax, sig[3];
+
+ cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]);
+
+ if (memcmp(TDX_IDENT, sig, sizeof(sig)))
+ return;
+}