[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 7/9] target/i386: Support multi-dies when host do
From: |
Like Xu |
Subject: |
[Qemu-devel] [PATCH v3 7/9] target/i386: Support multi-dies when host doesn't support CPUID.1F |
Date: |
Wed, 12 Jun 2019 16:41:02 +0800 |
In guest CPUID generation process, the cpuid_min_level would be adjusted to
the maximum passed value for basic CPUID configuration and it should not be
restricted by the limited value returned from cpu_x86_cpuid(). After the basic
cpu_x86_cpuid() loop is finished, the cpuid_0_entry.eax needs to be configured
again by the last adjusted cpuid_min_level value.
If a user wants to expose CPUID.1F by passing dies > 1 for any reason without
host support, a per-cpu smp topology warning will appear but it's not blocked.
Signed-off-by: Like Xu <address@hidden>
---
target/i386/kvm.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 9b4da9b265..8bf1604d2b 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -931,12 +931,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
int kvm_base = KVM_CPUID_SIGNATURE;
- int r;
+ int r, cpuid_0_entry, cpuid_min_level;
Error *local_err = NULL;
memset(&cpuid_data, 0, sizeof(cpuid_data));
- cpuid_i = 0;
+ cpuid_i = cpuid_0_entry = cpuid_min_level = 0;
r = kvm_arch_set_tsc_khz(cs);
if (r < 0) {
@@ -1050,6 +1050,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
+ /* Allow 0x1f setting regardless of kvm support if nr_dies > 1 */
+ if (limit < 0x1f && env->nr_dies > 1 && cpu->enable_cpuid_0x1f) {
+ limit = env->cpuid_level = env->cpuid_min_level = 0x1f;
+ warn_report("CPU topology: the CPUID.1F isn't supported on the host.");
+ }
+
for (i = 0; i <= limit; i++) {
if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
fprintf(stderr, "unsupported level value: 0x%x\n", limit);
@@ -1151,8 +1157,22 @@ int kvm_arch_init_vcpu(CPUState *cs)
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
break;
}
+
+ /* Remember the index of cpuid.0 leaf for reconfiguration. */
+ cpuid_0_entry = (i == 0) ? (cpuid_i - 1) : cpuid_0_entry;
+
+ /* Adjust cpuid_min_level to the maximum index of valid basic cpuids.
*/
+ cpuid_min_level =
+ ((c->eax | c->ebx | c->ecx | c->edx | c->flags | c->index) &&
+ (i > cpuid_min_level)) ? i : cpuid_min_level;
}
+ env->cpuid_level = env->cpuid_min_level = cpuid_min_level;
+
+ /* Reconfigure cpuid_0_eax value to follow CPUID.0 instruction spec.*/
+ c = &cpuid_data.entries[cpuid_0_entry];
+ cpu_x86_cpuid(env, 0, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+
if (limit >= 0x0a) {
uint32_t eax, edx;
--
2.21.0
[Qemu-devel] [PATCH v3 2/9] hw/i386: Adjust nr_dies with configured smp_dies for PCMachine, Like Xu, 2019/06/12
[Qemu-devel] [PATCH v3 5/9] tests/x86-cpuid: Update testcases in test_topo_bits() with multiple dies, Like Xu, 2019/06/12
[Qemu-devel] [PATCH v3 3/9] i386/cpu: Consolidate die-id validity in smp context, Like Xu, 2019/06/12