libxc/x86: correct overflow avoidance check in AMD CPUID handling
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Sep 2019 13:50:58 +0000 (15:50 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Sep 2019 13:50:58 +0000 (15:50 +0200)
Commit df29d03f1d ("libxc/x86: avoid certain overflows in CPUID APIC ID
adjustments" introduced a one bit too narrow mask when checking whether
multiplying by 1 (in particular in leaf 1) would result in overflow.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxc/xc_cpuid_x86.c

index b472fbc6101d576117febefbea7abeb10251f989..54b0161132320d519b6089a4b11283fad28ff282 100644 (file)
@@ -403,7 +403,7 @@ static void amd_xc_cpuid_policy(const struct cpuid_domain_info *info,
          * - incrementing ApicIdCoreSize when it's zero (which changes the
          *   meaning of bits 7:0).
          */
-        if ( (regs[2] & 0x7fu) < 0x7fu )
+        if ( (regs[2] & 0xffu) < 0x7fu )
         {
             if ( (regs[2] & 0xf000u) && (regs[2] & 0xf000u) != 0xf000u )
                 regs[2] = ((regs[2] + 0x1000u) & 0xf000u) | (regs[2] & 0xffu);