]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: read the TDX CPUID leaf unconditionally
authorPaul Meyer <katexochen0@gmail.com>
Tue, 23 Jun 2026 10:34:12 +0000 (12:34 +0200)
committerPaul Meyer <katexochen0@gmail.com>
Tue, 23 Jun 2026 10:37:54 +0000 (12:37 +0200)
vmm.c carries the confidential-VM detection used by sd-boot/sd-stub.
Its detect_tdx() had the same dead guard as the userspace copy: it
gated the 0x21 read on CPUID_GET_HIGHEST_FUNCTION (0x80000000, the
extended max function), which is always >= 0x80000000, so the guard
never held.

Mirror the userspace fix: read leaf 0x21 directly and rely on the
IntelTDX signature, matching the kernel. An out-of-range CPUID leaf
returns the highest basic leaf's data (no fault), and 0x21 is a
synthetic TDX leaf whose presence need not be reflected in the max
basic function, so it must not be gated on it.

Ref: Linux 59bd54a84d15 ("x86/tdx: Detect running as a TDX guest in
early boot"), arch/x86/coco/tdx/tdx.c:1119 (tdx_early_init()).

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
src/boot/vmm.c

index 902f61b41c2e40176f35cef3b6b0428bdf4ccb7e..e571a3990de643831b979caf82f41f2b04768f16 100644 (file)
@@ -225,14 +225,10 @@ static bool detect_sev(void) {
 }
 
 static bool detect_tdx(void) {
-        uint32_t eax, ebx, ecx, edx;
         char sig[13] = {};
 
-        __cpuid(CPUID_GET_HIGHEST_FUNCTION, eax, ebx, ecx, edx);
-
-        if (eax < CPUID_INTEL_TDX_ENUMERATION)
-                return false;
-
+        /* Querying an unsupported CPUID leaf is harmless (it returns the highest basic leaf's data rather
+         * than faulting), so reading this leaf and matching the IntelTDX signature is sufficient. */
         cpuid_leaf(CPUID_INTEL_TDX_ENUMERATION, sig, true);
 
         if (memcmp(sig, CPUID_SIG_INTEL_TDX, sizeof(sig)) == 0)