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

[Xen-changelog] [xen stable-4.9] x86: Don't use potentially incorrect CPUID values for topology information



commit 96990e27b00702ee5a803fdc16f58fd6e325061d
Author:     Jan H. Schönherr <jschoenh@xxxxxxxxx>
AuthorDate: Wed Jan 17 17:04:30 2018 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jan 17 17:04:30 2018 +0100

    x86: Don't use potentially incorrect CPUID values for topology information
    
    Intel says for CPUID leaf 0Bh:
    
      "Software must not use EBX[15:0] to enumerate processor
       topology of the system. This value in this field
       (EBX[15:0]) is only intended for display/diagnostic
       purposes. The actual number of logical processors
       available to BIOS/OS/Applications may be different from
       the value of EBX[15:0], depending on software and platform
       hardware configurations."
    
    And yet, we're using them to derive the number cores in a package
    and the number of siblings in a core.
    
    Derive the number of siblings and cores from EAX instead, which is
    intended for that.
    
    Signed-off-by: Jan H. Schönherr <jschoenh@xxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    master commit: d51baf310e530659f73e714acf575555bdc46303
    master date: 2018-01-08 10:48:24 +0000
---
 xen/arch/x86/cpu/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 6cf3628..0e83a94 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -479,8 +479,8 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
        initial_apicid = edx;
 
        /* Populate HT related information from sub-leaf level 0 */
-       core_level_siblings = c->x86_num_siblings = LEVEL_MAX_SIBLINGS(ebx);
        core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
+       core_level_siblings = c->x86_num_siblings = 1u << ht_mask_width;
 
        sub_index = 1;
        do {
@@ -488,8 +488,8 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
 
                /* Check for the Core type in the implemented sub leaves */
                if ( LEAFB_SUBTYPE(ecx) == CORE_TYPE ) {
-                       core_level_siblings = LEVEL_MAX_SIBLINGS(ebx);
                        core_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
+                       core_level_siblings = 1u << core_plus_mask_width;
                        break;
                }
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.9

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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