[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/10] i386/cpu: Set up CPUID_HT in x86_cpu_expand_features()
From: |
Xiaoyao Li |
Subject: |
[PATCH v2 09/10] i386/cpu: Set up CPUID_HT in x86_cpu_expand_features() instead of cpu_x86_cpuid() |
Date: |
Thu, 19 Dec 2024 06:01:24 -0500 |
Currently CPUID_HT is evaluated in cpu_x86_cpuid() each time. It's not a
correct usage of how feature bit is maintained and evaluated. The
expected practice is that features are tracked in env->features[] and
cpu_x86_cpuid() should be the consumer of env->features[].
Track CPUID_HT in env->features[FEAT_1_EDX] instead and evaluate it in
cpu's realizefn().
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
There is one issue[1] of CPUID_HT being user settable that when
"-cpu xxx,-ht" with "-smp 2", HT flag is still exposed to guest.
However, the issue is not irrelevant to this patch. If anyone has
interest to reslove it please go ahead.
[1] Z1FUDGnenETEFV6Z@intel.com/">https://lore.kernel.org/qemu-devel/Z1FUDGnenETEFV6Z@intel.com/
---
target/i386/cpu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index fd59da5d445d..bee494bdd029 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6537,7 +6537,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,
uint32_t count,
*edx = env->features[FEAT_1_EDX];
if (threads_per_pkg > 1) {
*ebx |= threads_per_pkg << 16;
- *edx |= CPUID_HT;
}
if (!cpu->enable_pmu) {
*ecx &= ~CPUID_EXT_PDCM;
@@ -7528,6 +7527,10 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
}
}
+ if (x86_threads_per_pkg(&env->topo_info) > 1) {
+ env->features[FEAT_1_EDX] |= CPUID_HT;
+ }
+
for (i = 0; i < ARRAY_SIZE(feature_dependencies); i++) {
FeatureDep *d = &feature_dependencies[i];
if (!(env->features[d->from.index] & d->from.mask)) {
--
2.34.1
- [PATCH v2 00/10] i386: Track X86CPUTopoInfo in CPUX86State and track features in env->features[], Xiaoyao Li, 2024/12/19
- [PATCH v2 01/10] i386/cpu: Extract a common fucntion to setup value of MSR_CORE_THREAD_COUNT, Xiaoyao Li, 2024/12/19
- [PATCH v2 04/10] i386/topology: Update the comment of x86_apicid_from_topo_ids(), Xiaoyao Li, 2024/12/19
- [PATCH v2 03/10] i386/cpu: Drop cores_per_pkg in cpu_x86_cpuid(), Xiaoyao Li, 2024/12/19
- [PATCH v2 05/10] i386/topology: Introduce helpers for various topology info of different level, Xiaoyao Li, 2024/12/19
- [PATCH v2 06/10] i386/cpu: Track a X86CPUTopoInfo directly in CPUX86State, Xiaoyao Li, 2024/12/19
- [PATCH v2 02/10] i386/cpu: Drop the variable smp_cores and smp_threads in x86_cpu_pre_plug(), Xiaoyao Li, 2024/12/19
- [PATCH v2 07/10] i386/cpu: Hoist check of CPUID_EXT3_TOPOEXT against threads_per_core, Xiaoyao Li, 2024/12/19
- [PATCH v2 08/10] cpu: Remove nr_cores from struct CPUState, Xiaoyao Li, 2024/12/19
- [PATCH v2 09/10] i386/cpu: Set up CPUID_HT in x86_cpu_expand_features() instead of cpu_x86_cpuid(),
Xiaoyao Li <=
- [PATCH v2 10/10] i386/cpu: Set and track CPUID_EXT3_CMP_LEG in env->features[FEAT_8000_0001_ECX], Xiaoyao Li, 2024/12/19