qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Bharata B Rao <bharata.rao@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] X86 CPU topology broken in qemu ?
Date: Thu, 25 Aug 2011 12:47:39 +0200	[thread overview]
Message-ID: <4E56284B.6020002@siemens.com> (raw)
In-Reply-To: <CAGZKiBpXSCYtK2q-KWd+bCP6xFURWu6xR5tT_eimc3+Pd-71YA@mail.gmail.com>

On 2011-08-17 07:25, Bharata B Rao wrote:
> 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 <bharata.rao@gmail.com>
> ---
>  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;
> +

Moving it only here will break TCG mode. Make sure to test both. I guess
it's best to move cpuid_apic_id initialization into cpu_x86_init. And
you need to take care of the external APIC case (i486) as well.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  parent reply	other threads:[~2011-08-25 10:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGZKiBpbqMALiRdNRqd0WN6iqNWpnkOcsvVb8AzJAGocuWBrTw@mail.gmail.com>
2011-08-17  5:25 ` [Qemu-devel] X86 CPU topology broken in qemu ? Bharata B Rao
2011-08-19  9:51   ` Bharata B Rao
2011-08-25 10:01   ` Avi Kivity
2011-08-30  5:42     ` Bharata B Rao
2011-08-25 10:47   ` Jan Kiszka [this message]
2011-08-30  5:43     ` Bharata B Rao

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=4E56284B.6020002@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=bharata.rao@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).