All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Igor Mammedov" <imammedo@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH 07/29] cpu: Introduce get_arch_id() method and override it for X86CPU
Date: Thu,  2 May 2013 15:35:33 +0200	[thread overview]
Message-ID: <1367501755-32272-8-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1367501755-32272-1-git-send-email-afaerber@suse.de>

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>
---
 include/qom/cpu.h |  2 ++
 qom/cpu.c         |  6 ++++++
 target-i386/cpu.c | 10 ++++++++++
 3 files changed, 18 insertions(+)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index ac93dce..1b4de17 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-dependent 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 34fa805..9a4457b 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -78,6 +78,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);
@@ -85,6 +90,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..f34ba23 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 *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);
@@ -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.8.1.4

  parent reply	other threads:[~2013-05-02 13:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-02 13:35 [Qemu-devel] [PULL for-1.5 00/29] QOM CPUState patch queue 2013-05-02 Andreas Färber
2013-05-02 13:35 ` [PATCH 01/29] cpu: Make kvm-stub.o available outside softmmu Andreas Färber
2013-05-02 13:35   ` [Qemu-devel] " Andreas Färber
2013-05-02 13:35 ` [PATCH 02/29] cpu: Call cpu_synchronize_post_init() from DeviceClass::realize() Andreas Färber
2013-05-02 13:35   ` [Qemu-devel] " Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 03/29] cpu: Introduce cpu_resume(), for single CPU Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 04/29] cpu: Resume CPU from DeviceClass::realize() if hot-plugged Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 05/29] cpu: Introduce CPU hot-plug notifier Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 06/29] pc: Update rtc_cmos on CPU hot-plug Andreas Färber
2013-05-02 13:35 ` Andreas Färber [this message]
2013-05-02 13:35 ` [Qemu-devel] [PATCH 08/29] cpu: Add qemu_for_each_cpu() Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 09/29] cpus: Use qemu_for_each_cpu() in TCG thread Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 10/29] cpu: Add helper cpu_exists(), to check if CPU with specified id exists Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 11/29] acpi_piix4: Add infrastructure to send CPU hot-plug GPE to guest Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 12/29] target-i386: Introduce feat2prop() for CPU properties Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 13/29] target-i386: Introduce apic-id CPU property Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 14/29] target-i386: Do not allow to set apic-id once CPU is realized Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 15/29] target-i386: Replace MSI_SPACE_SIZE with APIC_SPACE_SIZE Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 16/29] kvmvapic: Make dependency on sysbus.h explicit Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 17/29] cpu: Move cpu_write_elfXX_note() functions to CPUState Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 18/29] target-i386: Introduce ICC bus/device/bridge Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 19/29] target-i386: Attach ICC bus to CPU on its creation Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 20/29] target-i386: Move APIC to ICC bus Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 21/29] Add hot_add_cpu hook to QEMUMachine Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 22/29] QMP: Add cpu-add command Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 23/29] pc: Implement QEMUMachine::hot_add_cpu hook Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 24/29] target-i386: Group together level, xlevel, xlevel2 fields Andreas Färber
2013-05-02 13:35 ` [PATCH 25/29] target-i386/kvm.c: Code formatting changes Andreas Färber
2013-05-02 13:35   ` [Qemu-devel] " Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 26/29] target-i386: Break CPUID feature definition lines Andreas Färber
2013-05-02 13:35 ` [PATCH 27/29] target-i386: Replace cpuid_*features fields with a feature word array Andreas Färber
2013-05-02 13:35   ` [Qemu-devel] " Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 28/29] cpus: Fix pausing TCG CPUs while in vCPU thread Andreas Färber
2013-05-02 13:35 ` [Qemu-devel] [PATCH 29/29] Drop redundant resume_all_vcpus() from main() Andreas Färber

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=1367501755-32272-8-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.