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

[Xen-devel] [PATCH RFC 1/8] x86/hvm: set initial apicid to vcpu_id



Currently the initial_apicid is set vcpu_id * 2 which makes it difficult
for the toolstack to manage how is the topology seen by the guest.
Instead of forcing procpkg and proccount to be VCPUID * 2, instead we
set it to max vcpuid on proccount to max_vcpu_id + 1 (logical number of
logical cores) and procpkg to max_vcpu_id (max cores minus 1)

Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
---
CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
CC: Ian Campbell <ian.campbell@xxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 tools/libxc/xc_cpuid_x86.c | 18 +++++++++++++-----
 xen/arch/x86/hvm/hvm.c     |  2 +-
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index c142595..aa1d679 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -45,6 +45,7 @@ struct cpuid_domain_info
     bool hvm;
     bool pvh;
     uint64_t xfeature_mask;
+    uint32_t max_vcpu_id;
 
     /* PV-only information. */
     bool pv64;
@@ -102,6 +103,7 @@ static int get_cpuid_domain_info(xc_interface *xch, domid_t 
domid,
 
     info->hvm = di.hvm;
     info->pvh = di.pvh;
+    info->max_vcpu_id = di.max_vcpu_id;
 
     /* Get xstate information. */
     domctl.cmd = XEN_DOMCTL_getvcpuextstate;
@@ -245,10 +247,16 @@ static void intel_xc_cpuid_policy(xc_interface *xch,
     case 0x00000004:
         /*
          * EAX[31:26] is Maximum Cores Per Package (minus one).
-         * Update to reflect vLAPIC_ID = vCPU_ID * 2.
          */
-        regs[0] = (((regs[0] & 0x7c000000u) << 1) | 0x04000000u |
-                   (regs[0] & 0x3ffu));
+       {
+                unsigned int procpkg = 0;
+                if ( info->hvm )
+                        procpkg = info->max_vcpu_id << 26;
+                else
+                        procpkg = (regs[0] & 0x7c000000u) << 1;
+
+                regs[0] = (procpkg | 0x04000000u | (regs[0] & 0x3ffu));
+        }
         regs[3] &= 0x3ffu;
         break;
 
@@ -353,9 +361,9 @@ static void xc_cpuid_hvm_policy(xc_interface *xch,
     case 0x00000001:
         /*
          * EBX[23:16] is Maximum Logical Processors Per Package.
-         * Update to reflect vLAPIC_ID = vCPU_ID * 2.
          */
-        regs[1] = (regs[1] & 0x0000ffffu) | ((regs[1] & 0x007f0000u) << 1);
+        regs[1] = (regs[1] & 0x0000ffffu) |
+                   (((info->max_vcpu_id + 1) << 16));
 
         regs[2] &= (bitmaskof(X86_FEATURE_XMM3) |
                     bitmaskof(X86_FEATURE_PCLMULQDQ) |
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index fe382ce..d45e7a9 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4633,7 +4633,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, 
unsigned int *ebx,
     case 0x1:
         /* Fix up VLAPIC details. */
         *ebx &= 0x00FFFFFFu;
-        *ebx |= (v->vcpu_id * 2) << 24;
+        *ebx |= (v->vcpu_id) << 24;
         if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
             __clear_bit(X86_FEATURE_APIC & 31, edx);
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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