]> xenbits.xensource.com Git - xenclient/kernel.git/commitdiff
x86 xen: New vcpu_op call to get physical CPU identity.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 11:09:41 +0000 (11:09 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 5 Mar 2008 11:09:41 +0000 (11:09 +0000)
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@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
drivers/xen/core/smpboot.c
include/xen/interface/vcpu.h

index 84352157502cff67eeb9f8f8c62f71988ee67e9d..deb5f99183681ac626998887bc5f09e0c018700a 100644 (file)
@@ -258,17 +258,28 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 {
        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 int max_cpus)
                        (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_data[cpu].apicid = apicid;
 
-               cpu_2_logical_apicid[cpu] = cpu;
-               x86_cpu_to_apicid[cpu] = cpu;
+               cpu_2_logical_apicid[cpu] = apicid;
+               x86_cpu_to_apicid[cpu] = apicid;
 
                idle = fork_idle(cpu);
                if (IS_ERR(idle))
index 4cd4229d915dfd241f85f5ac370ac4ce8f816c7d..b7173c6024f7637e0d2f701c224d14b2abd358ef 100644 (file)
@@ -170,7 +170,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_set_singleshot_timer_t);
  *
  * 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 */
@@ -182,6 +182,22 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_register_vcpu_info_t);
 /* 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__ */
 
 /*