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

[Xen-changelog] [linux-2.6.18-xen] x86 xen: New vcpu_op call to get physical CPU identity.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1204715381 0
# Node ID 26e1e96bd46a53991e216271d077aa6fb20ea218
# Parent  1cf7ba68d855aa86b1c54c34c03fc62571eb5c94
x86 xen: New vcpu_op call to get physical CPU identity.

Some AMD machines have APIC IDs that not equal to CPU IDs. In
the default Xen configuration, ACPI calls on these machines
can get confused. This shows up most noticeably when running
AMD PowerNow!. The only solution is for dom0 to get the
hypervisor's cpuid to apicid table when needed (ie, when dom0
vcpus are pinned).

Add a vcpu op to Xen to allow dom0 to query the hypervisor for
architecture dependent physical cpu information if dom0 vcpus are
pinned.

Signed-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 drivers/xen/core/smpboot.c   |   34 +++++++++++++++++++++++++++-------
 include/xen/interface/vcpu.h |   18 +++++++++++++++++-
 2 files changed, 44 insertions(+), 8 deletions(-)

diff -r 1cf7ba68d855 -r 26e1e96bd46a drivers/xen/core/smpboot.c
--- a/drivers/xen/core/smpboot.c        Mon Mar 03 13:36:57 2008 +0000
+++ b/drivers/xen/core/smpboot.c        Wed Mar 05 11:09:41 2008 +0000
@@ -258,17 +258,28 @@ void __init smp_prepare_cpus(unsigned in
 {
        unsigned int cpu;
        struct task_struct *idle;
+       int apicid, acpiid;
+       struct vcpu_get_physid cpu_id;
 #ifdef __x86_64__
        struct desc_ptr *gdt_descr;
 #else
        struct Xgt_desc_struct *gdt_descr;
 #endif
 
-       boot_cpu_data.apicid = 0;
+       apicid = 0;
+       if (HYPERVISOR_vcpu_op(VCPUOP_get_physid, 0, &cpu_id) == 0) {
+               apicid = xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id);
+               acpiid = xen_vcpu_physid_to_x86_acpiid(cpu_id.phys_id);
+#ifdef CONFIG_ACPI
+               if (acpiid != 0xff)
+                       x86_acpiid_to_apicid[acpiid] = apicid;
+#endif
+       }
+       boot_cpu_data.apicid = apicid;
        cpu_data[0] = boot_cpu_data;
 
-       cpu_2_logical_apicid[0] = 0;
-       x86_cpu_to_apicid[0] = 0;
+       cpu_2_logical_apicid[0] = apicid;
+       x86_cpu_to_apicid[0] = apicid;
 
        current_thread_info()->cpu = 0;
 
@@ -312,11 +323,20 @@ void __init smp_prepare_cpus(unsigned in
                        (void *)gdt_descr->address,
                        XENFEAT_writable_descriptor_tables);
 
+               apicid = cpu;
+               if (HYPERVISOR_vcpu_op(VCPUOP_get_physid, cpu, &cpu_id) == 0) {
+                       apicid = xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id);
+                       acpiid = xen_vcpu_physid_to_x86_acpiid(cpu_id.phys_id);
+#ifdef CONFIG_ACPI
+                       if (acpiid != 0xff)
+                               x86_acpiid_to_apicid[acpiid] = apicid;
+#endif
+               }
                cpu_data[cpu] = boot_cpu_data;
-               cpu_data[cpu].apicid = cpu;
-
-               cpu_2_logical_apicid[cpu] = cpu;
-               x86_cpu_to_apicid[cpu] = cpu;
+               cpu_data[cpu].apicid = apicid;
+
+               cpu_2_logical_apicid[cpu] = apicid;
+               x86_cpu_to_apicid[cpu] = apicid;
 
                idle = fork_idle(cpu);
                if (IS_ERR(idle))
diff -r 1cf7ba68d855 -r 26e1e96bd46a include/xen/interface/vcpu.h
--- a/include/xen/interface/vcpu.h      Mon Mar 03 13:36:57 2008 +0000
+++ b/include/xen/interface/vcpu.h      Wed Mar 05 11:09:41 2008 +0000
@@ -170,7 +170,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_set_singles
  *
  * This may be called only once per vcpu.
  */
-#define VCPUOP_register_vcpu_info   10  /* arg == struct vcpu_info */
+#define VCPUOP_register_vcpu_info   10  /* arg == vcpu_register_vcpu_info_t */
 struct vcpu_register_vcpu_info {
     uint64_t mfn;    /* mfn of page to place vcpu_info */
     uint32_t offset; /* offset within page */
@@ -181,6 +181,22 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_register_vc
 
 /* Send an NMI to the specified VCPU. @extra_arg == NULL. */
 #define VCPUOP_send_nmi             11
+
+/* 
+ * Get the physical ID information for a pinned vcpu's underlying physical
+ * processor.  The physical ID informmation is architecture-specific.
+ * On x86: id[7:0]=apic_id, id[15:8]=acpi_id, id[63:16]=mbz,
+ *         and an unavailable identifier is returned as 0xff.
+ * This command returns -EINVAL if it is not a valid operation for this VCPU.
+ */
+#define VCPUOP_get_physid           12 /* arg == vcpu_get_physid_t */
+struct vcpu_get_physid {
+    uint64_t phys_id;
+};
+typedef struct vcpu_get_physid vcpu_get_physid_t;
+DEFINE_XEN_GUEST_HANDLE(vcpu_get_physid_t);
+#define xen_vcpu_physid_to_x86_apicid(physid) ((uint8_t)((physid)>>0))
+#define xen_vcpu_physid_to_x86_acpiid(physid) ((uint8_t)((physid)>>8))
 
 #endif /* __XEN_PUBLIC_VCPU_H__ */
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.