qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC 4/6] target-i386: convert cpu to 2-stage ini


From: Igor Mammedov
Subject: Re: [Qemu-devel] [PATCH RFC 4/6] target-i386: convert cpu to 2-stage initialization
Date: Wed, 18 Apr 2012 18:03:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

On 04/17/2012 01:37 AM, Igor Mammedov wrote:
From: Igor Mammedov<address@hidden>

Use realize to start a cpu prepared by x86_cpu_initfn.

v2:
Create apic for cpu only once.

Signed-off-by: Igor Mammedov<address@hidden>
---
  hw/pc.c              |   35 ++++---------------------
  target-i386/cpu.c    |   69 +++++++++++++++++++++++++++++++++++++++++++++++++-
  target-i386/helper.c |   46 +++-----------------------------
  3 files changed, 79 insertions(+), 71 deletions(-)

[...]
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 30ae0c2..e4dcf52 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -30,6 +30,8 @@
  #include "hyperv.h"

  #include "qerror.h"
+#include "hw/qdev.h"
+#include "sysemu.h"

  /* feature flags taken from "Intel Processor Identification and the CPUID
   * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
@@ -1489,16 +1491,73 @@ static void x86_set_cpu_model(Object *obj, const char 
*value, Error **errp)
          fprintf(stderr, "Unable to find x86 CPU definition\n");
          error_set(errp, QERR_INVALID_PARAMETER_COMBINATION);
      }
+
+    mce_init(cpu);
+
+    if (((env->cpuid_features&  CPUID_APIC) || smp_cpus>  1)&&  
!env->apic_state) {
I wonder if it is ok to drop "smp_cpus>  1" here?
Booted linux guest with
  -smp 2 -cpu host,-apic
and it sees/initializes only one cpu. So I guess that CPUID_APIC must be
present for smp machine and that makes "smp_cpus>  1" redundant.

+        if (kvm_irqchip_in_kernel()) {
+            env->apic_state = qdev_create(NULL, "kvm-apic");
+        } else {
+            env->apic_state = qdev_create(NULL, "apic");
+        }
+        qdev_prop_set_uint8(env->apic_state, "id", env->cpuid_apic_id);
+        qdev_prop_set_ptr(env->apic_state, "cpu_env", env);
+       object_property_add_child(OBJECT(cpu), "apic", OBJECT(env->apic_state), 
NULL);
+
+        /* We hard-wire the BSP to the first CPU. */
+        if (env->cpu_index == 0) {
+            apic_designate_bsp(env->apic_state);
+        }
+    }
+}
[...]

-----
 Igor



reply via email to

[Prev in Thread] Current Thread [Next in Thread]