From: Mark Langsdorf Subject: [PATCH][retry 3][1/2] new vcpu op call to get physical CPU information Date: Tue, 4 Mar 2008 15:52:28 -0600 Message-ID: <200803041552.28425.mark.langsdorf@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com, Chris Lalancette List-Id: xen-devel@lists.xenproject.org Some AMD machines have APIC IDs that not equal to CPU IDs. =A0In the default Xen configuration, ACPI calls on these machines can get confused. =A0This shows up most noticeably when running AMD PowerNow!. =A0The 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. =20 The second patch adds the dom0 call to this vcpu hypercall. I have tested this on my 4p/16 core machine and it works. =A0I would appreciate testing on other boxes. =2DMark Langsdorf Operating System Research Center AMD Signed-off-by: Mark Langsdorf diff -r 7530c4dba8a5 xen/arch/x86/domain.c =2D-- 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; } =20 + case VCPUOP_get_physid: + { + struct vcpu_get_physid cpu_id; + int i; + int cpu_num =3D v->vcpu_id; + short temp =3D 0xff; + + if ( !opt_dom0_vcpus_pin) + rc =3D -EINVAL; + rc =3D -EFAULT; + + cpu_id.phys_id =3D x86_cpu_to_apicid[cpu_num]; + for (i =3D 0; i++; i < NR_CPUS)=20 + if (x86_acpiid_to_apicid[i] =3D=3D x86_cpu_to_apicid[cpu_num]) + temp =3D i; + cpu_id.phys_id |=3D temp << 8; + + if ( copy_to_guest(arg, &cpu_id, 1) ) + break; + rc =3D 0; + + break; + } + default: rc =3D -ENOSYS; break; diff -r 7530c4dba8a5 xen/common/schedule.c =2D-- 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); =20 /* opt_dom0_vcpus_pin: If true, dom0 VCPUs are pinned. */ =2Dstatic 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); =20 enum cpufreq_controller cpufreq_controller; diff -r 7530c4dba8a5 xen/include/public/vcpu.h =2D-- 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 =3D=3D NULL. */ #define VCPUOP_send_nmi 11 =20 +/*=20 + * 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 =3D=3D 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__ */ =20 /* diff -r 7530c4dba8a5 xen/include/xen/sched.h =2D-- 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; =20 /* 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; =20 #ifndef CONFIG_COMPAT #define MAX_EVTCHNS(d) NR_EVENT_CHANNELS