From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: [PATCH] qemu-kvm: x86: Fix CPU initialization
Date: Fri, 19 Jun 2009 19:11:39 +0200 [thread overview]
Message-ID: <4A3BC6CB.402@siemens.com> (raw)
In-Reply-To: <4A3BA861.6040601@siemens.com>
Fix regression in CPU initialization caused by merge a5b526135d and try
to avoid this in the future by dropping qemu-kvm specific pc_new_cpu. If
such refactoring is desired, it should go through upstream first.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/pc.c | 44 ++++++++++++++++++--------------------------
1 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 6c19f55..c4117e5 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -839,31 +839,6 @@ int cpu_is_bsp(CPUState *env)
return env->cpuid_apic_id == 0;
}
-CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled)
-{
- CPUState *env = cpu_init(cpu_model);
- if (!env) {
- fprintf(stderr, "Unable to find x86 CPU definition\n");
- exit(1);
- }
- if (cpu != 0)
- env->halted = 1;
- if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
- env->cpuid_apic_id = env->cpu_index;
- apic_init(env);
- }
- qemu_register_reset(main_cpu_reset, 0, env);
- if (pci_enabled) {
- apic_init(env);
- }
-
- /* kvm needs this to run after the apic is initialized. Otherwise,
- * it can access invalid state and crash.
- */
- qemu_init_vcpu(env);
- return env;
-}
-
/* PC hardware initialisation */
static void pc_init1(ram_addr_t ram_size,
const char *boot_device,
@@ -906,7 +881,24 @@ static void pc_init1(ram_addr_t ram_size,
}
for(i = 0; i < smp_cpus; i++) {
- env = pc_new_cpu(i, cpu_model, pci_enabled);
+ env = cpu_init(cpu_model);
+ if (!env) {
+ fprintf(stderr, "Unable to find x86 CPU definition\n");
+ exit(1);
+ }
+ if (cpu != 0)
+ env->halted = 1;
+ if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
+ env->cpuid_apic_id = env->cpu_index;
+ apic_init(env);
+ }
+ qemu_register_reset(main_cpu_reset, 0, env);
+
+ /*
+ * FIXME: qemu-kvm needs this after apic_init as it accesses APIC
+ * structures.
+ */
+ qemu_init_vcpu(env);
}
vmport_init();
next prev parent reply other threads:[~2009-06-19 17:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-19 15:01 -no-kvm broken since merge a5b526135d Jan Kiszka
2009-06-19 17:11 ` Jan Kiszka [this message]
2009-06-19 17:17 ` [PATCH v2] qemu-kvm: x86: Fix CPU initialization Jan Kiszka
2009-06-21 12:38 ` Avi Kivity
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=4A3BC6CB.402@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.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