[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230908175644.2478924-1-sagis@google.com>
Date: Fri, 8 Sep 2023 10:56:44 -0700
From: Sagi Shahar <sagis@...gle.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Jun Nakajima <jun.nakajima@...el.com>,
Isaku Yamahata <isaku.yamahata@...el.com>,
Erdem Aktas <erdemaktas@...gle.com>,
Vishal Annapurve <vannapurve@...gle.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Nikolay Borisov <nik.borisov@...e.com>,
"Jason A. Donenfeld" <Jason@...c4.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, Sagi Shahar <sagis@...gle.com>
Subject: [PATCH] x86/tdx: Allow extended topology CPUID leafs to be emulated
by hypercall
The current TDX module does not handle extended topology leaves
explicitly and will generate a #VE but the current #VE handler
implementation blindly returns 0 for those CPUID leaves.
This currently causes TDX guests to see 0 values when querying the numa
topology leading to incorrect numa configurations.
This patch fixes this behavior by emulating the extended topology leaves
using the CPUID hypercall.
Change-Id: I427807e3ac8d9e3be50a6fac40ebd3f54b445b0c
Signed-off-by: Sagi Shahar <sagis@...gle.com>
---
arch/x86/coco/tdx/tdx.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 1d6b863c42b0..db9a4673555a 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -321,13 +321,16 @@ static int handle_cpuid(struct pt_regs *regs, struct ve_info *ve)
};
/*
- * Only allow VMM to control range reserved for hypervisor
- * communication.
+ * Only emulate CPUID in 2 cases:
+ * - CPUID is in the range reserved for hypervisor communication.
+ * - CPUID is an extended topology leaf which is not emulated natively
+ * by the TDX module.
*
- * Return all-zeros for any CPUID outside the range. It matches CPU
- * behaviour for non-supported leaf.
+ * Return all-zeros for any other CPUID. It matches CPU behaviour for
+ * non-supported leaf.
*/
- if (regs->ax < 0x40000000 || regs->ax > 0x4FFFFFFF) {
+ if ((regs->ax < 0x40000000 || regs->ax > 0x4FFFFFFF) &&
+ regs->ax != 0x0b && regs->ax != 0x1f) {
regs->ax = regs->bx = regs->cx = regs->dx = 0;
return ve_instr_len(ve);
}
--
2.42.0.283.g2d96d420d3-goog
Powered by blists - more mailing lists