|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/7] cpu: Introduce get_arch_id() method and override it for X86CPU
From: Igor Mammedov <imammedo@xxxxxxxxxx>
get_arch_id() adds possibility for generic code to get a guest-visible
CPU ID without accessing CPUArchState.
If derived classes don't override it, it will return cpu_index.
Override it on target-i386 in X86CPU to return the APIC ID.
Signed-off-by: Igor Mammedov <imammedo@xxxxxxxxxx>
Reviewed-by: Eduardo Habkost <ehabkost@xxxxxxxxxx>
Reviewed-by: liguang <lig.fnst@xxxxxxxxxxxxxx>
Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Signed-off-by: Andreas FÃrber <afaerber@xxxxxxx>
(cherry picked from QEMU commit 997395d3888fcde6ce41535a8208d7aa919d824b)
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
include/qemu/cpu.h | 2 ++
qom/cpu.c | 8 ++++++++
target-i386/cpu.c | 10 ++++++++++
3 files changed, 20 insertions(+)
diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index 61b7698..8d2e0cb 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -41,6 +41,7 @@ typedef struct CPUState CPUState;
/**
* CPUClass:
* @reset: Callback to reset the #CPUState to its initial state.
+ * @get_arch_id: Callback for getting architecture-dependent CPU ID.
*
* Represents a CPU family or model.
*/
@@ -50,6 +51,7 @@ typedef struct CPUClass {
/*< public >*/
void (*reset)(CPUState *cpu);
+ int64_t (*get_arch_id)(CPUState *cpu);
} CPUClass;
/**
diff --git a/qom/cpu.c b/qom/cpu.c
index 5b36046..dfd14c8 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -34,11 +34,19 @@ static void cpu_common_reset(CPUState *cpu)
{
}
+static int64_t cpu_common_get_arch_id(CPUState *cpu)
+{
+ /* Not used in Xen, so no backport.
+ * There is a missing cpu_index field in CPUState. */
+ abort();
+}
+
static void cpu_class_init(ObjectClass *klass, void *data)
{
CPUClass *k = CPU_CLASS(klass);
k->reset = cpu_common_reset;
+ k->get_arch_id = cpu_common_get_arch_id;
}
static TypeInfo cpu_type_info = {
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c6c2ca0..e055d69 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2111,6 +2111,14 @@ static void x86_cpu_initfn(Object *obj)
}
}
+static int64_t x86_cpu_get_arch_id(CPUState *cs)
+{
+ X86CPU *cpu = X86_CPU(cs);
+ CPUX86State *env = &cpu->env;
+
+ return env->cpuid_apic_id;
+}
+
static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
{
X86CPUClass *xcc = X86_CPU_CLASS(oc);
@@ -2118,6 +2126,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc,
void *data)
xcc->parent_reset = cc->reset;
cc->reset = x86_cpu_reset;
+
+ cc->get_arch_id = x86_cpu_get_arch_id;
}
static const TypeInfo x86_cpu_type_info = {
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |