From: Jan Kiszka <jan.kiszka@siemens.com>
To: "bharata.rao@gmail.com" <bharata.rao@gmail.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"avi@redhat.com" <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] Fix X86 CPU topology in KVM mode
Date: Thu, 08 Sep 2011 19:04:54 +0200 [thread overview]
Message-ID: <4E68F5B6.5050909@siemens.com> (raw)
In-Reply-To: <1315460008-22657-1-git-send-email-bharata.rao@gmail.com>
On 2011-09-08 07:33, bharata.rao@gmail.com wrote:
> From: Bharata B Rao <bharata.rao@gmail.com>
>
> 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. This results in broken CPU topology in guest.
>
> Fix this by setting cpuid_apic_id before cpuid information is passed to
> the host kernel. This is done by moving the setting of cpuid_apic_id
> to cpu_x86_init() where it will work for both KVM as well as TCG modes.
>
> Signed-off-by: Bharata B Rao <bharata.rao@gmail.com>
> ---
> This is the next post of the fix that addresses Jan's comment about
> bringing back (smp_cpus > 1) check.
>
> The previous version was posted here:
> http://lists.gnu.org/archive/html/qemu-devel/2011-09/msg00892.html
>
> I coudn't boot a 486 kernel successfully with qemu and hence not
> sure if and how this fix breaks i486. Any help from Jan or others
> who might have easy means to boot 486 would be good.
At least it preserves the current logic, just moves it up in the
initialization path.
>
> hw/pc.c | 1 -
> target-i386/helper.c | 5 +++++
> 2 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index 5bc845a..f9cca4d 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -933,7 +933,6 @@ static CPUState *pc_new_cpu(const char *cpu_model)
> exit(1);
> }
> if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
> - env->cpuid_apic_id = env->cpu_index;
> env->apic_state = apic_init(env, env->cpuid_apic_id);
> }
> qemu_register_reset(pc_cpu_reset, env);
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 5df40d4..139a193 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -1256,6 +1256,11 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
> cpu_x86_close(env);
> return NULL;
> }
> +
> + if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
> + env->cpuid_apic_id = env->cpu_index;
> + }
> +
> mce_init(env);
>
> qemu_init_vcpu(env);
Tested-and-acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Just in time, we happen to hit this bug today too. It confused libvirt
in the guest quite a bit...
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2011-09-08 17:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-08 5:33 [Qemu-devel] [PATCH v2] Fix X86 CPU topology in KVM mode bharata.rao
2011-09-08 17:04 ` Jan Kiszka [this message]
2011-09-09 17:14 ` Anthony Liguori
2011-09-10 14:37 ` Bharata B Rao
2011-09-11 8:02 ` Jan Kiszka
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=4E68F5B6.5050909@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.