WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH][retry 3][1/2] new vcpu op call to get physical CPU i

To: xen-devel@xxxxxxxxxxxxxxxxxxx, Chris Lalancette <clalance@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH][retry 3][1/2] new vcpu op call to get physical CPU information
From: Mark Langsdorf <mark.langsdorf@xxxxxxx>
Date: Tue, 4 Mar 2008 15:52:28 -0600
Delivery-date: Tue, 04 Mar 2008 13:51:54 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.9.6 (enterprise 20070904.708012)
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.  

The second patch adds the dom0 call to this vcpu hypercall.

I have tested this on my 4p/16 core machine and it works.  I
would appreciate testing on other boxes.

-Mark Langsdorf
Operating System Research Center
AMD

Signed-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxx>
diff -r 7530c4dba8a5 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/arch/x86/domain.c     Tue Mar 04 15:42:51 2008 -0600
@@ -952,6 +952,30 @@ arch_do_vcpu_op(
         break;
     }
 
+    case VCPUOP_get_physid:
+    {
+        struct vcpu_get_physid cpu_id;
+        int i;
+        int cpu_num = v->vcpu_id;
+       short temp = 0xff;
+
+        if ( !opt_dom0_vcpus_pin)
+            rc = -EINVAL;
+        rc = -EFAULT;
+
+        cpu_id.phys_id = x86_cpu_to_apicid[cpu_num];
+        for (i = 0; i++; i < NR_CPUS) 
+             if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu_num])
+                 temp = i;
+       cpu_id.phys_id |= temp << 8;
+
+        if ( copy_to_guest(arg, &cpu_id, 1) )
+            break;
+        rc = 0;
+
+        break;
+    }
+
     default:
         rc = -ENOSYS;
         break;
diff -r 7530c4dba8a5 xen/common/schedule.c
--- a/xen/common/schedule.c     Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/common/schedule.c     Tue Mar 04 15:42:51 2008 -0600
@@ -39,7 +39,8 @@ string_param("sched", opt_sched);
 string_param("sched", opt_sched);
 
 /* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
-static unsigned int opt_dom0_vcpus_pin;
+unsigned int opt_dom0_vcpus_pin;
+EXPORT_SYMBOL(opt_dom0_vcpus_pin);
 boolean_param("dom0_vcpus_pin", opt_dom0_vcpus_pin);
 
 enum cpufreq_controller cpufreq_controller;
diff -r 7530c4dba8a5 xen/include/public/vcpu.h
--- a/xen/include/public/vcpu.h Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/include/public/vcpu.h Tue Mar 04 15:42:51 2008 -0600
@@ -182,6 +182,17 @@ 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 phyiscal ID informmation is architecture
+ * defined, but would ACPI and APIC IDs on x86 processors.
+ */
+#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);
 #endif /* __XEN_PUBLIC_VCPU_H__ */
 
 /*
diff -r 7530c4dba8a5 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Mon Mar 03 15:19:39 2008 +0000
+++ b/xen/include/xen/sched.h   Tue Mar 04 15:42:51 2008 -0600
@@ -29,6 +29,9 @@ extern unsigned long volatile jiffies;
 
 /* A global pointer to the initial domain (DOM0). */
 extern struct domain *dom0;
+
+/* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */
+extern unsigned int opt_dom0_vcpus_pin;
 
 #ifndef CONFIG_COMPAT
 #define MAX_EVTCHNS(d)     NR_EVENT_CHANNELS


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