From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: "Zhao Liu" <zhao1.liu@intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Babu Moger" <babu.moger@amd.com>,
"Ewan Hai" <ewanhai-oc@zhaoxin.com>, "Pu Wen" <puwen@hygon.cn>,
"Tao Su" <tao1.su@intel.com>, "Yi Lai" <yi1.lai@intel.com>,
"Dapeng Mi" <dapeng1.mi@intel.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [PATCH 07/16] i386/cpu: Mark CPUID[0x80000005] as reserved for Intel
Date: Thu, 3 Jul 2025 15:07:34 +0800 [thread overview]
Message-ID: <44cdc08c-21e9-422c-b55a-17e53d34ef90@linux.intel.com> (raw)
In-Reply-To: <20250620092734.1576677-8-zhao1.liu@intel.com>
On 6/20/2025 5:27 PM, Zhao Liu wrote:
> Per SDM, 0x80000005 leaf is reserved for Intel CPU, and its current
> "assert" check blocks adding new cache model for non-AMD CPUs.
>
> And please note, although Zhaoxin mostly follows Intel behavior,
> this leaf is an exception [1].
>
> So, add a compat property "x-vendor-cpuid-only-v2" (for PC machine v10.0
> and older) to keep the original behavior. For the machine since v10.1,
> check the vendor and encode this leaf as all-0 only for Intel CPU.
>
> This fix also resolves 2 FIXMEs of legacy_l1d_cache_amd and
> legacy_l1i_cache_amd:
>
> /*FIXME: CPUID leaf 0x80000005 is inconsistent with leaves 2 & 4 */
>
> In addition, per AMD's APM, update the comment of CPUID[0x80000005].
>
> [1]: https://lore.kernel.org/qemu-devel/fa16f7a8-4917-4731-9d9f-7d4c10977168@zhaoxin.com/
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> Changes since RFC:
> * Only set all-0 for Intel CPU.
> * Add x-vendor-cpuid-only-v2.
> ---
> hw/i386/pc.c | 1 +
> target/i386/cpu.c | 11 ++++++++---
> target/i386/cpu.h | 11 ++++++++++-
> 3 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index ad2d6495ebde..9ec3f4db31f3 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -83,6 +83,7 @@
>
> GlobalProperty pc_compat_10_0[] = {
> { TYPE_X86_CPU, "x-consistent-cache", "false" },
> + { TYPE_X86_CPU, "x-vendor-cpuid-only-v2", "false" },
> };
> const size_t pc_compat_10_0_len = G_N_ELEMENTS(pc_compat_10_0);
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 8f174fb971b6..df40d1362566 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -655,7 +655,6 @@ static CPUCacheInfo legacy_l1d_cache = {
> .share_level = CPU_TOPOLOGY_LEVEL_CORE,
> };
>
> -/*FIXME: CPUID leaf 0x80000005 is inconsistent with leaves 2 & 4 */
> static CPUCacheInfo legacy_l1d_cache_amd = {
> .type = DATA_CACHE,
> .level = 1,
> @@ -684,7 +683,6 @@ static CPUCacheInfo legacy_l1i_cache = {
> .share_level = CPU_TOPOLOGY_LEVEL_CORE,
> };
>
> -/*FIXME: CPUID leaf 0x80000005 is inconsistent with leaves 2 & 4 */
> static CPUCacheInfo legacy_l1i_cache_amd = {
> .type = INSTRUCTION_CACHE,
> .level = 1,
> @@ -7889,11 +7887,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
> *edx = env->cpuid_model[(index - 0x80000002) * 4 + 3];
> break;
> case 0x80000005:
> - /* cache info (L1 cache) */
> + /* cache info (L1 cache/TLB Associativity Field) */
> if (cpu->cache_info_passthrough) {
> x86_cpu_get_cache_cpuid(index, 0, eax, ebx, ecx, edx);
> break;
> }
> +
> + if (cpu->vendor_cpuid_only_v2 && IS_INTEL_CPU(env)) {
> + *eax = *ebx = *ecx = *edx = 0;
> + break;
> + }
> +
> *eax = (L1_DTLB_2M_ASSOC << 24) | (L1_DTLB_2M_ENTRIES << 16) |
> (L1_ITLB_2M_ASSOC << 8) | (L1_ITLB_2M_ENTRIES);
> *ebx = (L1_DTLB_4K_ASSOC << 24) | (L1_DTLB_4K_ENTRIES << 16) |
> @@ -9464,6 +9468,7 @@ static const Property x86_cpu_properties[] = {
> DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor),
> DEFINE_PROP_BOOL("cpuid-0xb", X86CPU, enable_cpuid_0xb, true),
> DEFINE_PROP_BOOL("x-vendor-cpuid-only", X86CPU, vendor_cpuid_only, true),
> + DEFINE_PROP_BOOL("x-vendor-cpuid-only-v2", X86CPU, vendor_cpuid_only_v2, true),
> DEFINE_PROP_BOOL("x-amd-topoext-features-only", X86CPU, amd_topoext_features_only, true),
> DEFINE_PROP_BOOL("lmce", X86CPU, enable_lmce, false),
> DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true),
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index 8d3ce8a2b678..02cda176798f 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -2282,9 +2282,18 @@ struct ArchCPU {
> /* Enable auto level-increase for all CPUID leaves */
> bool full_cpuid_auto_level;
>
> - /* Only advertise CPUID leaves defined by the vendor */
> + /*
> + * Compatibility bits for old machine types (PC machine v6.0 and older).
> + * Only advertise CPUID leaves defined by the vendor.
> + */
> bool vendor_cpuid_only;
>
> + /*
> + * Compatibility bits for old machine types (PC machine v10.0 and older).
> + * Only advertise CPUID leaves defined by the vendor.
> + */
> + bool vendor_cpuid_only_v2;
> +
> /* Only advertise TOPOEXT features that AMD defines */
> bool amd_topoext_features_only;
>
The Intel related part looks good to me. (Not quite familiar with AMD's
Spec, so no reviewed-by tag)
next prev parent reply other threads:[~2025-07-03 7:07 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 9:27 [PATCH 00/16] i386/cpu: Unify the cache model in X86CPUState Zhao Liu
2025-06-20 9:27 ` [PATCH 01/16] i386/cpu: Refine comment of CPUID2CacheDescriptorInfo Zhao Liu
2025-07-02 8:48 ` Mi, Dapeng
2025-07-03 7:38 ` Zhao Liu
2025-06-20 9:27 ` [PATCH 02/16] i386/cpu: Add descriptor 0x49 for CPUID 0x2 encoding Zhao Liu
2025-07-02 9:04 ` Mi, Dapeng
2025-07-03 7:39 ` Zhao Liu
2025-06-20 9:27 ` [PATCH 03/16] i386/cpu: Add default cache model for Intel CPUs with level < 4 Zhao Liu
2025-07-02 9:53 ` Mi, Dapeng
2025-07-03 7:47 ` Zhao Liu
2025-06-20 9:27 ` [PATCH 04/16] i386/cpu: Present same cache model in CPUID 0x2 & 0x4 Zhao Liu
2025-07-03 4:14 ` Mi, Dapeng
2025-07-03 6:35 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 05/16] i386/cpu: Consolidate CPUID 0x4 leaf Zhao Liu
2025-06-26 12:10 ` Ewan Hai
2025-06-27 2:44 ` Zhao Liu
2025-07-03 6:41 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 06/16] i386/cpu: Drop CPUID 0x2 specific cache info in X86CPUState Zhao Liu
2025-07-03 7:03 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 07/16] i386/cpu: Mark CPUID[0x80000005] as reserved for Intel Zhao Liu
2025-07-03 7:07 ` Mi, Dapeng [this message]
2025-06-20 9:27 ` [PATCH 08/16] i386/cpu: Fix CPUID[0x80000006] for Intel CPU Zhao Liu
2025-07-03 7:09 ` Mi, Dapeng
2025-07-03 7:52 ` Zhao Liu
2025-06-20 9:27 ` [PATCH 09/16] i386/cpu: Add legacy_intel_cache_info cache model Zhao Liu
2025-07-03 7:15 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 10/16] i386/cpu: Add legacy_amd_cache_info " Zhao Liu
2025-07-03 7:18 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 11/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x2 Zhao Liu
2025-07-03 8:47 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 12/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x4 Zhao Liu
2025-07-03 8:49 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 13/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x80000005 Zhao Liu
2025-07-03 8:52 ` Mi, Dapeng
2025-06-20 9:27 ` [PATCH 14/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x80000006 Zhao Liu
2025-06-20 9:27 ` [PATCH 15/16] i386/cpu: Select legacy cache model based on vendor in CPUID 0x8000001D Zhao Liu
2025-06-20 9:27 ` [PATCH 16/16] i386/cpu: Use a unified cache_info in X86CPUState Zhao Liu
2025-07-03 8:53 ` Mi, Dapeng
2025-07-03 9:50 ` Zhao Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44cdc08c-21e9-422c-b55a-17e53d34ef90@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=babu.moger@amd.com \
--cc=berrange@redhat.com \
--cc=dapeng1.mi@intel.com \
--cc=eduardo@habkost.net \
--cc=ewanhai-oc@zhaoxin.com \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=puwen@hygon.cn \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=tao1.su@intel.com \
--cc=yi1.lai@intel.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).