[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/21] cpu: introduce get_arch_id() method and overr
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 07/21] cpu: introduce get_arch_id() method and override it for target-i386 |
Date: |
Tue, 23 Apr 2013 10:29:41 +0200 |
get_arch_id() adds possibility for generic code to get guest visible
CPU ID without accessing CPUArchState. If target doesn't override it,
it will return cpu_index.
Override it on target-i386 to return APIC ID.
Signed-off-by: Igor Mammedov <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: liguang <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
---
* it will be used later by new cpu_exists() generic function and
acpi_piix.
* s/cpu_firmware_id/cpu_arch_id/
---
include/qom/cpu.h | 2 ++
qom/cpu.c | 6 ++++++
target-i386/cpu.c | 10 ++++++++++
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index d6a0e80..639b436 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -45,6 +45,7 @@ typedef struct CPUState CPUState;
* instantiatable CPU type.
* @reset: Callback to reset the #CPUState to its initial state.
* @do_interrupt: Callback for interrupt handling.
+ * @get_arch_id: Callback for getting architecture depended CPU ID
* @vmsd: State description for migration.
*
* Represents a CPU family or model.
@@ -58,6 +59,7 @@ typedef struct CPUClass {
void (*reset)(CPUState *cpu);
void (*do_interrupt)(CPUState *cpu);
+ int64_t (*get_arch_id)(CPUState *cpu);
const struct VMStateDescription *vmsd;
} CPUClass;
diff --git a/qom/cpu.c b/qom/cpu.c
index 9f78114..d44f987 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -76,6 +76,11 @@ static void cpu_common_realizefn(DeviceState *dev, Error
**errp)
}
}
+static int64_t cpu_common_get_arch_id(CPUState *cpu)
+{
+ return cpu->cpu_index;
+}
+
static void cpu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -83,6 +88,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
k->class_by_name = cpu_common_class_by_name;
k->reset = cpu_common_reset;
+ k->get_arch_id = cpu_common_get_arch_id;
dc->realize = cpu_common_realizefn;
dc->no_user = 1;
}
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e2302d8..a415fa3 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2272,6 +2272,14 @@ static void x86_cpu_initfn(Object *obj)
}
}
+static int64_t x86_cpu_get_arch_id(CPUState *cpu)
+{
+ X86CPU *x86cpu = X86_CPU(cpu);
+ CPUX86State *env = &x86cpu->env;
+
+ return env->cpuid_apic_id;
+}
+
static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
{
X86CPUClass *xcc = X86_CPU_CLASS(oc);
@@ -2286,6 +2294,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc,
void *data)
cc->do_interrupt = x86_cpu_do_interrupt;
cpu_class_set_vmsd(cc, &vmstate_x86_cpu);
+
+ cc->get_arch_id = x86_cpu_get_arch_id;
}
static const TypeInfo x86_cpu_type_info = {
--
1.7.1
- [Qemu-devel] [PATCH 00/21 v5] target-i386: CPU hot-add with cpu-add QMP command, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 07/21] cpu: introduce get_arch_id() method and override it for target-i386,
Igor Mammedov <=
- [Qemu-devel] [PATCH 03/21] introduce cpu_resume(), for single CPU, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 09/21] cpu: add helper cpu_exists(), to check if CPU with specified id exists, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 12/21] target-i386: introduce ICC bus/device/bridge, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 08/21] exec: add qemu_for_each_cpu, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 13/21] target-i386: cpu: attach ICC bus to CPU on its creation, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 11/21] target-i386: introduce apic-id property, Igor Mammedov, 2013/04/23
- [Qemu-devel] [PATCH 10/21] acpi_piix4: add infrastructure to send CPU hot-plug GPE to guest, Igor Mammedov, 2013/04/23