From: Manish Mishra <manish.mis...@nutanix.com> Add a "cpuid-0x1f" property so that CPU models can enable it and have 0x1f CPUID leaf natually as the Host CPU.
The advantage is that when the CPU model's cache model is already consistent with the Host CPU, for example, SRF defaults to l2 per module & l3 per package, 0x1f can better help users identify the topology in the VM. Adding 0x1f for specific CPU models should not cause any trouble in principle. This property is only enabled for CPU models that already have 0x1f leaf on the Host, so software that originally runs normally on the Host won't encounter issues in the Guest with corresponding CPU model. Conversely, some software that relies on checking 0x1f might experience problems in the Guest due to the lack of 0x1f [*]. In summary, adding 0x1f is also intended to further emulate the Host CPU environment. Therefore, the "x-" prefix is not added to this property. [*]: https://lore.kernel.org/qemu-devel/ph0pr02mb738410511bf51b12db09be6cf6...@ph0pr02mb7384.namprd02.prod.outlook.com/ Co-authored-by: Xiaoyao Li <xiaoyao...@intel.com> (Missing signed-off from Manish & Xiaoyao) Signed-off-by: Zhao Liu <zhao1....@intel.com> --- Note: This patch integrates the idea from 2 previous posted patches (ordered by post time)[1] [2]. Although the target cases are not exactly the same as this patch, add the authorship of previous authors. [1]: From Manish: https://lore.kernel.org/qemu-devel/20240722101859.47408-1-manish.mis...@nutanix.com/ [2]: From Xiaoyao: https://lore.kernel.org/qemu-devel/20240813033145.279307-1-xiaoyao...@intel.com/ --- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e0716dbe5934..26dc5b6a6a8c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -9195,6 +9195,7 @@ static const Property x86_cpu_properties[] = { DEFINE_PROP_BOOL("x-intel-pt-auto-level", X86CPU, intel_pt_auto_level, true), DEFINE_PROP_BOOL("x-l1-cache-per-thread", X86CPU, l1_cache_per_core, true), + DEFINE_PROP_BOOL("cpuid-0x1f", X86CPU, enable_cpuid_0x1f, false), }; #ifndef CONFIG_USER_ONLY -- 2.34.1