[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] X86 CPU topology broken in qemu ?
From: |
Bharata B Rao |
Subject: |
[Qemu-devel] X86 CPU topology broken in qemu ? |
Date: |
Wed, 17 Aug 2011 10:55:47 +0530 |
Hi,
I see that x86 CPU topology inside VM is not showing up as specified.
With some debugging, I found out that the root cause for this: qemu is
not enumerating the apic ids correctly for vcpus. I made the below
hackish change to get it working. Has anybody else seen this problem
? This patch is on qemu-kvm-0.14.1. Using 2.6.39 for guest.
***************************
Fix apic id enumeration
apic id returned to guest kernel in ebx for cpuid(function=1) depends on
CPUX86State->cpuid_apic_id which gets populated after the cpuid information
is cached in the host kernel.
Fix this by setting cpuid_apic_id before cpuid information is passed to
the host kernel.
Signed-off-by: Bharata B Rao <address@hidden>
---
hw/pc.c | 4 +---
target-i386/kvm.c | 3 +++
2 files changed, 4 insertions(+), 3 deletions(-)
Index: qemu-kvm-0.14.1/hw/pc.c
===================================================================
--- qemu-kvm-0.14.1.orig/hw/pc.c
+++ qemu-kvm-0.14.1/hw/pc.c
@@ -930,10 +930,8 @@ CPUState *pc_new_cpu(const char *cpu_mod
fprintf(stderr, "Unable to find x86 CPU definition\n");
exit(1);
}
- if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
- env->cpuid_apic_id = env->cpu_index;
+ if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1)
env->apic_state = apic_init(env, env->cpuid_apic_id);
- }
qemu_register_reset(pc_cpu_reset, env);
pc_cpu_reset(env);
return env;
Index: qemu-kvm-0.14.1/target-i386/kvm.c
===================================================================
--- qemu-kvm-0.14.1.orig/target-i386/kvm.c
+++ qemu-kvm-0.14.1/target-i386/kvm.c
@@ -340,6 +340,9 @@ int kvm_arch_init_vcpu(CPUState *env)
cpuid_i = 0;
+ if (env->cpuid_features & CPUID_APIC)
+ env->cpuid_apic_id = env->cpu_index;
+
#ifdef CONFIG_KVM_PARA
/* Paravirtualization CPUIDs */
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
**************************
This is how various fields look like before and after this change with
qemu command line option of "-smp ,sockets=1,cores=4,threads=2"
Before
------
address@hidden:~# grep "core id" /proc/cpuinfo
core id : 0
core id : 0
core id : 0
core id : 0
core id : 0
core id : 0
core id : 0
core id : 0
After
-----
address@hidden:~# grep "core id" /proc/cpuinfo
core id : 0
core id : 0
core id : 1
core id : 1
core id : 2
core id : 2
core id : 3
core id : 3
Before
------
address@hidden:~# grep "cpu cores" /proc/cpuinfo
cpu cores : 1
cpu cores : 1
cpu cores : 1
cpu cores : 1
cpu cores : 1
cpu cores : 1
cpu cores : 1
cpu cores : 1
After
-----
address@hidden:~# grep "cpu cores" /proc/cpuinfo
cpu cores : 4
cpu cores : 4
cpu cores : 4
cpu cores : 4
cpu cores : 4
cpu cores : 4
cpu cores : 4
cpu cores : 4
Before
------
address@hidden:~# grep apicid /proc/cpuinfo
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
apicid : 0
initial apicid : 0
After
-----
address@hidden:~# grep apicid /proc/cpuinfo
apicid : 0
initial apicid : 0
apicid : 1
initial apicid : 1
apicid : 2
initial apicid : 2
apicid : 3
initial apicid : 3
apicid : 4
initial apicid : 4
apicid : 5
initial apicid : 5
apicid : 6
initial apicid : 6
apicid : 7
initial apicid : 7
Before
------
address@hidden:/sys/devices/system/cpu# cat cpu*/topology/core_siblings_list
0-7
0-7
0-7
0-7
0-7
0-7
0-7
0-7
address@hidden:/sys/devices/system/cpu# cat cpu*/topology/thread_siblings_list
0-7
0-7
0-7
0-7
0-7
0-7
0-7
0-7
After
-----
address@hidden:/sys/devices/system/cpu# cat cpu*/topology/core_siblings_list
0-7
0-7
0-7
0-7
0-7
0-7
0-7
0-7
address@hidden:/sys/devices/system/cpu# cat cpu*/topology/thread_siblings_list
0-1
0-1
2-3
2-3
4-5
4-5
6-7
6-7
Regards,
Bharata.
--
http://bharata.sulekha.com/blog/posts.htm, http://raobharata.wordpress.com/
- [Qemu-devel] X86 CPU topology broken in qemu ?,
Bharata B Rao <=