TDX: Allow cpuid leaf 2 emulation to return valid values
Due to an issue in glibc as reported by:
https://sourceware.org/bugzilla/show_bug.cgi?id=30037
glibc wrongly relies on non-zero values of cpuid 2 queries. For now
allow cpuid leaf 2 to be emulated so that libc falls back to querying
other supported leafs.
Signed-off-by: Vishal Annapurve <vannapurve@google.com>
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 629bf25..3f27991 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -391,7 +391,8 @@ static int handle_cpuid(struct pt_regs *regs, struct ve_info *ve)
*/
if ((regs->ax < 0x40000000 || regs->ax > 0x4FFFFFFF) &&
regs->ax != 0x0b && regs->ax != 0x1f) {
- regs->ax = regs->bx = regs->cx = regs->dx = 0;
+ regs->ax = (regs->ax == 0x2) ? 0xff01 : 0;
+ regs->bx = regs->cx = regs->dx = 0;
return ve_instr_len(ve);
}