From: Anthony PERARD <anthony.perard@citrix.com>
To: Xen Devel <xen-devel@lists.xen.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>
Subject: [PATCH 1/7] cpu: Introduce get_arch_id() method and override it for X86CPU
Date: Mon, 17 Jun 2013 15:15:43 +0100 [thread overview]
Message-ID: <1371478549-28527-1-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1371478402-28082-1-git-send-email-anthony.perard@citrix.com>
From: Igor Mammedov <imammedo@redhat.com>
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@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
(cherry picked from QEMU commit 997395d3888fcde6ce41535a8208d7aa919d824b)
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
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@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-06-17 14:15 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-17 14:13 [PATCH v2 0/7] CPU hotplug for qemu-xen for 4.3 Anthony PERARD
2013-06-17 14:15 ` Anthony PERARD [this message]
2013-06-17 14:15 ` [PATCH 2/7] cpu: Add qemu_for_each_cpu() Anthony PERARD
2013-06-17 14:15 ` [PATCH 3/7] acpi_piix4: Add infrastructure to send CPU hot-plug GPE to guest Anthony PERARD
2013-06-17 14:15 ` [PATCH 4/7] Add hot_add_cpu hook to QEMUMachine Anthony PERARD
2013-06-17 14:15 ` [PATCH 5/7] QMP: Add cpu-add command Anthony PERARD
2013-06-17 14:15 ` [PATCH 6/7] xen: Fix vcpus initialisation Anthony PERARD
2013-06-20 11:14 ` Stefano Stabellini
2013-06-17 14:15 ` [PATCH 7/7] xen: Implement hot_add_cpu hook Anthony PERARD
2013-06-20 11:21 ` Stefano Stabellini
2013-06-20 13:19 ` Anthony PERARD
2013-06-20 13:40 ` Stefano Stabellini
2013-06-21 17:40 ` Anthony PERARD
2013-06-17 14:20 ` [PATCH v2 1/2] libxl: Add "cpu-add" QMP command Anthony PERARD
2013-06-17 14:20 ` [PATCH v2 2/2] libxl: Use QMP cpu-add to hotplug CPU with qemu-xen Anthony PERARD
2013-06-17 15:31 ` Ian Campbell
2013-06-17 15:50 ` Anthony PERARD
2013-06-20 11:12 ` Stefano Stabellini
2013-06-17 15:25 ` [PATCH v2 1/2] libxl: Add "cpu-add" QMP command Ian Campbell
2013-06-17 15:28 ` Anthony PERARD
2013-06-17 15:31 ` Ian Campbell
2013-06-17 14:22 ` [PATCH v2] xen: Allow CPU to be counted than currently "plugged" Anthony PERARD
2013-06-17 15:24 ` Ian Campbell
2013-06-17 15:44 ` Anthony PERARD
2013-06-24 16:57 ` [PATCH v2 0/7] CPU hotplug for qemu-xen for 4.3 Stefano Stabellini
2013-06-24 17:21 ` Stefano Stabellini
2013-06-24 17:28 ` Anthony PERARD
2013-06-25 9:19 ` George Dunlap
2013-06-25 11:40 ` Stefano Stabellini
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=1371478549-28527-1-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=stefano.stabellini@citrix.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).