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>
}
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)